react-native-ble-manager icon indicating copy to clipboard operation
react-native-ble-manager copied to clipboard

requestMTU success, but still receieved 20 characters

Open 15638228357 opened this issue 4 years ago • 2 comments

BluetoothManager.connect(this.peripheralId) .then(() => { console.log('Connected'); BluetoothManager.requestMTU(200); setTimeout(() => { this.getNotic(); }, 500); }) .catch(error => { console.log('Connected error:', error); });

15638228357 avatar May 26 '21 03:05 15638228357

requestMTU doesn't seem to be doing anything version 7.6.1, also noticed packages are still 20 bytes. On 8.0.1 the Promise never returns... it gets stuck in that line

jaimebg avatar Jan 27 '22 09:01 jaimebg

try setting the MTU value to 185 or less. It worked for me

AlexManSPB avatar Aug 04 '22 10:08 AlexManSPB

I am still facing the same issue. I'm trying to set MTU to 512 it shows ok in logs but actually it still sending 20 bytes chunks. Please help if someone resolved this issue

HamzaQayyumMST avatar Jul 27 '23 12:07 HamzaQayyumMST

I am still facing the same issue. I'm trying to set MTU to 512 it shows ok in logs but actually it still sending 20 bytes chunks. Please help if someone resolved this issue

Hi! Experimentally, I found that in some Android systems, the MTU of more than 185 does not work. Try to make the value no more than 185. A delay of 2000 ms is required after BleManager.connect. My code example: ... const TimePauseMTU = 2000; // необходима задержка после соединения (перед установкой MTU)

await BleManager.connect(peripheral.id);

await new Promise((resolve, _reject) => setTimeout(resolve, TimePauseMTU), );

if (Platform.OS === 'android') { await BleManager.requestMTU(peripheral.id, 185) }

await BleManager.retrieveServices(peripheral.id); ...

AlexManSPB avatar Jul 28 '23 08:07 AlexManSPB

@AlexManSPB I tried but it didn't worked is there another solution. should i use react native ble -plex?

HamzaQayyumMST avatar Jul 31 '23 06:07 HamzaQayyumMST

@AlexManSPB I tried but it didn't worked is there another solution. should i use react native ble -plex?

I think react native ble-plx won't solve your issue. A possible solution is to accept data in several smaller packets

Perhaps your peripheral device allows the MTU to be only 20, in which case you will not be able to increase it higher.

AlexManSPB avatar Aug 18 '23 13:08 AlexManSPB