I am using nrf52840 . I am sending data 2 bytes as FF .I put the data in 2d array like this.
char dataSend[1][5]={"FF"};
This char dataSend has 1 row and 5 length .This should send as 2 bytes .for(int i=0;i<1;i++){ printf("&d",dataSend[i]); }
I already debug in terminal as it will print and send as 255 in decimal.
Android apps will prepare to receive the bytes data. But it fail to receive as 2 bytes.It will receive as single byte . So the byte data is
byte[0]=70
byte[1]=70
70 decimal
hex is F
I expected the data as
byte[0]=255.
255 decimal
hex is FFprivate final BleManagerGattCallback mGattCallback = new BleManagerGattCallback() { @Override protected void initialize() { setNotificationCallback(mTXCharacteristic).with((device, data) -> { byte[]=data.getValue; //not receiving as 255 for 2 bytes //only receive as 46 as 1 bytes }); requestMtu(260).enqueue(); enableNotifications(mTXCharacteristic).enqueue(); } @Override public boolean isRequiredServiceSupported(@NonNull final BluetoothGatt gatt) { final BluetoothGattService service = gatt.getService(LBS_UUID_SERVICE); if (service != null) { mRXCharacteristic = service.getCharacteristic(LBS_UUID_BUTTON_CHAR); mTXCharacteristic = service.getCharacteristic(LBS_UUID_LED_CHAR); } boolean writeRequest = false; boolean writeCommand = false; if (mRXCharacteristic != null) { final int rxProperties = mRXCharacteristic.getProperties(); writeRequest = (rxProperties & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0; writeCommand = (rxProperties & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) > 0; // Set the WRITE REQUEST type when the characteristic supports it. // This will allow to send long write (also if the characteristic support it). // In case there is no WRITE REQUEST property, this manager will divide texts // longer then MTU-3 bytes into up to MTU-3 bytes chunks. if (writeRequest) mRXCharacteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT); else mUseLongWrite = false; } return mRXCharacteristic != null && mTXCharacteristic != null && (writeRequest || writeCommand); } @Override protected void onDeviceDisconnected() { mRXCharacteristic = null; mTXCharacteristic = null; mUseLongWrite = true; } };