Simultaneous WiFI and BLE

plerup
Posts: 3
Joined: Mon Jan 02, 2017 2:09 pm

Simultaneous WiFI and BLE

Postby plerup » Mon Jan 02, 2017 2:15 pm

Hi,

What is the status of simultaneous BLE/WiFi, i.e. the possibility to use the ESP32 as a BLE-Internet gateway?

Thanks
/Peter

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Simultaneous WiFI and BLE

Postby ESP_Angus » Tue Jan 03, 2017 12:31 am

Recent esp-idf mainline versions can enable the WiFi and Bluetooth stacks simultaneously.

The "12_blufi" example provides an example which runs the BLE stack (for configuration) simultaneously with WiFi.

It should be technically possible to use the ESP32 as a BLE-Internet gateway, however we don't have example code using this (or BLE IPv6 support) at this time.

plerup
Posts: 3
Joined: Mon Jan 02, 2017 2:09 pm

Re: Simultaneous WiFI and BLE

Postby plerup » Tue Jan 03, 2017 7:44 am

Ok, thanks.

I will try a combination of example 3 and 15 then

xzwang
Posts: 22
Joined: Wed Dec 14, 2016 4:54 am

Re: Simultaneous WiFI and BLE

Postby xzwang » Tue Jan 03, 2017 9:20 am

I am also doing this, using esp32 as BLE-Internet gateway. I have established BLE and WIFI connection at the same time. I have some problems here:
1, How to get all services, characteristics, descriptions?
2, How to connect more than one ble devices?

Could you share your experience here? Or if I can do some help for you, I would happy to share my experience.

plerup
Posts: 3
Joined: Mon Jan 02, 2017 2:09 pm

Re: Simultaneous WiFI and BLE

Postby plerup » Tue Jan 03, 2017 11:57 am

I'm mainly interested in relaying advertisement data from BLE to WiFi so I have not yet looked into connection details.

I did see however that example 15 has a search for services, started via esp_ble_gattc_search_service

If you do however have some code you could share I would be very grateful.

Thanks
/Peter

xzwang
Posts: 22
Joined: Wed Dec 14, 2016 4:54 am

Re: Simultaneous WiFI and BLE

Postby xzwang » Wed Jan 04, 2017 12:41 am

I have read the example 15, and also found some GATTC APIs. The followed codes is the key code to get services, characteristics,descriptions... But it may exist some issues, sometimes the ESP32 will restart with an exception.
I confused how to use the start_xxx_id in these two apis.
esp_err_t esp_ble_gattc_get_characteristic(uint16_t conn_id,esp_gatt_srvc_id_t *srvc_id, esp_gatt_id_t *start_char_id);
esp_err_t esp_ble_gattc_get_descriptor(uint16_t conn_id,esp_gatt_srvc_id_t *srvc_id, esp_gatt_id_t *char_id,esp_gatt_id_t *start_descr_id);

Code: Select all

static void esp_gattc_cb(uint32_t event, void *param)
{
        ...
   case ESP_GATTC_SEARCH_CMPL_EVT:
       ...
       //call esp_ble_gattc_get_characteristic for each service
       while( service_node )
       {
           esp_ble_gattc_get_characteristic( conn_id, service_node->srvc_id, NULL );
           service_node = service_node->next;
       }
       break;
       
   case ESP_GATTC_GET_CHAR_EVT:
       ...
       esp_ble_gattc_get_descriptor( conn_id, srvc_id, char_id, NULL );
       esp_ble_gattc_get_characteristic( conn_id, srvc_id, char_id );
       break;
       
   case ESP_GATTC_GET_DESCR_EVT:
       ...
       esp_ble_gattc_get_descriptor( conn_id, srvc_id, char_id, descr_id );
       break;
}

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Simultaneous WiFI and BLE

Postby kolban » Wed Jan 04, 2017 1:29 am

My understanding is that this function is an "iterator" over characteristics of a service.

Initially, we will call esp_ble_gattc_get_characteristic() with a start_characteristic_id value of NULL. This will cause an event to be posted (ESP_GATTC_GET_CHAR_EVT) with the first characteristic of the service. When we call esp_ble_gattc_get_characteristic() for a second time, we will pass in the characteristic last posted as an event. This can continue while the status code in the received event doesn't indicate an error.

This model of programming does feel "odd" but one has to realize that there is an asynchronous protocol going on here. Programming this in an async/functional language would make a bit more sense rather than C ... however even in C, it does seem to work.

If this explanation isn't clear, please post back and we can try and elaborate on what is going on. I'm trying to write up notes on BLE but its going to take some time to get right. You might be able to do me a favor by looking at my efforts in my PDF of notes and see if that makes more sense.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

xerocool
Posts: 1
Joined: Wed Mar 08, 2017 1:31 am

Re: Simultaneous WiFI and BLE

Postby xerocool » Wed Mar 08, 2017 1:33 am

Has anyone successfully able to do a GAP Scan and maintain WiFi connection with ESP32? if so, are there any examples that shows how that works.

torntrousers
Posts: 21
Joined: Mon Dec 21, 2015 9:30 am

Re: Simultaneous WiFI and BLE

Postby torntrousers » Wed Mar 08, 2017 9:41 am

This does that.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Simultaneous WiFI and BLE

Postby kolban » Thu Sep 28, 2017 4:11 am

I have a WiFi App that works great (it is an HTTP Server). I enabled BLE in the make menuconfig, recompiled and flashed and now I find that the WiFi functions no longer work. Having searched the forum, there appears to be a number of Q&As on co-existence of BLE and WiFi. I'm wondering what the current story may be?

Is it supported in any fashion? I am testing against Github ESP-IDF master as of the date of this post.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Who is online

Users browsing this forum: No registered users and 87 guests