Simultaneous esp_ble_gattc_read_char() calls?

josephhui
Posts: 6
Joined: Thu Apr 02, 2020 10:00 am

Simultaneous esp_ble_gattc_read_char() calls?

Postby josephhui » Sun Jul 26, 2020 6:12 pm

If I make a esp_ble_gattc_read_char() call for "characteristic2" immediately after a esp_ble_gattc_read_char() call for "characteristic1", is that going to work?

Since esp_ble_gattc_read_char() is asynchronous, do I need to somehow wait for the characteristic value to be returned before making another esp_ble_gattc_read_char() call? What is the best way to do this?

Also, is esp_ble_gattc_read_char() thread safe? In my firmware, another task could potentially make another esp_ble_gattc_read_char() call before esp_ble_gattc_read_char() is even returned.

Thanks in advance,
Joseph

ChrisBird
Posts: 1
Joined: Tue Jul 28, 2020 6:02 am

Re: Simultaneous esp_ble_gattc_read_char() calls?

Postby ChrisBird » Fri Jul 31, 2020 3:40 am

I too am facing this issue. It appears that we may need to implement some form of locking (like a basic semaphore lock like they did in https://github.com/nkolban/esp32-snippets). So that one request goes and we get one response before requesting the second one.

There is also the handle ID which I guess we could use. Curious to see what others have done.

josephhui
Posts: 6
Joined: Thu Apr 02, 2020 10:00 am

Re: Simultaneous esp_ble_gattc_read_char() calls?

Postby josephhui » Sat Aug 08, 2020 9:19 am

Chris,

Thanks for the reply. We are considering using IDF's queue API to implement a dispatch queue for serializing the BLE requests.

Joseph

Who is online

Users browsing this forum: No registered users and 25 guests