开发Android手机APP和CC2564MODN通信,已经获取到服务,下面是一个单击按钮事件,负责发送notify属性变化通知,但是调用setCharacteristicNotification()之后,并没有进入回调函数onCharacteristicChanged(),请问这是为何?
public void onBtTest(View view ){
BluetoothGattService service = mBluetoothGatt.getService(UUID.fromString("53455206-444C-5020-4E49-52204E616E6F"));
if(service == null)
{
Log.i("get service", "not find!");
}
BluetoothGattCharacteristic characteristic = service.getCharacteristic(UUID.fromString("4348411D-444C-5020-4E49-52204E616E6F"));
if(characteristic == null)
{
Log.i("get charateristic", "not find!");
}
if(characteristic != null)
{
Log.i("测试notify 属性!", "characteristic");
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor);
}
mBluetoothGatt.setCharacteristicNotification(characteristic, true);
Log.i("notify 属性!", "返回notify属性!");
}
应该进入的回调函数,但实际没有进入!(想不明白怎么回事)
public void onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic)
{
Log.i(TAG, "这里是notify特性的数据接收,回调此方法");
broadcastUpdate(ACTION_DATA_AVAILABLE, EXTRA_NOTIFY_DATA,characteristic);
}