Comments (13)
Adding a 200 ms delay between createClient()
and connect()
solves the problem, 100 ms is too short. Still I think disconnect()
should wait for the event.
from nimble-arduino.
This reminds of my last weekend, where I finally was "sure" that my ESP32 was broken.
For me the solution was to erase the flash , which seemed to have solved it. In the end I erased it basically before every upload.
What IDE are you using? If you are using some kind of caching mechanism, you might need to delete the compiler cache too.
from nimble-arduino.
I had a "broken" ESP32 too a few days ago, put it apart, I have not thrown it away yet. I'll try to erase the flash to see if that brings it back to life.
But this is another issue. I can reset to run the sketch again. I can re-flash and start the program over again. But is won't get passed the second connect()
. As you can see in the logging, while connecting the first time it logs:
D NimBLEClient: "Got Client event "
D NimBLEClient: "Connection established"
and the second time it logs:
D NimBLEClient: "Got Client event "
D NimBLEClient: "Got Client event "
and then waits forever...
Most of the time, also this time, I use the Arduino IDE, 1.8.10 (that is the one but last I believe). Every now and then I use pio.
from nimble-arduino.
Turn on event code strings to see what
D NimBLEClient: "Got Client event "
D NimBLEClient: "Got Client event "
actually are.
Looks like you're hanging on a semaphore, or the stack is getting stuck because the peripheral has not disconnected yet. Try putting a delay of 100ms or so between deleting and creating the client.
from nimble-arduino.
Logging now:
Started
I NimBLEDevice: "BLE Host Task Started"
I NimBLEDevice: "NimBle host synced."
Create
Connecting...
D NimBLEClient: ">> connect(a4:c1:38:5d:ef:16)"
D FreeRTOS: "Semaphore taking: name: OpenEvt (0x3ffc88fc), owner: <N/A> for connect"
D FreeRTOS: "Semaphore taken: name: OpenEvt (0x3ffc88fc), owner: connect"
D FreeRTOS: ">> wait: Semaphore waiting: name: OpenEvt (0x3ffc88fc), owner: connect for connect"
D NimBLEClient: "Got Client event BLE_GAP_EVENT_CONNECT "
D NimBLEClient: "Connection established"
D FreeRTOS: "Semaphore giving: name: OpenEvt (0x3ffc88fc), owner: connect"
D FreeRTOS: "<< wait: Semaphore released: name: OpenEvt (0x3ffc88fc), owner: <N/A>"
D NimBLEClient: "Refreshing Services for: (a4:c1:38:5d:ef:16)"
D NimBLEClient: ">> deleteServices"
D NimBLEClient: "<< deleteServices"
D NimBLEClientCallbacks: "onConnect: default"
D NimBLEClient: "<< connect()"
Connected
D NimBLEClient: ">> disconnect()"
D NimBLEClient: "<< disconnect()"
Disconnected
D NimBLEClient: ">> deleteServices"
D NimBLEClient: "<< deleteServices"
Create
Connecting...
D NimBLEClient: ">> connect(a4:c1:38:5d:ef:16)"
D FreeRTOS: "Semaphore taking: name: OpenEvt (0x3ffc88fc), owner: <N/A> for connect"
D FreeRTOS: "Semaphore taken: name: OpenEvt (0x3ffc88fc), owner: connect"
D FreeRTOS: ">> wait: Semaphore waiting: name: OpenEvt (0x3ffc88fc), owner: connect for connect"
D NimBLEClient: "Got Client event BLE_GAP_EVENT_MTU"
D NimBLEClient: "Got Client event BLE_GAP_EVENT_DISCONNECT"
I think the issue is indeed that BLE_GAP_EVENT_DISCONNECT
arrives AFTER calling connect()
again.
I think disconnect()
should wait for this event...!
from nimble-arduino.
Adding a 200 ms delay between
createClient()
andconnect()
solves the problem, 100 ms is too short. Still I thinkdisconnect()
should wait for the event.
Interesting observation, I will test this too.
from nimble-arduino.
What is the purpose of doing this? It seems odd to me to create a client object delete it and create another in such a short time, why not just reuse the client object?
Still I think disconnect() should wait for the event.
That would unnecessarily slow down other applications, if you really need to know the client is disconnected there is a callback for that.
from nimble-arduino.
In the integration I am creating several devices are read out independently. Most don't need a connection, some do. I just want to use the functionality that is there. Also, I think it should always work
Could you give me some directions how to check if the client has disconnected? The function isDisconnected() does not do this job
from nimble-arduino.
For me the solution was to erase the flash , which seemed to have solved it. In the end I erased it basically before every upload.
This is must when you are building bluetooth app.
from nimble-arduino.
D FreeRTOS: ">> wait: Semaphore waiting: name: OpenEvt (0x3ffc88fc), owner: connect for connect"
D NimBLEClient: "Got Client event BLE_GAP_EVENT_MTU"
D NimBLEClient: "Got Client event BLE_GAP_EVENT_DISCONNECT"
This may have happen when there is no successful connection, maybe except MTU exchange, because this requires full connection established, unless MTU is called too early (in wrong place).
from nimble-arduino.
from nimble-arduino.
This issue was just resolved in commit 4c798fe.
from nimble-arduino.
This issue was just resolved in commit 4c798fe.
I can confirm that. Thank you @h2zero!
from nimble-arduino.
Related Issues (20)
- NimBLEClient issue on TRANSPARENT UART: receiving only one callback from ble server after writing HOT 2
- NimBLEServerCallbacks won't call onConnect(BLEServer*, NimBLEConnInfo&) HOT 2
- Is it possible to scan and detect smartphones? HOT 1
- suppressing some serial output from the scan whitelist example HOT 3
- Support for new ESP32 Arduino core (3.x) and IDF (5.1) HOT 7
- [Feature request] Support for ESP32-C6 HOT 17
- ESP_ERROR_CHECK failed on platformio, [email protected]
- Is it possible to advertise multiple 128bit services with data? HOT 1
- no advertising with ESP32-C6 HOT 4
- Set Manufacturer Data - Bug HOT 1
- Platformio, arduino and esp32 - pinning nimble to core and debug HOT 3
- onAuthenticationComplete() never called HOT 2
- ESP32-S3 crashing with the examples HOT 2
- Device name not showed at first connection HOT 2
- Allow only certain bonded client to connect to NimBLEServer. Whitelist in advertising does not work for already bonded peers
- Changing CPU frequency causes crash HOT 4
- Notification 8 byte data size
- how to get faster reconnects from deep sleep HOT 3
- ble does not work when cpu set to 40mhz or bellow HOT 2
- notify not updating values in nRF Connect HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nimble-arduino.