question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Received advertising data format is not ArrayBuffer

See original GitHub issue

Version

  • react-native-ble-manager v5.0.4
  • react-native v0.45.1
  • Android v5.0.2

Expected behavior

From your example code, it is shown that in handleDiscoverPeripheral, the peripheral object will have a advertising key and it will be an ArrayBuffer ( the same thing also specified in cordova-plugin-ble-central documentation ). it can then be easily converted to UInt8Array or String.

Actual behavior

When I logged the peripheral object it is showing that the advertising key is an object with two keys: ‘CDVType’ and ‘data’. I tried to convert this object to UInt8Array using new Uint8Array(peripheral.advertising) and to String using String.fromCharCode.apply(null, new Uint16Array(buf)). But failed. It is showing an empty result. Am I missing something?

Stack trace and console log

Console log

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
whitedogg13commented, Jun 14, 2017

@marcosinigaglia How do you think about this idea (using bytes rather than base64 for advertising data) ? I can try to make a PR about this one, for both iOS and Android.

1reaction
guerjoncommented, Jun 15, 2017

On LollipopScanner onScanResult i get the advertising data like this

SparseArray<byte[]> array = result.getScanRecord().getManufacturerSpecificData(); byte[] manufacture_data = [] if(array.valueAt(0) != null){ manufacture_data = array.valueAt(0); } and you get an array of bytes with the manufacturerData inside.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I am stuck in determining whether BLE device is connectable ...
The advertisement data in the buffer you are examining is part of the payload and does not contain information from the PDU header....
Read more >
ArrayBuffer, binary arrays - The Modern JavaScript Tutorial
In web-development we meet binary data mostly while dealing with files (create, upload, download). Another typical use case is image ...
Read more >
20. Typed Arrays - Exploring JS
Instances of ArrayBuffer store the binary data to be processed. Two kinds of views are used to access the data: Typed Arrays (...
Read more >
Node.js v19.3.0 Documentation
Basic Node-API data types ... No require , exports , or module.exports; No __filename or __dirname ... arrayBuffer(stream); streamConsumers.blob(stream) ...
Read more >
Persisting and manipulating JS ArrayBuffer data on the server
If I store every Buffer in a binary file, and use filesystem seek/read/write ops, I get finegrained control but I lose convenience, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found