[问题] ANDROID BLE Notifications

楼主: herboy (洋葱)   2014-07-28 11:53:21
各位前辈好,小弟最近在研究Android BLE
设定Notifications时遇到一些奇怪的问题
我的做法是参考官方SDK的说明
private BluetoothGatt mBluetoothgatt;
BluetoothGattCharacteristic characteristic;
boolean enabled;
...
mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
...
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
UUID.formString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor);
然后callback用onCharacteristicChanged()实现
测试的时候用Battery Level没有问题
可以正确的回传装置电池电量
但是当我把sUUID改成血糖用的Glucose
cUUID改成Glucose Measurement和
Glucose Measurement Context时,
(装置是支援BLE的血糖机)
却发现他连onCharacteristicChanged()这个callback都没有进去...
所以想请问有开发过类似设备app的前辈
在Glucose或Heart Rate等类似Service的Notifications写法是否有不同
我有点不能理解为什么一样使用setCharacteristicNotification
Battery Level的情况可以,其他却不行
PS : LogCat有显示setChatacteristicNotofication,
但是却没有进到onCharacteristicChanged()
恳请解答,卡了一阵子了…
感谢各位

Links booklink

Contact Us: admin [ a t ] ucptt.com