Closed psambit9791 closed 5 years ago
This does not look like a question regarding this library but a general bluetooth question. This library does not expose any handles. Are you sure you wanted to ask the question here?
I tried using the following code to write value to the specific UUID:
const characteristic = await this.device.writeCharacteristicWithResponseForService(SERVICE_UUID, "00002902-0000-1000-8000-00805f9b34fb", value);
But since the UUID contains multiple attributes, the write could not take place. Is there a way to specify how I can write to the specific attribute of a characteristic?
There is no support for writing descriptors in this library yet. It is all handled for you. https://github.com/Polidea/react-native-ble-plx/wiki/Characteristic-Notifying
Thanks. That worked!!!
@psambit9791 , im trying to do this. How you do to get notifications for this descriptor ?
This was a long time back. From memory, the monitor() function on the relevant characteristicUUID helped me.
This was a long time back. From memory, the monitor() function on the relevant characteristicUUID helped me.
by monitoring the feature I can get all the data when I write to the RACP feature, but I can't get the data when I send it directly from the device to my app. Searching a lot I found it might be the descriptor 2902 that I wasn't dealing with. But I don't know how to monitor this descriptor :(
currently this is what I have. I can read all meter data, but I cannot send meter data to my app. This way I can't get the glucose value when this data is measured
` const connect = async deviceId => { const device = await bleManager.connectToDevice(deviceId); console.log('connected device: ', device); await device.discoverAllServicesAndCharacteristics();
const services = await device.services(); console.log('services: ', services); };
const notifyCharacteristic = (deviceId, characteristicUUID) => { const serviceUUID = '00001808-0000-1000-8000-00805f9b34fb';
bleManager.monitorCharacteristicForDevice( deviceId, serviceUUID, characteristicUUID, async (error, characteristic) => { if (error) { console.log('monitorError: ', error); }
// console.log('monitorCharacteristic: ', characteristic);
// // console.log('monitorCharacteristicValue: ', characteristic.value);
console.log('monitorCharacteristic: ', characteristic);
const values = buffer.from(characteristic?.value || '', 'base64');
console.log('values: ', values);
if (values.length > 5) {
const glucoseValue = values[12]; // 12th position in the case of my device
console.log('glucoseValue: ', glucoseValue);
}
},
); };
const writeCharacteristic = async ( deviceId, characteristicUUID, command = '0x0101', ) => { const serviceUUID = '00001808-0000-1000-8000-00805f9b34fb';
// const dataMostSignificantByte = (command >> 8) & 0xff; // const dataLeastSignificantByte = command & 0xff;
// const dataByteArrayInLittleEndian = [ // dataLeastSignificantByte, // dataMostSignificantByte, // ]; // const dataInBase64 = buffer // .from(dataByteArrayInLittleEndian) // .toString('base64');
const allValuesRetrieverInBase64 = buffer .from([0x01, 0x06]) .toString('base64');
await bleManager.writeCharacteristicWithResponseForDevice( deviceId, serviceUUID, characteristicUUID, allValuesRetrieverInBase64, ); }; `
My objective is to write notification enable/disable values to 0x002902, but it has multiple handles within it for various functions. This is what the UUID looks like on gatttool:
char-read-uuid 00002902-0000-1000-8000-00805f9b34fb handle: 0x0004 value: 00 00 handle: 0x0023 value: 00 00 handle: 0x0026 value: 00 00 handle: 0x0029 value: 00 00 handle: 0x0034 value: 00 00
I cannot find any information on the documentation on how to write values to these specific handles within the UUID.
Any help would be much appreciated.