-
Notifications
You must be signed in to change notification settings - Fork 715
Timeout on BLE (Random disconnect) #731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This now works without disconnect when using @chegewara repository. https://github.com/chegewara/esp32-snippets-enchancements-test |
Thank you everyone for this library, and Thanks @chegewara for your work on improving the code |
Hmmm, if I change delay from 250 to 100 I am back where I started. I know you mentioned you had 70Hz, but this seems like it is only 4Hz. Is it because I am sending an int? |
Hi @msj121 |
Thanks! |
@msj121 Here is log from nRF connect. First time ive got situation when my samsung S9+ got problem with copy/paste nRF connect logs after few seconds connection (so many logs):
I am using standard BLE_notify example from library (arduino log level warn). |
Here is "pimp my code" version with logs:
|
Here is version with
|
@chegewara Thanks, I will try to root down the problem on my code then. I fear it might be iOS because as I search through similar errors with other boards people sometimes mention that they don't have issues with android. SO I'll try to find an Android phone and see if it works there. Thank you! Your library definitely helped improve the connection and I am sure a lot of other bugs. At the very least I seem to have a stable 4Hz on iOS with your code and I didn't have even 1Hz stability before. For now I will close, I will try to find and Android. |
I performed long run test. After over 6 hours test with To work with iOS you have 3 new functions.
|
@chegewara I still have not been able to find out why I get random disconnects on my iphone.... I have updated to the new library, and added updateConnParams:
Do you or anyone know of any fixes for this? It looks like you solved it for Android, I will include a log for most current example of disconnect: I wrote some code to write out the malloc when "disconnect" is called from the callbacks. I am hoping this might help. Any ideas how to try and narrow down the problem would also be great, happy to try things in the .cpp files.
|
Hi, Problem with iPhone connection is that i dont know and understand some very specific and restrictive connection requirements. Because of that some library functions can cause issues. From time to time when such issues are reported and i find time i am trying to read apple specs again and again. I will try to run some tests with iPhone when i have time. |
@chegewara Thanks for all the help! Really appreciate it. From my end, what I see everytime before disconnection event is that it looks like there is some sort of stuttering in the bluetooth data. So that it will delay like 200ms a few times and clump data together. Then will disconnect with an error peripheral disconnected from the apple side. I have tried writing my own apple software in SWIFT thinking that it might be an apple issue and the cordova library, but bug persisted. |
I did expand looking at other ble modules to see if they have the same problem and some do have public issues, but someone posted a solution for an NRF module I'd like to try. https://devzone.nordicsemi.com/f/nordic-q-a/11837/automatically-disconnection-ios @chegewara Do you know where these values can be set in esp32 arduino? I have gone through the current arduino code and have had trouble finding this in bleserver or other files I have been perusing. |
Solution from this link are those 2 functions:
https://github.com/nkolban/ESP32_BLE_Arduino/blob/master/examples/BLE_server/BLE_server.ino#L36-L37 btw i should fix that timeout probably |
I have tried all three options:
I also put the following at the end of the setup and got rid of pServer->getAdvertising() code:
@chegewara Still same issues, but takes longer to connect, which makes sense. Did I use large enough values? Thanks for all the help, let me know if you have any other ideas to try. Really appreciate all the help. |
You should read this, especially 11.6: |
@chegewara Changed the settings to match as far as I can tell with no more success. I did notice that everytime I use the "reset" button or software "reset", the next connection tends to last longer like 5 minutes without interruption. But once there is an interruption it doesn't tend to last more than a minute, sometimes only 10 seconds. So I reset each time right now on disconnection no matter what the reason for disconnect. This is a "bad" workaround, but it might be useful to know that something in the code on the esp32 is fixed somewhat on reset. Not sure what changes though. Let me know if I can be of any help tracking this down. |
@msj121 I have the same problem trying to upload the firmware using ios, Did when i send the first package the cellphone and esp32 disconnects, could you find a solution? |
Similar issues here, almost giving up on esp32. Connects on android but disconnect without any reason or message (even verbose activated). Its quite sad that BLE has so little support and people sharing its code. |
Uh oh!
There was an error while loading. Please reload this page.
I got most of the code from nkolban with minimal changes for reading an analog value and relaying to a cordova app.
I can connect and get values; however, what seems like after 5 seconds to 2 minutes, I get an error on the cordova app that "The connection has timed out". I similarly get the nRF Connect app to connect and read values but all of a sudden it disconnects in a similar way so I don't think it's the phone software.
I have tried updating the arduino library as stated by replacing this repository (nkolban cpp_utils), restarting arduino, but it didn't work.
Any ideas? Did I do something stupid or should I test anything? I would like to avoid constantly reconnecting if possible.
Here is the verbose log from arduino
The text was updated successfully, but these errors were encountered: