我们如何将大字节数据发送到BLE设备?

时间:2018-12-20 10:33:58

标签: java android bluetooth bluetooth-lowenergy mtu

我有两个特性,没有响应,一个带有描述符2902,另一个没有描述符。 我想发送20个以上的字节,但终止时只写16个字节 另一个是0100000等 我正在使用以下代码。

void sendDataToBLE(String str) {
    str = "st,1544697039";

    Log.d(TAG, "Sending result=" + str+ " "+characteristicTX);
    final byte[] tx = str.getBytes();

    if (mConnected) {


        characteristicTX.setValue(tx);


        mBluetoothLeService.writeCharacteristic(characteristicTX);
        mBluetoothLeService.setCharacteristicNotification(characteristicRX, true);
        mBluetoothLeService.readCharacteristic(characteristicRX);

        }
}

下面是我的日志

 I/BluetoothLeService: onServicesDiscovered: characteristic=c364aea7-5978-41fc-b6c0-4f8292368def

 I/BluetoothLeService: onServicesDiscovered: characteristic=c364aea7-5978-41fc-b6c0-4f8292368df0

  W/BluetoothLeService: onServicesDiscovered: found LED

 E/sonbroadcastupdate: com.example.bluetooth.le.ACTION_GATT_SERVICES_DISCOVERED
 D/BluetoothGatt: onConfigureMTU() - Device=00:1E:C0:3C:EE:7D mtu=23 status=0

 E/SonaMtu: 23
  D/BluetoothAdapter: stopLeScan()

 D/BluetoothAdapter: scan not started yet

 W/PhoneWindow: Destroyed,return false!

 E/sonalitim: st,1545052413  [B@e0dd805  st,1545052413

 D/DeviceControlActivity: Sending result=st,1545052413 
 android.bluetooth.BluetoothGattCharacteristic@c94b05a

 E/sonalirEAD: [B@28a6b28b
 D/DeviceControlActivity: Sending resultson=st,1545052413

 I/BluetoothLeService: data[B@3be28f68

 D/BluetoothLeService: st����������������������

如何增加字节数限制,以便将完整的数据发送到BLE设备?

我尝试使用代码增加MTU值,但没有增加MTU值

0 个答案:

没有答案