[問題] ANDROID BLE Notifications

看板AndroidDev作者 (洋蔥)時間11年前 (2014/07/28 11:53), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
各位前輩好,小弟最近在研究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() 懇請解答,卡了一陣子了… 感謝各位 ----- Sent from JPTT on my Samsung GT-I9300. -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.143.182.245 ※ 文章網址: http://www.ptt.cc/bbs/AndroidDev/M.1406519607.A.816.html
文章代碼(AID): #1JrSatWM (AndroidDev)