Я работал над реактивом native-ble-plx с сенсорным тегом cc2650stk , и у меня возникли проблемы с извлечением данных акселерометра и гироскопа.
Error: Characteristic "f000aa82-0451-4000-b000-000000000000" write failed for device xxxxxx and service "f000aa80-0451-4000-b000-000000000000"
Все отлично работает для всех остальных датчиков тега ticc2650. как влажность, температура, барометр и т. д.
constructor() {
super();
this.manager = new BleManager()
this.state = {info: "", values: {}}
this.prefixUUID = "f000aa"
this.suffixUUID = "-0451-4000-b000-000000000000"
this.sensors = {
0: "Temperature",
8: "Accelerometer",
2: "Humidity",
7: "Magnetometer",
4: "Barometer",
// 5: "Gyroscope"
}
}
serviceUUID(num) {
return this.prefixUUID + num + "0" + this.suffixUUID
}
notifyUUID(num) {
return this.prefixUUID + num + "1" + this.suffixUUID
}
writeUUID(num) {
return this.prefixUUID + num + "2" + this.suffixUUID
}
Мой сенсорный тег Movemnet UUIDS:
MOVEMENT_SERVICE = 'f000aa80-0451-4000-b000-000000000000';
MOVEMENT_DATA = 'f000aa81-0451-4000-b000-000000000000';
MOVEMENT_CONFIG = 'f000aa82-0451-4000-b000-000000000000';
MOVEMENT_PERIOD = 'f000aa83-0451-4000-b000-000000000000';
MOVEMENT_NOTIFICATION = '00002902-0000-1000-8000-00805f9b34fb';
if (device.name === 'CC2650 SensorTag' || device.name === 'SensorTag') {
this.info("Connecting to TI Sensor")
this.manager.stopDeviceScan();
device.connect()
.then((device) => {
this.info("Discovering services and characteristics")
return device.discoverAllServicesAndCharacteristics()
})
.then((device) => {
this.info("Setting notifications")
console.log(device);
return this.setupNotifications(device)
})
.then(() => {
this.info("Listening...")
}, (error) => {
this.error(error.message)
})
}
async setupNotifications(device) {
for (const id in this.sensors) {
//id = 8;
const service = this.serviceUUID(id);
const characteristicW = this.writeUUID(id);
const characteristicN = this.notifyUUID(id);
const characteristic = await device.writeCharacteristicWithResponseForService(
service, characteristicW, "AQ==" /* 0x01 in hex */
)
device.monitorCharacteristicForService(service, characteristicN, (error, characteristic) => {
if (error) {
this.error(error.message)
return
}
console.log(characteristic.uuid+":::"+characteristic.value);
this.updateValue(characteristic.uuid, characteristic.value)
})
}
}
отлично работает для других датчиков, но не для гироскопа и акселерометра.