をcharactersticへの書き込み中に、私は次のように使用しています私は、BLE device.Iに読み取りおよび書き込み操作を実行しようとしていますライブラリreact-native-ble-managerブレ-取得エラーコード - 128
を反応させるのに成功し、読み取り操作を行うことが可能です。しかし、私はBLEデバイスに書き込み中にエラーコード128を取得しています。
最初、私は特性のための通知を有効にしています -
const base64String = new Buffer('0x00B00050D0', 'hex').toString('base64');
BleManager.write(peripheralId, serviceId, characteristicId, base64Value)
書き込み操作のリターンエラーコード-128 - base64文字列に
変換する '進' 値 -
BleManager.startNotification(peripheralId, serviceId, characteristicId)
書き込みは、このようなものです
:(
UPDATE - これは、通知を開始し、付加価値 完全なファイルを書き込むためのコードスニペットでは、これは、リソースがないエラーですhere- BluetoothLeService.java
public void writeCharacteristic(BleCharacteristic bleCharacteristic, String inputValue) {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return;
}
if (!bleCharacteristic.isNotificationStarted()) {
Log.w(TAG, "Notification not started please start notification");
return;
}
BluetoothGattCharacteristic bluetoothGattCharacteristic = bleCharacteristic.getBluetoothGattCharacteristic();
bluetoothGattCharacteristic.setValue(inputValue);
mBluetoothGatt.writeCharacteristic(bluetoothGattCharacteristic);
}
public void setCharacteristicNotification(BleCharacteristic bleCharacteristic) {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return;
}
boolean enable = !bleCharacteristic.isNotificationStarted();
Log.d(TAG, "setCharacteristicNotification(device=" + mBluetoothDeviceAddress + ", UUID="
+ bleCharacteristic.getUUID().toString() + ", enable=" + enable + ")");
BluetoothGattCharacteristic characteristic = mBluetoothGatt.getService(bleCharacteristic.getServiceUUID()).getCharacteristic(bleCharacteristic.getUUID());
mBluetoothGatt.setCharacteristicNotification(characteristic, enable);
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(enable ? BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE : new byte[]{0x00, 0x00});
boolean result = mBluetoothGatt.writeDescriptor(descriptor);
bleCharacteristic.setNotificationStarted(result);
Log.d(TAG, "setCharacteristicNotification(device=" + mBluetoothDeviceAddress + ", UUID="
+ bleCharacteristic.getUUID().toString() + ", enabled=" + result + ")");
}
:ここ
は一例です。 0_r1/stack/include/gatt_api.h#49)、エラーは 'GATT_NO_RESOURCES'を意味します。それがどういう意味なのかわからない – Distjubo
奇妙なことに、 'write'の代わりに' writeWithoutResponse'を使うとどうなりますか?これで問題は解決しますか? – Distjubo
@Distjubo writeWithoutResponseで試してみましたが、エラーは発生しませんでしたが、問題は です。 を書き込んだ後に応答が必要です。2.特性型がwriteWithoutResponseではありません。 – Subham