Page 1 of 1
Parsing advertisement data (scanRecord)
Posted: 06:51, 21 Nov 2014
by yubozhao
Hi
I am currently working on a project that involves TI sensorTag(cc2541) advertise all of its data to device scanning, instead of going the route of connect and & discover. I checked, that android does not have support for parsing that scanRecord to something useful (like an JSON object). Do you guys know any good ways to archive this?
Thanks
Bo
Re: Parsing advertisement data (scanRecord)
Posted: 11:07, 21 Nov 2014
by Fredrik
You're in luck. Yesterday, working on an unrelated project, I put the finishing touches on my
scanRecord parser. You'll probably want to use the "manufacturer data" field.
Re: Parsing advertisement data (scanRecord)
Posted: 21:27, 21 Nov 2014
by yubozhao
Hi Fredrik
You are awesome. I will check it out now, and let you know how that goes
Re: Parsing advertisement data (scanRecord)
Posted: 02:16, 22 Nov 2014
by yubozhao
hi Fredrik
I keep getting this error when I try to use it
processMessage failed: Error: RangeError: softshould be a multiple ofr cordova.js:1044
processMessage failed: Stack: RangeError: softshould be a multiple ofr
processMessage failed: Message: S11 BLE1081554528 {"scanRecord":"AgEEAwLzGAz\/16X+wAsGDwUAAAACCgAMCWNvV29ya1BvaW50CRb\/AbxqKa7WKQAAAAAAAAAAAAAAAAAAAAA=","address":"BC:6A:29:AE:D6:29","name":"coWorkPoint","rssi":-38}
for this section of code : line 202 var data = new Uint16Array(byteArray.buffer, pos, length);
I tracked it down to this
https://code.google.com/p/v8/issues/detail?id=3159Any ideas of how to fix this?
Re: Parsing advertisement data (scanRecord)
Posted: 15:57, 27 Nov 2014
by micke
I wonder if there is a workaround for this bug? Can the array buffer be constructed in an alternative way?
What Android version and device are you using?
Best, Mikael
Re: Parsing advertisement data (scanRecord)
Posted: 17:13, 27 Nov 2014
by Fredrik
Issue 3159 relates only to the formatting of the error message.
According to the
TypedArray specification, "The given byteOffset must be a multiple of the element size of the specific type, otherwise an exception is raised."
In your example, the Uint16Array is created with offset 5, which is not a multiple of 2. This causes the exception.
I must change the function to use more forgiving means of extracting multi-byte integers. I'll post here again once that's done.
Re: Parsing advertisement data (scanRecord)
Posted: 17:29, 27 Nov 2014
by Fredrik
Fixed, I hope.
I don't have your device, so I can't really test it, but since the exception-throwing line is gone now, it should work better.
Re: Parsing advertisement data (scanRecord)
Posted: 01:58, 28 Nov 2014
by yubozhao
HI guys
Thank you for all of the help!
The test device is Nexus 7 (2012) with 4.4.4 installed and rooted. I will let you know how did this go!