Parsing advertisement data (scanRecord)

Ask, and ye shall receive.
yubozhao
Posts: 4
Joined: 06:41, 21 Nov 2014

Parsing advertisement data (scanRecord)

Postby yubozhao » 06:51, 21 Nov 2014

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
Last edited by yubozhao on 03:03, 22 Nov 2014, edited 1 time in total.

Fredrik
Site Admin
Posts: 196
Joined: 15:00, 18 Nov 2013

Re: Parsing advertisement data (scanRecord)

Postby Fredrik » 11:07, 21 Nov 2014

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.

yubozhao
Posts: 4
Joined: 06:41, 21 Nov 2014

Re: Parsing advertisement data (scanRecord)

Postby yubozhao » 21:27, 21 Nov 2014

Hi Fredrik

You are awesome. I will check it out now, and let you know how that goes

yubozhao
Posts: 4
Joined: 06:41, 21 Nov 2014

Re: Parsing advertisement data (scanRecord)

Postby yubozhao » 02:16, 22 Nov 2014

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=3159


Any ideas of how to fix this?

User avatar
micke
Posts: 256
Joined: 20:49, 18 Nov 2013

Re: Parsing advertisement data (scanRecord)

Postby micke » 15:57, 27 Nov 2014

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

Fredrik
Site Admin
Posts: 196
Joined: 15:00, 18 Nov 2013

Re: Parsing advertisement data (scanRecord)

Postby Fredrik » 17:13, 27 Nov 2014

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.

Fredrik
Site Admin
Posts: 196
Joined: 15:00, 18 Nov 2013

Re: Parsing advertisement data (scanRecord)

Postby Fredrik » 17:29, 27 Nov 2014

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.

yubozhao
Posts: 4
Joined: 06:41, 21 Nov 2014

Re: Parsing advertisement data (scanRecord)

Postby yubozhao » 01:58, 28 Nov 2014

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!


Return to “Questions and answers”

Who is online

Users browsing this forum: No registered users and 22 guests