Comments (4)
Some logs would help but I suspect that the delay is a bit too short, do you know what the connection interval is?
from nimble-arduino.
The connection interval (desc->conn_itvl) is 24 units, which I believe is 30 msecs. Does that mean I should make my delay between notify's a bit over 30 msecs to avoid using up all the buffer? Is there a way to force a more frequent connection interval?
from nimble-arduino.
I added a print to the onStatus callback. It looks like the first 8 notify's are okay but it starts to fail after that:
onStatus TX status: 1 rc: 0
onStatus TX status: 1 rc: 0
onStatus TX status: 1 rc: 0
onStatus TX status: 1 rc: 0
onStatus TX status: 1 rc: 0
onStatus TX status: 1 rc: 0
onStatus TX status: 1 rc: 0
onStatus TX status: 1 rc: 0
onStatus TX status: 4 rc: 6
onStatus TX status: 4 rc: 6
onStatus TX status: 4 rc: 6
onStatus TX status: 4 rc: 6
...
I increased the delay to a full second (1000 msecs) and it still sends only the first eight.
from nimble-arduino.
I found my problem.
I was calling writeTest() in response to a request coming from the client. Thus, it was called from the onWrite() callback in my subclass of BLECharacteristicCallbacks. I'm guessing that the BLE stack holds a lock until the onWrite() callback returned. Thus, NimBLE was queuing notify messages to be sent when onWrite() returned, but when writeTest() did too many notify() calls it ran out of buffers.
The fix was to have onWrite() set a flag to request that writeTest() be called from the loop() function. With that change, writeTest() can send thousands of bytes. I'm seeing throughputs of about 5k bytes/second from a micro:bit V2 to my MacBook Pro, which is great!
I now have a new problem.
I'm using a delay in the writeTest() loop to avoid queuing data faster than NimBLE can send it. To maximize bandwidth, I want to minimize that delay. Through trial-and-error, I've found that 12 msecs works but 10 msecs results in errors (status: 4, return code: 6) and lost data. I'd rather not depend on a delay for this.
Is there a function I can call to be sure that a buffer is available for doing a setValue and notify on an attribute? Alternatively, is there some way to get an immediate return code indicating that the setValue or notify failed and should be tried again later? (I'm using onStatus now, but I'm not sure exactly when that gets called. Is it triggered by the setValue() or the notify() call? Is onStatus() called immediately when the error occurs?
Thanks!
from nimble-arduino.
Related Issues (20)
- 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 6
- 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
- Is it possible to advertise the device name as a client? HOT 2
- How to achieve long-distance connection communication? HOT 3
- Rapid and Repeated: E NimBLEClient: Connection failed; status=574 Connection Failed to be Established HOT 2
- How to obtain client from existing server connection?
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.