how do I go with logical flow for BLE GATT client?
Posted: Mon Jul 31, 2017 6:47 pm
I have from gattc_demo made basic code that connects to my pheripheral device(NRF51822 GATT Server). I can now connect find service and characteristics of my interest and then enable notification I am also able to send data to NRF51 and it respond back with the data I asked it for.
But there is much more I am doing on the pheripheral like I have made a command control where I ask for time to it and NRF51 sends time. ask for Battery level it sends me battery level ask for stored data it sends stored Data. But how do I implement that kind of logic? I mean there are all basic events that are called in ESP32.
such as for one single command I have done this.
after Notification is enabled this event is called and I send 'B' for battery level it send me that data and notify me. but I want to implement logic where on certain situation I will ask for other thing and it should respond. there is no loop() function in ESP32 IDF that keeps looking on flags and if flag is set I can perform or send command. or is there ? or a perodically called function.
Any Idea?
like in NRF51 I am programming with mbed BLE api and mbed API where I can set a periodic function to call with Tickerhttps://www.google.co.in/url?sa=t&rct=j ... AfhcYrg3Ug .I thought of using freeRTOS API to create task on connection and handle things and then delete it once the connection is done. But I am not sure should I do that.
Help would be appriciated.
But there is much more I am doing on the pheripheral like I have made a command control where I ask for time to it and NRF51 sends time. ask for Battery level it sends me battery level ask for stored data it sends stored Data. But how do I implement that kind of logic? I mean there are all basic events that are called in ESP32.
such as for one single command I have done this.
Code: Select all
case ESP_GATTC_WRITE_DESCR_EVT:
ESP_LOGI(GATTC_TAG, "WRITE: status %d", p_data->write.status);
char cmd='B';
esp_ble_gattc_write_char(gattc_if,
conn_id,
&Myservice_id,
&Tx_char_ID,//esp_gatt_id_t *char_id, //get_char->char_id
1,//uint16_t value_len,
(uint8_t *)&cmd,//uint8_t *value,
ESP_GATT_WRITE_TYPE_NO_RSP,//esp_gatt_write_type_t write_type,
ESP_GATT_AUTH_REQ_NONE);//esp_gatt_auth_req_t auth_req)
Any Idea?
like in NRF51 I am programming with mbed BLE api and mbed API where I can set a periodic function to call with Tickerhttps://www.google.co.in/url?sa=t&rct=j ... AfhcYrg3Ug .I thought of using freeRTOS API to create task on connection and handle things and then delete it once the connection is done. But I am not sure should I do that.
Help would be appriciated.