How to make 128bit service using ble gatts table demo?
Posted: Fri Nov 23, 2018 7:17 pm
Hi.
I'm using this demo:
https://github.com/espressif/esp-idf/bl ... eat_demo.c
I want to make custom 128bit service with some 128bit characteristics aswell.
My peripheral must advertize UUID of my128bit_service too.
My service and characteristics:
Due increased value data, I limited avertizing data:
Here is what I got in nRF Connect:
And here is database:
I dont know why nothing appears when I connected to device. Log looks clean (no errors):
I got only working only when service comes with 16bit.
I set 0xDDDD, rest of UID values (0000-1000-8000-00805F9B34FB) are reserved by SIG as I understand.
So is it possible to completely change service with custom 128 bit values?
I'm using this demo:
https://github.com/espressif/esp-idf/bl ... eat_demo.c
I want to make custom 128bit service with some 128bit characteristics aswell.
My peripheral must advertize UUID of my128bit_service too.
- [my128bit_service]
- [128bit characteristic_1]
[char_1_value]
[char_1_configuration] - [128bit characteristic_2]
[char_2_value]
[char_2_configuration]
My service and characteristics:
- static uint8_t service_uuid[16] = {
- /* LSB <--------------------------------------------------------------------------------> MSB */
- 0x3d, 0x23, 0x33, 0xa0, 0xde, 0xf9, 0x42, 0x88, 0x30, 0x32, 0x12, 0xd7, 0x11, 0x37, 0x34, 0xda
- };
- static uint8_t char1_uuid[16] = {
- /* LSB <--------------------------------------------------------------------------------> MSB */
- 0xde, 0xba, 0x0a, 0xc3, 0xa5, 0x34, 0xb5, 0xbc, 0x00, 0x22, 0xe0, 0x11, 0xe2, 0x0c, 0x42, 0x2a
- };
- static uint8_t char2_uuid[16] = {
- /* LSB <--------------------------------------------------------------------------------> MSB */
- 0xbe, 0x12, 0x14, 0x43, 0x22, 0x39, 0x3e, 0xb1, 0xe5, 0xd3, 0xa5, 0xd5, 0xf6, 0x08, 0x3e, 0xd4
- };
- static esp_ble_adv_data_t adv_data = {
- .set_scan_rsp = false,
- .include_name = false,
- .include_txpower = false,
- .min_interval = 0x20,
- .max_interval = 0x40,
- .appearance = 0x00,
- .manufacturer_len = 0,
- .p_manufacturer_data = NULL,
- .service_data_len = 0,
- .p_service_data = NULL,
- .service_uuid_len = 32, // WITH value 16 it doesnt work for some reason?
- .p_service_uuid = my_service_uuid,
- .flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
- };
- // scan response data
- static esp_ble_adv_data_t scan_rsp_data = {
- .set_scan_rsp = true,
- .include_name = true,
- .include_txpower = false,
- .min_interval = 0x20,
- .max_interval = 0x40,
- .appearance = 0x00,
- .manufacturer_len = 0,
- .p_manufacturer_data = NULL,
- .service_data_len = 0,
- .p_service_data = NULL,
- .service_uuid_len = 0,
- .p_service_uuid = NULL,
- .flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
- };
And here is database:
- #define GATTS_DEMO_CHAR_VAL_LEN_MAX 500
- const uint8_t charact_1_descr[2] = {0x00, 0x00};
- const uint8_t charact_2_descr[2] = {0x00, 0x00};
- static const esp_gatts_attr_db_t gatt_db[HRS_IDX_NB] =
- {
- // [HRS_IDX_SVC]: Named or designated initializer in the enum table.
- // ESP_GATT_AUTO_RSP: Auto respond configuration, set to respond automatically by the stack.
- // ESP_UUID_LEN_16: UUID length set to 16 bits.
- // (uint8_t *)&primary_service_uuid: UUID to identify the service as a primary one (0x2800).
- // ESP_GATT_PERM_READ: Read Permission for the service.
- // sizeof(uint16_t): Maximum length of the service UUID (16 bits).
- // sizeof(heart_rate_svc): Current service length set to the size of the variable heart_rate_svc, which is 16 bits.
- // (uint8_t *)&heart_rate_svc: Service attribute value set to the variable heart_rate_svc which contains the Heart Rate Service UUID (0x180D).
- // Service Declaration
- //tried this and no success:
- [IDX_SVC] =
- {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&primary_service_uuid, ESP_GATT_PERM_READ,
- //16, sizeof(service_uuid), (uint8_t *)&service_uuid}}, //- none
- //32, 32, (uint8_t *)&service_uuid}}, //- none
- // what to insert here?
- /* Characteristic Declaration */
- [IDX_CHAR_A] =
- {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_declaration_uuid, ESP_GATT_PERM_READ,
- CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_read_write_notify}},
- /* Characteristic Value */
- [IDX_CHAR_VAL_A] =
- {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&char1_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
- GATTS_DEMO_CHAR_VAL_LEN_MAX , sizeof(char_value), (uint8_t *)char_value}},
- /* Client Characteristic Configuration Descriptor */
- [IDX_CHAR_CFG_A] =
- {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
- sizeof(uint16_t), sizeof(charact_1_descr), (uint8_t *)charact_1_descr}},
- /* Characteristic Declaration */
- [IDX_CHAR_B] =
- {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_declaration_uuid, ESP_GATT_PERM_READ,
- CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_read_write_notify}},
- /* Characteristic Value */
- [IDX_CHAR_VAL_B] =
- {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&char_2_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
- GATTS_DEMO_CHAR_VAL_LEN_MAX , sizeof(char_value), (uint8_t *)char_value}},
- /* Client Characteristic Configuration Descriptor */
- [IDX_CHAR_CFG_B] =
- {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
- sizeof(uint16_t), sizeof(charact_2_descr), (uint8_t *)charact_2_descr}},
- };
I dont know why nothing appears when I connected to device. Log looks clean (no errors):
- 2018-11-23_19:29:22][0;32mI (0) cpu_start: Starting scheduler on APP CPU.[0m
- [2018-11-23_19:29:22][0;32mI (84) BTDM_INIT: BT controller compile version [8353b1b]
- [2018-11-23_19:29:22][0m
- [2018-11-23_19:29:22][0;32mI (85) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE[0m
- [2018-11-23_19:29:22][0;32mI (150) phy: phy_version: 3960, 5211945, Jul 18 2018, 10:40:07, 0, 0[0m
- [2018-11-23_19:29:22][0;32mI (335) BLE: create attribute table successfully, the number handle = 10
- [2018-11-23_19:29:22][0m
- [2018-11-23_19:29:22][0;32mI (339) BLE: SERVICE_START_EVT, status 0, service_handle 40[0m
- [2018-11-23_19:29:22][0;32mI (339) BLE: advertising start successfully[0m
I got only working only when service comes with 16bit.
I set 0xDDDD, rest of UID values (0000-1000-8000-00805F9B34FB) are reserved by SIG as I understand.
- static const uint16_t GATTS_SERVICE_UUID_TEST = 0xDDDD;
- [IDX_SVC] =
- {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&primary_service_uuid, ESP_GATT_PERM_READ,
- 2, sizeof(GATTS_SERVICE_UUID_TEST), (uint8_t *)&GATTS_SERVICE_UUID_TEST}},
- /* Characteristic Declaration */
- [IDX_CHAR_A] =
- {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_declaration_uuid, ESP_GATT_PERM_READ,
- CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_read_write_notify}},
- /* Characteristic Value */
- [IDX_CHAR_VAL_A] =
- {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&char1_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
- GATTS_DEMO_CHAR_VAL_LEN_MAX, sizeof(char_value), (uint8_t *)char_value}},
- /* Client Characteristic Configuration Descriptor */
- [IDX_CHAR_CFG_A] =
- {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
- sizeof(uint16_t), sizeof(charact_1_descr), (uint8_t *)charact_1_descr}},
- /* Characteristic Declaration */
- [IDX_CHAR_B] =
- {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_declaration_uuid, ESP_GATT_PERM_READ,
- CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_read_write_notify}},
- /* Characteristic Value */
- [IDX_CHAR_VAL_B] =
- {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&char2_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
- GATTS_DEMO_CHAR_VAL_LEN_MAX, sizeof(char_value), (uint8_t *)char_value}},
- /* Client Characteristic Configuration Descriptor */
- [IDX_CHAR_CFG_B] =
- {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
- sizeof(uint16_t), sizeof(charact_2_descr), (uint8_t *)charact_2_descr}},
So is it possible to completely change service with custom 128 bit values?