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)
- How to get current PHY mode HOT 4
- Name clash of `const char *TAG` with Arduino core macro `TAG`. HOT 5
- ESP32-S3 Extended Advertising: Capturing Packets HOT 4
- Error compile Arduino BLE 5 example for ESP32 HOT 5
- API change - feature test macro missing HOT 2
- Error in converting EddystoneTLM negative temperatures to float HOT 4
- ESP32-S3 crash with arduino-esp32 core 3.x.x HOT 28
- The future of this repo... new ESP MCU's cannot be supported. HOT 4
- NimBLE-Arduino crashes with esp32 version 3.0.1. and a LilyGo T-display S3 HOT 4
- NimBLE-Arduino debug exception when trying to initialize BLE functions HOT 3
- Crash with 'Arduino Nano ESP32' on core ESP32 3.0.1 with NimbleV1.4.2 HOT 2
- BLE SERVICE and WiFi.scanNetworks not wokring simulteneously HOT 3
- GAP server event to get client rssi HOT 2
- increasing heap consumption over time HOT 12
- NimBLE-Arduino 1.4.2: problem with device name? HOT 1
- How to pass correct hid device name HOT 8
- esp_bt.h: No such file or directory HOT 3
- Cannot set TX power to +8dbm for nRF52840 HOT 3
- NRA connection on NON-esp device (NRF81522)
- NimBLEAddress initialization failure with 17bytes address string HOT 2
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.