If you are asking a question, please follow this template:
super i deleted my post by accident!!
- My goal is: [describe your goal]
process or at least understand the weird hex data I am getting as a BLE advertisement - My actions are: [describe your actions - code, commands, etc]
I am getting data from a BLE peripheral using a gap_scan. When printed it looks funky I need the last 4 bytes. I am using the example-ble-js project as the basis for my work.
Event.on(GAP.EV_SCAN_RESULT, function(ev, evdata) {
let sr = GAP.getScanResultArg(evdata);
print("sr data", sr.advData);
[Apr 21 15:38:41.636] sr data \x02\x01\x06\x03\x03\x0a\x18\x07\xff2\x0bw\x09\x0cC
- The result I see is: [show the result - log, etc]
[Apr 21 15:38:41.636] sr data \x02\x01\x06\x03\x03\x0a\x18\x07\xff2\x0bw\x09\x0cC
I hate to do this, but I kinda know how to manipulate this in python…
>>> import binascii
>>> weirdstring = "\x02\x01\x06\x03\x03\x0a\x18\x07\xff2\x0bw\x09\x0cC"
>>> binascii.hexlify(bytes(weirdstring, "utf-8"))
b'02010603030a1807c3bf320b77090c43'
>>>
- My expectation & question is: [describe your expectation and your question]
Why does the hex look weird? How do I convert the weird mJS string into bytes? Are there other GAP functions exposed in mJS besides parseName?
thank you