BLE custom profiles with security

kristaps_r
Posts: 11
Joined: Sun Jul 15, 2018 2:48 pm

BLE custom profiles with security

Postby kristaps_r » Sun Jul 15, 2018 5:51 pm

Hi!

I am new to BLE and trying to make client - server ESP32 system that has custom BLE services and use security.
So I am looking in way of combining examples from IDF folder: gatt_security_server, gatt_security_client, gatt_server, gatt_client, because security_server/client applications are made with heart thermometer service.

I see that security examples use different way of attribute creating in gatts_profile_event_handler event ESP_GATTS_REG_EVT case than non security examples.
I see that non security examples have more complex ESP_GATTS_WRITE_EVT processing.

Can some one tell which example would be most complete and best to use as start point for own application?
And one thing. How can I understand which attribute is being written in ESP_GATTS_WRITE_EVT? I can get handle, but how to link that to my defined attributes?

Thanks,
Kristaps

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

Re: BLE custom profiles with security

Postby chegewara » Mon Jul 16, 2018 5:27 pm

Here you have some resources to study:
https://github.com/espressif/esp-idf/bl ... emo.c#L301
https://github.com/espressif/esp-idf/bl ... h#L58-L270

https://github.com/espressif/esp-idf/bl ... through.md

Basically, when attribute (service, characteristic or descriptor) is registered in ESP_GATTS_REG_EVT event then you get values that you need to store (uuid, handle etc.). Then during ESP_GATTS_WRITE_EVT you have to loop thru all characteristics and/or descriptors (service does not have value as far as i know) and change value if handle is the same as in ESP_GATTS_WRITE_EVT param.

Personally i would say if you are new to ble to use c++ library which is written by Neil Kolban, its much easier to start with (if you dont mind to use c++).

kristaps_r
Posts: 11
Joined: Sun Jul 15, 2018 2:48 pm

Re: BLE custom profiles with security

Postby kristaps_r » Mon Jul 16, 2018 9:35 pm

Thanks @chegewara!

I will look closer at links you gave but at first look I see that attribute handle is read in ESP_GATTS_ADD_CHAR_EVT event.
But if I use esp_ble_gatts_create_attr_tab() i get ESP_GATTS_CREAT_ATTR_TAB_EVT event and I am not sure how to extract handle for each attribute because i get param with this structure:
struct gatts_add_attr_tab_evt_param{
esp_gatt_status_t status; /*!< Operation status */
esp_bt_uuid_t svc_uuid; /*!< Service uuid type */
uint16_t num_handle; /*!< The number of the attribute handle to be added to the gatts database */
uint16_t *handles; /*!< The number to the handles */
} add_attr_tab; /*!< Gatt server callback param of ESP_GATTS_CREAT_ATTR_TAB_EVT */

Regarding C++ library I suppose that's for Arduino, but I use IDF.

Thanks,
Kristaps

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

Re: BLE custom profiles with security

Postby chegewara » Tue Jul 17, 2018 12:51 pm

With building app using attributes table i cant help you, sorry.

C++ code is prepared to be used as esp-idf component or arduino library.

Who is online

Users browsing this forum: No registered users and 63 guests