I am trying to build an iot platform that takes the sensor data via smartwatch and pass to Raspberry pi (BLE Gateway) and sends to webserver. I used https://github.com/noble/noble JS, able to connect to watch and can see the characteristics and services but cannot get the data. This is how I wrote
const noble = require('@abandonware/noble')
noble.on('stateChange', async (state) => {
if (state === 'poweredOn') {
await noble.startScanningAsync([], false);
} else {
noble.stopScanningAsync();
}
});
noble.on('discover', async (peripheral) => {
console.log(peripheral.id)
if (peripheral.id === "xxxxxxxxxx") peripheral.connectAsync(() => {
peripheral.discoverServices(['fff0'], async (e, services) => {
services[0].discoverCharacteristics(['fff7'], async (e, characteristics) => {
const chara = characteristics[0]
chara.once('read', (data) => {
console.log(data);
})
chara.once('notify', async function (isNotification) {
console.log('Notification', isNotification);
})
chara.readAsync(async (error, data) => {
console.log(data);
})
})
})
})
})
I contacted the watch manufacturer and they told me that I have to pass the 16 byte data, so for example to get the battery i need to pass
0x13 AA 00 00 00 00 00 00 00 00 00 00 00 00 00 00 CRC
But they never told me how to pass or which language to use. They told me to go through BLE protocol but this is bit confusing. Anyone has any idea, how this can be done? Do I need to use python to pass the 16-byte command and get response. Thank you