I have a device that sends very simple data via Bluetooth to an Android app. I want to receive that data with an Arduino instead. Now the question is, what kind of bluetooth module do I need? Would this module do the job?
And what kind of code do I need to connect/pair and receive data?
The protocol seems to be custom. And the data that I want to extract can be found by searching for simple byte sequences in the received packets.
This is what other people have found out about the protocol:
Ok, I got to a start from the data captures sent by @Tilmann. It's NOT a plaintext protocol, as I first thought, due it being parsing integers from text, but thankfully it seems to be a simpler binary protocol than, say, ASN.1 or Zigbee. I've got to the point where I can locate the following values:
62,84V 0,00km/h 0,000 "mRunNow" (trip-meter?) -0,25A Current 36,530 Temperature (Celsius?)
They're using a somewhat weird (and inefficient) way of parsing the binary data, where it's first turned into a hex-string and at some point decoded to string with GBK-charset ("GBK is an extension of the GB2312 character set for simplified Chinese characters, used in the People's Republic of China"), and then parse the values 2 bytes at a time as base-16 (hex) integers (which are later cast to shorts) from the middle of other data (I didn't notice at first that the integers were parsed as base-16). The datapackets seem to be separated by "18 5A 5A 5A 5A" (as hex), but it's not always the voltage etc. data after that. I'll try to dig deeper when I got the time.
Here's an example of the datacapture with seemingly correct values (after one of the 18 5A 5A... -headers):
INDEX 0 188C Voltage, 1/100th 1 0000 Speed, fixed point, 3.6 * value / 100 2-3 00000000 "mRunNow", 32bit-value, first bytes are high bits (shifted up 16 bits), the later low bits, 1/1000th (so probably meters turned into kilometers) 4 FFE6 Current, 1/100th 5 F808 Temperature, 1/340th + 36.53
The decoding seems to end (to start a new round later) after it detects something like "00 00 04" (called "type_ch" in the code) after the measurement values:
str2 = str1.substring(i + 4, i + 4 + 4); BluetoothChat.this.mPackageTemp[(i / 4)] = Integer.parseInt(str2, 16); continue; str2 = str1.substring(i + 4, i + 4 + 4); BluetoothChat.this.mPackageTemp[(i / 4)] = Integer.parseInt(str2, 16); continue; str2 = str1.substring(i + 4, i + 4 + 2); BluetoothChat.this.type_ch = Integer.parseInt(str2, 16); } } while (BluetoothChat.this.type_ch != 4);
The odotemeter seems to be sent out in it's own packet, terminated again with 00 00 04:
18 5A 5A 5A 5A 55 AA 00 08 82 EE 00 00 00 00 00 00 00 00 00 00 00 00 04
Don't know what the 55 AA is, but the 00 08 82 EE corresponds to 557 806 which is closest to the trip meter value of 557,798km I could find (that should be Tillmans odometer, but I think there's some rounding error, as so far I can't find that exact figure anywhere, and the value is divided by 1000 (to get kilometers from meters) and then formatted for display.
If someone has the Kingsong App, could you please send it to me (or just link where I can get it), if it's using the same protocol, getting it decompiled too might give some more clues.
I want to extract the 5 mentioned values (Voltage, Current, Speed, Temprature and mRunNow).