CC2564MODN的notify通知问题!
时间:10-02
整理:3721RD
点击:
开发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);
}
bin,
空中抓包可以看一下吗?确认一下你的characteristic操作的handle的正确性。
谢谢您的回答!我是首次接触蓝牙BLE通信,现在是用Java写的程序部署到Android手机上,我理解的是获取到服务后就可以利用不同的characteristic属性值发送相应的指令,所以不是太明白您所说的空中抓包是怎么回事!麻烦您能详细说明一下吗?谢谢。
