how to request OBD parameters and receive them - android

I'm new to android and I thought to develop a bluetooth app to retrieve parameters from an OBDII device. I have downloaded the sample bluetooth chat application and configured it. The problem is how and what is the message that I need to send to the OBDII device in order to receive the parameters? and how should I handle them in the application side?
Thank you.

You're question is not very specific, but I will give you some guidelines.
First of all, test with an exisiting OBD-II reader application if your car actually works.
The ELM327-bluetooth-connector you have (I assumed it's a ELM327) translates ASCII commands to voltages. So all you have to do, is send some ASCII commands, and you get ASCII-values back.
The OBD protocol knows several modes and parameter's, but I will explain to get real-time data. That's mode 1.
Mode 1 Sending
This is kinda simple as it is.
Mode 1 is '01'.
After that part, you have to send a parameter ID with it. 0C is for RPM, 0D is for speed. (Look into the link below).
And after each command you have to send a Carriage Return. (CR = '\r')
So basically, for speed, you have to send:
'010D\r'
Receiving Mode 1
The answer you will get back from a Mode 1 query, starts with '41'.
After that the parameter ID is returned, and then the value.
The value is most of the time in hex. You will have to do some conversion to read a human readable value. For more information, see the link, as formula's to convert are provided too.
Example:
'410D17'
So 17 is the value of your current speed in hex. 17 to decimal is 23, so you're driving with 23 km/h.
This wikipedia page has some good information about it:
OBD-II Parameters

Related

ANT transmission protocol: Reading Parcel after sending Broadcast Messages

I am a newbie in this forum and I'm not very familiar with app development in general, however I am in the situation in which I have to develop an app to acquire ANT data from 3 nodes. I am basing myself on a previously developed app for Windows in C++ (.exe extension).
I am using a Samsung Galaxy A51 as a mobile phone and my Android Studio API is 29.0.
I am starting with the case of a single node and have implemented the following steps in my app:
bindService() and it returns that it is true;
getChannelProvider() and it returns a name of the channel;
acquireChannel(), with a setup of a default Public network;
assignChannel() to the type of a Shared Bidirectional Master;
open() the channel;
setPeriod() to the user period I chose (1092, corresponding to 30 Hz which is what I want to achieve in order to look for each of my 3 units with a frequency of 10 Hz);
setBroadcastData() with a payload that I need to call one of my units.
At this point, I expect to have sent my broadcast data and I am waiting for an "answer" from my unit. How do I read the message? I am finding many functions that want an AntMessageParcel type as input but I don't know where to get that Parcel from. Also, I am not sure that the logical order of the app is correct or if I need additional steps in between my code.
I thank you for your help.
Have a nice day!

How to decode and read unity udp packets?

I am capturing the udp traffic of my mobile device to understand how the unity messages are sent, with what format, etc.
Currently I am not being able to even read them, I only see their hexadecimal value and if I want to transform it into ascii it does not make any sense. Only sometimes do you see a meaningful value like my username.
As I was able to speak with the developers of the game, unity sends by udp packages values ​​such as the position, the speed with which the character moves, the strength of the shots etc. But I need to be able to see those values ​​and now I can't figure out how.
Most of the packets are short and look like this:
Hexa: 450000282e4c40002711d6cb12c07b11c0a80034b55aeeff00146cac000185649a8b002080000000
Ascii: E(.L#'ÖËÀ{À¨4µZîÿl¬d
The biggest one with some information are similar to this:
Hexa:450002f6d07040002c1115bf12d79214c0a800349c8aff0a02e2d47a0001974c02cf0020c0000000ff82cb00020082c60201000c000001000c00016302030001604df870f965340ea85076954c4641b5cdcccdc20ad7233dcdcc90c2340200000000cdcccdc20ad7233dcdcc90c20100b44200000000000000000100b4420100b442fa000000803f010000000000000000000000000000000400c236ee4343498644a42ef08bbd67c4e8f168eb9d20563004c96d41d68b427abdd2843fe59f909904f8e91cc9b542033100000c00546573747465737474657374000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000020000001300000010000000510200004b000000e1fb64def58d5524fbaf9b5cf0547b9a0001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000006cd5317f111d42141a2481f7e95223c005000000dba0d79272a295c4a9a968a669a3650905000000fd301ab653c6cc548bb9862b0f9b3aa005000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000006cd5317f111d42141a2481f7e95223c00500000000000000000000000000000000000000dba0d79272a295c4a9a968a669a365090500000000000000000000000000000000000000fd301ab653c6cc548bb9862b0f9b3aa005000000000000000000000000000000000000000000000000000080f404353f00000080f204353f02000400010036000a0002010000000000000000000000002600000000000000000000000000010000000000000000000000000000000000000000000000000010000a0003020000000000000000000000000000
Ascii: EöÐp#,¿×À¨4ÿ âÔzLÏ ÀÿËÆc`Møpùe4¨PvLFAµÍÌÍ ×#=ÍÌÂ4ÍÌÍ ×#=ÍÌ´B´B´Bú?Â6îCCID¤.ð½gÄèñhë V0ÉmAÖBz½Ò?åøéɵB1TesttesttestQKáûdÞõU$û¯\ðT{lÕ1B$÷éR#ÀÛ ×r¢Ä©©h¦i£e ý0¶SÆÌT¹+: lÕ1B$÷éR#ÀÛ ×r¢Ä©©h¦i£e ý0¶SÆÌT¹+: ô5?ò5?6 &
Where Testtesttest is my Username
Any ideas?

"Best" way for Android Arduino communication via ethernet

I have an Arduino and an Android app which are communicating to each other via ethernet. The arduino shows a very simple webpage with only some values and an ID as seen below.
$1$201 //Value 1 ($1$): Temperature 20.1 degrees
$2$66 //Value 1 ($2$): Humidity 66%
$2$1 //Value 2 ($2$): Heating relay is on (1)
etc. up to 50 values
The Android app will read the data from this webpage as a string using a HTTP get request, filters the data and shows the values on a custom made screen. It is also possible to send some data to the arduino to change some settings or switch a relay or something. You can see is as some kind of thermostat. So far so good.
The "problem" is that I need to manualy update the data using a button. The question is: How can I update my values automatically?
I was thinking to just send a httpRequest every few seconds (polling), but I'm not sure if this is the way to go because it seems to use of lot of data.
Who can advise me what would be a good solution?
Regards,
Bas
The 'best' choice here will depend on your goals. Polling is easy to implement on the client (android) side. You could experiment with the optimal polling time depending on how 'fresh' your data needs to be compared to how much data you want your app to use. Alternatively, you could find or implement an http socket server such as ArduinoWebsocketServer, keeping in mind that the processor in your Arduino may or may not have the power needed to run this.

BLE Sending Blob request through android device

Is there someone using blob request (long read) from an android device?
We work with a CC2540 from TI, connected to a android 4.4.
We try to read a long characteristic value (size more than 23 bytes). In the android API for BLE, we have not seen a readBlob or readLong method.
We expect that the Android BLE Stack do the job for us, by reading a characteristic presentation format (same way has notification), but it doesn't works.
We have no idea how to send Blob Request through Android.
Let me make this clear that Android has only one method to read the value of a characteristic, readCharacteristic(characteristic). You can use this method to get the value of a characteristic of any length. Android takes care of forming a ReadBlob request; it's all in the back end. You'd have to change the code of your CC2540 though, to make it work with ReadBlob request. Once you make all the required changes at your CC2540 end, on calling readCharacteristic() from Android, you'll get the entire value of the characteristic which you can access in the onCharacteristicRead() callback.
You can´t, BLE characteristic values are limited at 20 bytes. So if you want to send or receive more than 20 bytes, you have to split it into 20 byte chunks. See this topic on the issue.

Android Bluetooth HDP-Blood Pressure Monitor

Hi I have developed an android program to display the readings from an omron bp monitor. In the IEEE specification of BP monitors it is said that the BP monitor can send upto 25 datas in one event report.
I am getting the following as data from the monitor,it has only one reading and sometimes it is not the latest reading but the first one from the device's memory
e7000052005000010101004a0000ffffffff0d1f0040f000000100010038004200030032000100
12000300060062004d005420140327213502000002000a005120140327213502000003000
a000020140327213502000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000
How should I get the program to get the latest data or how can I send request monitor to send multiple measurements in one event report?Pls help
You will need to consult the data sheet for the device which describes all the data, and how it should be interpreted.
This data string, actually should contain all the data.
The data sheet should have the details about which bits or a combination of bits gives you what.
For example:
The first 3 bits would give you the Device short name
The 4th, 5th, 6th and 7th bit would give you the timestamp of the reading.
The 9th and 10th bit could give you the Systolic measurement, and so on.
IEEE doesn't specify how this data should be arranged I guess. I have worked on another BP monitor, whose manuals had elaborate documentation about this.

Categories

Resources