Page 1 of 2

Simultaneous WiFI and BLE

Posted: Mon Jan 02, 2017 2:15 pm
by plerup
Hi,

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

Thanks
/Peter

Re: Simultaneous WiFI and BLE

Posted: Tue Jan 03, 2017 12:31 am
by ESP_Angus
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.

Re: Simultaneous WiFI and BLE

Posted: Tue Jan 03, 2017 7:44 am
by plerup
Ok, thanks.

I will try a combination of example 3 and 15 then

Re: Simultaneous WiFI and BLE

Posted: Tue Jan 03, 2017 9:20 am
by xzwang
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.

Re: Simultaneous WiFI and BLE

Posted: Tue Jan 03, 2017 11:57 am
by plerup
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

Re: Simultaneous WiFI and BLE

Posted: Wed Jan 04, 2017 12:41 am
by xzwang
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;
}

Re: Simultaneous WiFI and BLE

Posted: Wed Jan 04, 2017 1:29 am
by kolban
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.

Re: Simultaneous WiFI and BLE

Posted: Wed Mar 08, 2017 1:33 am
by xerocool
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.

Re: Simultaneous WiFI and BLE

Posted: Wed Mar 08, 2017 9:41 am
by torntrousers
This does that.

Re: Simultaneous WiFI and BLE

Posted: Thu Sep 28, 2017 4:11 am
by kolban
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.