WowWeeLabs/MiP-BLE-Protocol

Value translation

Closed this issue · 4 comments

I'm having this problem when working with BLE.

This is the command I send to mip:

[D0:39:72:A2:84:DE][LE]> char-write-cmd 13 14

And this is what I get:
Notification handle = 0x000e value: 31 34 30 45 30 32 31 42 30 37

I understand this should display year, month, date. The question is how should I translate this ?

Just to clarify in your example above, are you writing 0x13 or 0x14 ??

For example, to get the software version date you should only be writing 0x14.

0x14 is the software version date and 0x13 is for storing arbitrary values into the EEPRom.

[D0:39:72:A2:84:DE][LE]> char-write-cmd 14
Usage: char-write-cmd

13 is the handle value if I don't put 13 in there, it will be error.
It was originally 0x0013.

Usage: char-write-cmd this is the error

I can understand the confusion, receiving commands can be a little bit strange but let me try to break it down. The most important concept to understand from the documentation is this:

All received commands come in an ASCII encoded string.

So taking your example, you are sending command 0x14 which is get firmware version, it should return you back 4 bytes according to our documentation. Let me run you through step by step:

  1. Send 0x14 to the robot
  2. Receive 0x31,0x34,0x30,0x45,0x30,0x32,0x31,0x42,0x30,0x37 raw bytes from the robot
  3. Convert them to ASCII, for this example I just use a simple website. This gets the result 140E021B07
  4. Here are your bytes you can now use to interpret the command:

14 = Command 0x14 you sent, it's echoed back
0E = Year 14 (when converted to decimal)
02 = Month 02 (when converted to decimal)
1B = Day 27 (when converted to decimal)
07 = Number 7 (when converted to decimal) for the revision on this day

So there you go, it's a little bit confusing because at step 4 you actually have a string, but you need to realise that it's actually an ASCII string representing HEX.

I've got some sample code in the readme if your using Objective-C to convert the hex to ascii