我正在尝试让 Android Nexus 5X 应用程序与 NRF51 芯片一起使用,并面临一些问题,特别是在写入特性方面。真的希望能得到一些帮助。
我正在尝试通过应用程序在 nrf 上设置实时时钟 (RTC)。向我提供的有关 GATT 服务特性的详细信息如下:
属性:读取 - 强制、写入 - 强制、WriteWithoutResponse - 排除、SignedWrite - 排除、通知 - 排除、指示 - 排除、可写辅助 - 排除、广播 - 排除。
安全性:ENC_NO_MITM
描述:无
连接到 nrf 后,我的 'onServiceDiscovered()' 实现如下。我能够执行 readCharacteristic,这导致调用“conCharacteristicRead()”,但 writeCharacteristic() 失败。将不胜感激任何指导。非常感谢!
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
// Get the characteristic
BluetoothGattCharacteristic loggingRTCCharacteristic = gatt.getService(loggingServiceUUID).getCharacteristic(loggingRTCControlPointCharacteristicUUID);
// Read characteristic (which succeeded, as onReadCharacteristic is invoked)
boolean successFlag = gatt.readCharacteristic(loggingRTCCharacteristic);
// Check for success.
// Set a plausible timestamp.
int year_lsb = 221; int year_msb = 7;
int month = 3;
int dayOfMonth = 4;
int dayOfWeek = 7;
int hour = 9;
int min = 3;
int sec = 15;
byte[] timeStamp = {(byte)year_lsb, (byte)year_msb, (byte)month, (byte)dayOfMonth, (byte)dayOfWeek, (byte)hour, (byte)min, (byte)sec};
logingRTCCharacteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT);
// This returns a failure. The onCharacteristicWrite() function is not invoked either.
successFlag = gatt.writeCharacteristic(loggingRTCCharacteristic); }