I am working on a React-native ble project that now requires a Broadcaster (device) observer (client) relationship.
Is there a high level (JavaScript) way of reading the advertisement packet of ble to obtain the byte array? I am trying to read the entire advertisement packet rather than any format.
I have use react-native-ble-manager and am looking at react-native-ble-plx by Polidea:
https://polidea.github.io/react-native-ble-plx/#devicemanufacturerdata
It looks as if specific fields of the advertisement packet are available under Device: such as manufacture data (the thing I am most interested in and manipulating on the embedded side). However, Most of Polidea examples obtain the Device from a connection.
I may be misinterpreting the documentation? Could use some advice/ direction to any further references.
Was misunderstanding the documentation..
2 minutes of stripping down some complexity revealed what I needed to know.
Answer provided for reference of others:
BleManager's startDeviceScan function(UUIDS, options, listener) where listener is the function where second argument is returned device object. Access its fields from there.
this.manager.startDeviceScan(null, null, (error, device) => {
if (error) {
console.log(error.message);
return;
}
if(device.name === "Some_encoding_Sensor_1"){
console.log(device.manufacturerData);
}
Example shown should filter based off of UUID rather than device.name but that may be easier to work with initially/dynamically (having multiple devices with renaming scheme).
Take a look on this JS library: advlib
It helps with advertising packet decoding and currently supports the following protocols:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.