[問題] 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