robertc2000 opened a new pull request, #14549:
URL: https://github.com/apache/nuttx/pull/14549

   ## Summary
   
   This PR aims to improve and fix the core functionalities of the Bluetooth 
stack.
   
   Initially, I tried to connect to the NuttX device (a ESP32 device using the 
esp32-devkitC:ble menu configuration) via Bluetooth and attempted to read the 
services/characteristics that it was contains. I noticed that the connection 
did not work, because the NuttX device (the host layer) was not receiving  any 
ACL packets (containing my requests for these services) from the controller 
layer. Therefore, the device running NuttX was not replying to my requests and 
connection failed.
   
   I found a fix for this issue: the 'Controller to Host Flow Control' 
parameter has to be set to 0. This fixed the issue of packets not arriving in 
the host layer. With this setup, I got a successful connection. I decided to 
create an option in the Bluetooth menu, in which the user can select the value 
for this 'Controller to Host Flow Control' parameter. The reason for this is 
because I only tested on ESP32 and I got successful connection with the value 
set to 0. I didn't test on other devices, therefore I cannot confirm this value 
will work for any non-ESP32, so it's best to keep this parameter 
user-configurable.
   
   Another improvement I made was regarding the pairing process. I implemented 
the handling of the LL_CONNECTION_PARAM_REQ event and I noticed a considerable 
response speed improvement from the NuttX stack. Previously, the stack was 
using the 'bt_l2cap_update_conn_param' for connection parameter update, however 
I noticed the stack was a bit laggy in responding, so I commented this out for 
the moment.
   
   ## Testing
   
   I used a ESP32-DEVKITC board along with the esp32-devkitc:ble configuration. 
To connect to the device, I used my smartphone along with an application for 
connecting using Bluetooth ('nRF connect').
   
   I also discovered some bugs in the process:
   1. Advertising does not work, unless scanning is enabled. I used the 'btsak' 
app from the NuttX terminal (nsh) in order to enable advertising and scanning, 
and I noticed that enabling advertising does nothing. Only after enabling 
scanning, the device starts to also advertise.
   
   2. Transmission of packets does not work (from the host layer: L2CAP, GATT, 
etc..), unless logging is done simultaneously. I suspect there might be some 
synchronization/race condition error in the scheduler, because a separate 
thread is used for Bluetooth TX (it might not be necessarily related to the BLE 
stack). 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to