mJS process hex data

If you are asking a question, please follow this template:
super i deleted my post by accident!!

  1. My goal is: [describe your goal]
    process or at least understand the weird hex data I am getting as a BLE advertisement
  2. 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 
  1. 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'
>>>  
  1. 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

What do you mean by ‘weird’ ? Are you talking about the print formatting or the actual data ? I don’t think you are getting an hex string but binary data being printed in hex.
You should be able to use the proper method for your data type. E.g.: the at() method works fine with UART data obtained using the read() method. I’m not familiar with those GAP functions, though. mJS docs here