esp32 gatt server sensor data reading

iamcalledusman
Posts: 28
Joined: Tue Mar 23, 2021 10:44 am

esp32 gatt server sensor data reading

Postby iamcalledusman » Wed Jun 23, 2021 1:42 pm

Hi All !
I am using esp32-c3 / Esp32 esp-idf . The example i am using is gatt_server. I am sending the eddystone beacon messages (fixed packet) to andriod app using gatt server app .

My question is that , how can we send a sensor data ( which is changing ) using gatt server app . Means , i want to send every time a new value (eddystone beacon message ) to andriod app .Thanks in advance .

Thanks
Best Regard,

chegewara
Posts: 2230
Joined: Wed Jun 14, 2017 9:00 pm

Re: esp32 gatt server sensor data reading

Postby chegewara » Wed Jun 23, 2021 2:09 pm

You have to update eddystone packet with new values each time, then set new advertising data and re-start advertising.

iamcalledusman
Posts: 28
Joined: Tue Mar 23, 2021 10:44 am

Re: esp32 gatt server sensor data reading

Postby iamcalledusman » Wed Jun 23, 2021 3:42 pm

Hi !
Thank You for the quick response . I am new to esp-idf . I have found the stop function . And i implemented like that .

////////////////////////////////////////////////////////////////////////////////////////////
static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
{
switch (event) {
#ifdef CONFIG_SET_RAW_ADV_DATA
case ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT:
adv_config_done &= (~adv_config_flag);

if (adv_config_done==0){

esp_ble_gap_start_advertising(&adv_params);

raw_adv_data[25]=0x55;

int32_t esp_err_t = esp_ble_gap_stop_advertising();

}

/* else if (adv_config_done==1){

esp_ble_gap_start_advertising(&adv_params);
raw_adv_data[25]=0xAA;
int32_t esp_err_t = esp_ble_gap_stop_advertising();


}*/
break;

/////////////////////////////////////////////////////////////////////////////////

Can you help me in this regard ? that what is the program flow sequence? so that on every new iteration, i can change the values .

Again thanks !

iamcalledusman
Posts: 28
Joined: Tue Mar 23, 2021 10:44 am

Re: esp32 gatt server sensor data reading

Postby iamcalledusman » Wed Jun 23, 2021 6:48 pm

Hi
Thank you ! it is done by using the timer . Using XtaskCreate();

Again Thank You !

Who is online

Users browsing this forum: Bing [Bot] and 90 guests