sandeepmistry / arduino-BLEPeripheral

An Arduino library for creating custom BLE peripherals with Nordic Semiconductor's nRF8001 or nR51822.
MIT License
462 stars 179 forks source link

How to send more than 20 bytes fast to Android app? #245

Open dots123 opened 5 years ago

dots123 commented 5 years ago

I have a custom board with nrf52832 and softdevice s132. It says that theoretically it can reach speed up to 190 kBytes/s. But when I try to send a String splitted in 20 chars, in the NRF Connect I see it sends only the last 20 bytes of that string. In Arduino serial it prints correct all the parts. If I add a delay(1000); between every st.setValue(buf[i]) AND read every second in the NRFConnect, then it display every 20 bytes of that string.

I've tried with an Android developer to create a custom app and the behavior was the same. I can get that string only with a delay(100). If I decrease that delay or eliminated it, I loose chunks of string. The problem is that I need to send up to 1 Mbytes of data to phone and in this way it seems a headache.

Do you have/know an example with long strings?

kevin-webster commented 5 years ago

This is pretty much the same behaviour I'm seeing. Fast streaming of data is consistently unreliable and causes the entire BLE mechanism to just stop transmitting. I'm going to investigate adding various length delays between transmissions but this shouldn't be needed.

kevin-webster commented 5 years ago

@dots123 I don't know if you've found a solution to your issue however, if you find the function called setConnectionInterval which is part of the BLEDevice, you can change the "default" connection interval from 50ms down to 7.5ms in some instances. I have done this on my BLE device and connection to a Samsung Galaxy S tablet, the data transfer is now super-fast with no lost packets.

dots123 commented 5 years ago

Great! I'll try it!

Thank you!

kevin-webster commented 5 years ago

@dots123 Did this work for you? I've had some massive performance improvements since changing the connection interval but I think really, I need to target the latest nRF52 SDK and soft-device to get extra performance benefits.

dots123 commented 5 years ago

I had some improvements. I've got up to 11k, which is acceptable for now. If you change also Advertisment interval (30 instead of 100), maybe you can go higher. But it's ok if you use it only with Android. Ios has different settings accepted and you need to use them. I haven t tried but I ve read many problems with that.

On Thu, Oct 25, 2018 at 13:04, webzoidnotifications@github.com wrote:
@dots123 Did this work for you? I've had some massive performance improvements since changing the connection interval but I think really, I need to target the latest nRF52 SDK and soft-device to get extra performance benefits.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

kevin-webster commented 5 years ago

Thanks for the hint about the advertisement interval, I'll give that a try.

I think I'm going to push forward an update which targets the latest SDK and improvements from Nordic and at the same time, update the bootloader for the Sparkfun nRF52832 breakout board. The SDK currently used is pretty out-dated and it doesn't look like there's much future progress planned here.

dots123 commented 5 years ago

I believe you should look at SoftDevice! I use 132 v2. But other versions have improved speed. Take a look on Nordic SoftDevice' site. I dont think that bootloader or others will solve this problem.

On Thu, Oct 25, 2018 at 16:24, webzoidnotifications@github.com wrote:
Thanks for the hint about the advertisement interval, I'll give that a try.

I think I'm going to push forward an update which targets the latest SDK and improvements from Nordic and at the same time, update the bootloader for the Sparkfun nRF52832 breakout board. The SDK currently used is pretty out-dated and it doesn't look like there's much future progress planned here.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

kevin-webster commented 5 years ago

Ok, I'll take a look.

The bootloader is aside from this and the issues, but I'd quite like to develop (well, its a necessity really) an open OTA solution for the Sparkfun board.

pvonmoradi commented 3 years ago

@webzoid I've set bleSerial.setConnectionInterval(10, 15); still, I can't set more than 20 bytes in one transaction...

dots123 commented 3 years ago

@webzoid I've set bleSerial.setConnectionInterval(10, 15); still, I can't set more than 20 bytes in one transaction...

You can't send more than 20 in one transaction.

pvonmoradi commented 3 years ago

@webzoid I've set bleSerial.setConnectionInterval(10, 15); still, I can't set more than 20 bytes in one transaction...

You can't send more than 20 in one transaction.

It seems it is possible by changing MTU limit: https://stackoverflow.com/questions/63590616/what-is-the-maximum-att-mtu-allowed-by-bluetooth-le Not sure though