Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLE 128Bit UUID's is not running (IDFGH-13039) #13985

Closed
3 tasks done
meakashrao opened this issue Jun 15, 2024 · 8 comments
Closed
3 tasks done

BLE 128Bit UUID's is not running (IDFGH-13039) #13985

meakashrao opened this issue Jun 15, 2024 · 8 comments
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@meakashrao
Copy link

meakashrao commented Jun 15, 2024

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

ESP-IDF v5.1.2-666-ga5e3e0b90e

Espressif SoC revision.

ESP32-WROOM-32E-N8 (revision v3.0 and V3.1)

Operating System used.

Windows

How did you build your project?

VS Code IDE

If you are using Windows, please specify command line type.

None

Development Kit.

ESP-WROOM-32

Power Supply used.

USB

What is the expected behavior?

All BLE Services and Characteristics to have 128 bit UUID's

What is the actual behavior?

Advertisement starts correctly and the services and characteristics are discoverable but only the service has the custom 128 bit UUID and all other 9 characteristics have 16 bit UUID

Steps to reproduce.

uint8_t delishup_service_uuid[16] = {0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x01, 0x00, 0x40, 0x6E};

static esp_ble_adv_data_t adv_data = {
.set_scan_rsp = false,
.include_name = true,
.include_txpower = true,
.min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec
.max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec
.appearance = 0x00,
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
.p_manufacturer_data = NULL, //test_manufacturer,
.service_data_len = 0,
.p_service_data = NULL,
.service_uuid_len = sizeof(delishup_service_uuid),
.p_service_uuid = delishup_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 = true,
.min_interval = 0x0006,
.max_interval = 0x0010,
.appearance = 0x00,
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
.p_manufacturer_data = NULL, //&test_manufacturer[0],
.service_data_len = 0,
.p_service_data = NULL,
.service_uuid_len = sizeof(delishup_service_uuid),
.p_service_uuid = delishup_service_uuid,
.flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
};

static const uint8_t DELISHUP_SERVICE_UUID[16] = {0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x01, 0x00, 0x40, 0x6E};
static const uint8_t HEARTBEAT_UUID[16] = {0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x03, 0x00, 0x40, 0x6E};
static const uint8_t WEIGHT_UUID[16] = {0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x04, 0x00, 0x40, 0x6E};
static const uint8_t TEMPERATURE_UUID[16] = {0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x05, 0x00, 0x40, 0x6E};
static const uint8_t JAR_LID_UUID[16] = {0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x06, 0x00, 0x40, 0x6E};
static const uint8_t MOTOR_UUID[16] = {0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x07, 0x00, 0x40, 0x6E};
static const uint8_t FIRMWARE_UUID[16] = {0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x08, 0x00, 0x40, 0x6E};
static const uint8_t DIAL_UUID[16] = {0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x09, 0x00, 0x40, 0x6E};
static const uint8_t TEMPERATUREPID_UUID[16] = {0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x10, 0x00, 0x40, 0x6E};
static const uint8_t WRITE_UUID[16] = {0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x02, 0x00, 0x40, 0x6E};

static const esp_gatts_attr_db_t delishup_gatt_db[DELISHUP_IDX_NB] =
{
// Service Declaration
[DELISHUP_SVC_IDX] =
{{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&primary_service_uuid, ESP_GATT_PERM_READ,
sizeof(DELISHUP_SERVICE_UUID), sizeof(DELISHUP_SERVICE_UUID), (uint8_t *)DELISHUP_SERVICE_UUID}},

/* HEARTBEAT Characteristic Declaration */
[HEARTBEAT_CHAR_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)character_declaration_uuid, ESP_GATT_PERM_READ,
        CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_notify}},

/* HEARTBEAT Characteristic Value */
[HEARTBEAT_CHAR_VAL_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)HEARTBEAT_UUID, ESP_GATT_PERM_READ,
        sizeof(heartbeat_val), sizeof(heartbeat_val), (uint8_t *)heartbeat_val}},

/* HEARTBEAT Client Characteristic Configuration Descriptor */
[HEARTBEAT_NTF_CFG] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
        sizeof(heartbeat_val_ccc), sizeof(heartbeat_val_ccc), (uint8_t *)heartbeat_val_ccc}},

/* WEIGHT Characteristic Declaration */
[WEIGHT_CHAR_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)character_declaration_uuid, ESP_GATT_PERM_READ,
        CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_notify}},

/* WEIGHT Characteristic Value */
[WEIGHT_CHAR_VAL_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)WEIGHT_UUID, ESP_GATT_PERM_READ,
        sizeof(weight_val), sizeof(weight_val), (uint8_t *)weight_val}},

/* WEIGHT Client Characteristic Configuration Descriptor */
[WEIGHT_NTF_CFG] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
        sizeof(weight_val_ccc), sizeof(weight_val_ccc), (uint8_t *)weight_val_ccc}},

/* TEMPERATURE Characteristic Declaration */
[TEMPERATURE_CHAR_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)character_declaration_uuid, ESP_GATT_PERM_READ,
        CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_notify}},

/* TEMPERATURE Characteristic Value */
[TEMPERATURE_CHAR_VAL_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)TEMPERATURE_UUID, ESP_GATT_PERM_READ,
        sizeof(temperature_val), sizeof(temperature_val), (uint8_t *)temperature_val}},

/* TEMPERATURE Client Characteristic Configuration Descriptor */
[TEMPERATURE_NTF_CFG] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
        sizeof(temperature_val_ccc), sizeof(temperature_val_ccc), (uint8_t *)temperature_val_ccc}},

/* JAR_LID Characteristic Declaration */
[JAR_LID_CHAR_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)character_declaration_uuid, ESP_GATT_PERM_READ,
        CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_notify}},

/* JAR_LID Characteristic Value */
[JAR_LID_CHAR_VAL_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)JAR_LID_UUID, ESP_GATT_PERM_READ,
        sizeof(jar_lid_val), sizeof(jar_lid_val), (uint8_t *)jar_lid_val}},

/* JAR_LID Client Characteristic Configuration Descriptor */
[JAR_LID_NTF_CFG] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
        sizeof(jar_lid_val_ccc), sizeof(jar_lid_val_ccc), (uint8_t *)jar_lid_val_ccc}},

/* MOTOR Characteristic Declaration */
[MOTOR_CHAR_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)character_declaration_uuid, ESP_GATT_PERM_READ,
        CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_notify}},

/* MOTOR Characteristic Value */
[MOTOR_CHAR_VAL_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)MOTOR_UUID, ESP_GATT_PERM_READ,
        sizeof(motor_val), sizeof(motor_val), (uint8_t *)motor_val}},

/* MOTOR Client Characteristic Configuration Descriptor */
[MOTOR_NTF_CFG] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
        sizeof(motor_val_ccc), sizeof(motor_val_ccc), (uint8_t *)motor_val_ccc}},

/* FIRMWARE Characteristic Declaration */
[FIRMWARE_CHAR_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)character_declaration_uuid, ESP_GATT_PERM_READ,
        CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_notify}},

/* FIRMWARE Characteristic Value */
[FIRMWARE_CHAR_VAL_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)FIRMWARE_UUID, ESP_GATT_PERM_READ,
        sizeof(firmware_val), sizeof(firmware_val), (uint8_t *)firmware_val}},

/* FIRMWARE Client Characteristic Configuration Descriptor */
[FIRMWARE_CHAR_NTF_CFG] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
        sizeof(firmware_val_ccc), sizeof(firmware_val_ccc), (uint8_t *)firmware_val_ccc}},

/* DIAL Characteristic Declaration */
[DIAL_CHAR_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)character_declaration_uuid, ESP_GATT_PERM_READ,
        CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_notify}},

/* DIAL Characteristic Value */
[DIAL_CHAR_VAL_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)DIAL_UUID, ESP_GATT_PERM_READ,
        sizeof(dial_val), sizeof(dial_val), (uint8_t *)dial_val}},

/* DIAL Client Characteristic Configuration Descriptor */
[DIAL_NTF_CFG] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
        sizeof(dial_val_ccc), sizeof(dial_val_ccc), (uint8_t *)dial_val_ccc}},

/* TEMPERATURE_PID Characteristic Declaration */
[TEMPERATURE_PID_CHAR_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)character_declaration_uuid, ESP_GATT_PERM_READ,
        CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_notify}},

/* TEMPERATURE_PID Characteristic Value */
[TEMPERATURE_PID_CHAR_VAL_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)TEMPERATUREPID_UUID, ESP_GATT_PERM_READ,
        sizeof(temperature_pid_val), sizeof(temperature_pid_val), (uint8_t *)temperature_pid_val}},

/* TEMPERATURE_PID Client Characteristic Configuration Descriptor */
[TEMPERATURE_PID_NTF_CFG] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
        sizeof(temperature_pid_val_ccc), sizeof(temperature_pid_val_ccc), (uint8_t *)temperature_pid_val_ccc}},

/* WRITE Characteristic Declaration */
[WRITE_CHAR_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)character_declaration_uuid, ESP_GATT_PERM_READ,
        CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_write}},

/* WRITE Characteristic Value */
[WRITE_CHAR_VAL_IDX] =
    {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)WRITE_UUID, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
        sizeof(tablet_write_val), sizeof(tablet_write_val), (uint8_t *)tablet_write_val}},

};

static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
{
esp_err_t err;
esp_bd_addr_t bd_addr;

ESP_LOGI(BLE_TAG, "GAP_EVT, event %d\n", event);

switch (event)
{
case ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT:
    adv_config_done &= (~ADV_CONFIG_FLAG);
    if (adv_config_done == 0)
    {
        esp_ble_gap_start_advertising(&delishup_adv_params);
    }
    break;
case ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT:
    adv_config_done &= (~SCAN_RSP_CONFIG_FLAG);
    if (adv_config_done == 0)
    {
        esp_ble_gap_start_advertising(&delishup_adv_params);
    }
    break;
case ESP_GAP_BLE_ADV_START_COMPLETE_EVT:
    // advertising start complete event to indicate advertising start successfully or failed
    if ((err = param->adv_start_cmpl.status) != ESP_BT_STATUS_SUCCESS)
    {
        ESP_LOGE(BLE_TAG, "Advertising start failed: %s\n", esp_err_to_name(err));
    }
    else
    {
        ESP_LOGI(BLE_TAG, "advertising start successfully");
    }
    break;
case ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT:
    if (param->adv_stop_cmpl.status != ESP_BT_STATUS_SUCCESS)
    {
        ESP_LOGE(BLE_TAG, "Advertising stop failed");
    }
    else
    {
        ESP_LOGI(BLE_TAG, "Stop adv successfully");
    }
    break;
case ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT:
    ESP_LOGI(BLE_TAG, "update connection params status = %d, min_int = %d, max_int = %d,conn_int = %d,latency = %d, timeout = %d",
             param->update_conn_params.status,
             param->update_conn_params.min_int,
             param->update_conn_params.max_int,
             param->update_conn_params.conn_int,
             param->update_conn_params.latency,
             param->update_conn_params.timeout);
    break;
default:
    break;
}

}

static void gatts_delishup_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param)
{
esp_err_t ret;
esp_ble_char_t delishup_char;
ESP_LOGI(BLE_TAG, "%s - event: %d", func, event);

switch (event)
{
case ESP_GATTS_REG_EVT:
    esp_err_t set_dev_name_ret = esp_ble_gap_set_device_name(DEVICE_NAME);
    if (set_dev_name_ret)
    {
        ESP_LOGE(BLE_TAG, "set device name failed, error code = %x", set_dev_name_ret);
    }
    // config adv data
    esp_err_t ret = esp_ble_gap_config_adv_data(&adv_data);
    if (ret)
    {
        ESP_LOGE(BLE_TAG, "config adv data failed, error code = %x", ret);
    }
    adv_config_done |= ADV_CONFIG_FLAG;
    // config scan response data
    ret = esp_ble_gap_config_adv_data(&scan_rsp_data);
    if (ret)
    {
        ESP_LOGE(BLE_TAG, "config scan response data failed, error code = %x", ret);
    }
    adv_config_done |= SCAN_RSP_CONFIG_FLAG;

    ret = esp_ble_gatts_create_attr_tab(delishup_gatt_db, gatts_if, DELISHUP_IDX_NB, DELISHUP_PROFILE_APP_IDX);
    if (ret)
    {
        ESP_LOGE(BLE_TAG, "%s - create attr table failed, error code = %x", __func__, ret);
    }
    break;
case ESP_GATTS_READ_EVT:
    delishup_char = find_delishup_char_and_desr_by_handle(param->read.handle);
    ESP_LOGI(BLE_TAG, "client read, delishup_char: %d", delishup_char);
    break;
case ESP_GATTS_WRITE_EVT:
    ESP_LOGI(BLE_TAG, "ESP_GATTS_WRITE_EVT: handle = %d", param->write.handle);
    break;
case ESP_GATTS_EXEC_WRITE_EVT:
    ESP_LOGI(BLE_TAG, "ESP_GATTS_EXEC_WRITE_EVT %s - L%d", __func__, __LINE__);
    break;
case ESP_GATTS_MTU_EVT:
    ESP_LOGI(BLE_TAG, "ESP_GATTS_MTU_EVT - mtu = %d - %s - L%d", param->mtu.mtu, __func__, __LINE__);
    delishup_profile_tab[DELISHUP_PROFILE_APP_IDX].mtu_size = param->mtu.mtu;
    break;
case ESP_GATTS_CONF_EVT:
    break;
case ESP_GATTS_START_EVT:
    ESP_LOGI(BLE_TAG, "SERVICE_START_EVT, status %d, service_handle %d", param->start.status, param->start.service_handle);
    if (param->start.status != ESP_GATT_OK)
    {
        ESP_LOGE(BLE_TAG, "SERVICE START FAIL, status %d", param->start.status);
        break;
    }
    break;
case ESP_GATTS_CONNECT_EVT:
    delishup_profile_tab[DELISHUP_PROFILE_APP_IDX].conn_id = param->connect.conn_id;
    break;
case ESP_GATTS_DISCONNECT_EVT:
    esp_ble_gap_start_advertising(&delishup_adv_params);
    break;
case ESP_GATTS_CREAT_ATTR_TAB_EVT:
    if (param->add_attr_tab.status != ESP_GATT_OK)
    {
        ESP_LOGE(BLE_TAG, "create attribute table failed, error code=0x%x", param->add_attr_tab.status);
    }
    else if (param->add_attr_tab.num_handle != DELISHUP_IDX_NB)
    {
        ESP_LOGE(BLE_TAG, "create attribute table abnormally, num_handle (%d) doesn't equal to DELISHUP_IDX_NB(%d)", param->add_attr_tab.num_handle, DELISHUP_IDX_NB);
    }
    else
    {
        ESP_LOGI(BLE_TAG, "creating attribute table, the number handle = %d\n", param->add_attr_tab.num_handle);
        memcpy(delishup_handle_table, param->add_attr_tab.handles, sizeof(delishup_handle_table));
        ret = esp_ble_gatts_start_service(delishup_handle_table[DELISHUP_SVC_IDX]);
        if (ret != ESP_OK)
        {
            ESP_LOGE(BLE_TAG, "start service failed, error code = %x", ret);
        }
        else
        {
            ESP_LOGI(BLE_TAG, "service started successfully");
        }
    }
    break;
default:
    break;
}

}`

Debug Logs.

I (3649) BTDM_INIT: BT controller compile version [a38dc5c]
I (3651) BTDM_INIT: Bluetooth MAC: a0:b7:65:ce:16:f6
I (3654) phy_init: phy_version 4791,2c4672b,Dec 20 2023,16:06:06
I (3970) ESP_BLE: esp_ble_init init bluetooth

I (4048) ESP_BLE: EVT 0, gatts if 3

I (4049) ESP_BLE: gatts_delishup_profile_event_handler - event: 0
I (4051) main_task: Returned from app_main()
I (4062) ESP_BLE: EVT 22, gatts if 3

I (4063) ESP_BLE: gatts_delishup_profile_event_handler - event: 22
I (4065) ESP_BLE: creating attribute table, the number handle = 27

I (4072) ESP_BLE: service started successfully
I (4077) ESP_BLE: GAP_EVT, event 0

I (4081) ESP_BLE: GAP_EVT, event 1

I (4087) ESP_BLE: EVT 12, gatts if 3

I (4091) ESP_BLE: gatts_delishup_profile_event_handler - event: 12
I (4097) ESP_BLE: SERVICE_START_EVT, status 0, service_handle 40
I (4104) ESP_BLE: GAP_EVT, event 6

I (4108) ESP_BLE: advertising start successfully
I (7803) ESP_BLE: EVT 14, gatts if 3

I (7804) ESP_BLE: gatts_delishup_profile_event_handler - event: 14
I (8516) ESP_BLE: GAP_EVT, event 20

I (8517) ESP_BLE: update connection params status = 0, min_int = 0, max_int = 0,conn_int = 6,latency = 0, timeout = 500
I (8966) ESP_BLE: GAP_EVT, event 20

I (8967) ESP_BLE: update connection params status = 0, min_int = 0, max_int = 0,conn_int = 36,latency = 0, timeout = 500

More Information.

Even if I update all characteristic UUIDs to 128-bit by setting ESP_UUID_LEN_128.

[DELISHUP_SVC_IDX] =
{{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)DELISHUP_SERVICE_UUID, ESP_GATT_PERM_READ,
sizeof(DELISHUP_SERVICE_UUID), sizeof(DELISHUP_SERVICE_UUID), (uint8_t *)DELISHUP_SERVICE_UUID}},

[HEARTBEAT_CHAR_IDX] =
{{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)character_declaration_uuid, ESP_GATT_PERM_READ,
CHAR_DECLARATION_SIZE, CHAR_DECLARATION_SIZE, (uint8_t *)&char_prop_notify}},

[HEARTBEAT_CHAR_VAL_IDX] =
{{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)HEARTBEAT_UUID, ESP_GATT_PERM_READ,
sizeof(heartbeat_val), sizeof(heartbeat_val), (uint8_t *)heartbeat_val}},

[HEARTBEAT_NTF_CFG] =
{{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
sizeof(heartbeat_val_ccc), sizeof(heartbeat_val_ccc), (uint8_t *)heartbeat_val_ccc}},

I (3649) BTDM_INIT: BT controller compile version [a38dc5c]
I (3651) BTDM_INIT: Bluetooth MAC: a0:b7:65:ce:16:f6
I (3654) phy_init: phy_version 4791,2c4672b,Dec 20 2023,16:06:06

I (3977) ESP_BLE: esp_ble_init init bluetooth

I (4055) ESP_BLE: EVT 0, gatts if 3

I (4056) ESP_BLE: gatts_delishup_profile_event_handler - event: 0
I (4058) ESP_BLE: EVT 22, gatts if 3

I (4062) ESP_BLE: gatts_delishup_profile_event_handler - event: 22
I (4067) ESP_BLE: creating attribute table, the number handle = 27

I (4074) ESP_BLE: service started successfully
I (4079) ESP_BLE: GAP_EVT, event 0

I (4083) ESP_BLE: GAP_EVT, event 1

I (4089) main_task: Returned from app_main()
I (4101) ESP_BLE: GAP_EVT, event 6

I (4102) ESP_BLE: advertising start successfully
I (8044) ESP_BLE: EVT 14, gatts if 3

I (8045) ESP_BLE: gatts_delishup_profile_event_handler - event: 14
I (8805) ESP_BLE: GAP_EVT, event 20

I (8807) ESP_BLE: update connection params status = 0, min_int = 0, max_int = 0,conn_int = 6,latency = 0, timeout = 500
I (8997) ESP_BLE: GAP_EVT, event 20

I (8997) ESP_BLE: update connection params status = 0, min_int = 0, max_int = 0,conn_int = 36,latency = 0, timeout = 500
I (16588) ESP_BLE: EVT 15, gatts if 3

I (16589) ESP_BLE: gatts_delishup_profile_event_handler - event: 15
I (16604) ESP_BLE: GAP_EVT, event 6

I (16604) ESP_BLE: advertising start successfully
I (18844) ESP_BLE: EVT 14, gatts if 3

I (18845) ESP_BLE: gatts_delishup_profile_event_handler - event: 14
I (19557) ESP_BLE: GAP_EVT, event 20

I (19558) ESP_BLE: update connection params status = 0, min_int = 0, max_int = 0,conn_int = 6,latency = 0, timeout = 500
I (19751) ESP_BLE: GAP_EVT, event 20

I (19752) ESP_BLE: update connection params status = 0, min_int = 0, max_int = 0,conn_int = 36,latency = 0, timeout = 500
I (26218) ESP_BLE: EVT 15, gatts if 3

I (26219) ESP_BLE: gatts_delishup_profile_event_handler - event: 15
I (26233) ESP_BLE: GAP_EVT, event 6

I (26234) ESP_BLE: advertising start successfully

@meakashrao meakashrao added the Type: Bug bugs in IDF label Jun 15, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jun 15, 2024
@github-actions github-actions bot changed the title BLE 128Bit UUID's not reflecting only service and not in characteristics BLE 128Bit UUID's not reflecting only service and not in characteristics (IDFGH-13039) Jun 15, 2024
@meakashrao
Copy link
Author

meakashrao commented Jun 15, 2024

I made some more changes

static const uint8_t primary_service_uuid[2] = {ESP_GATT_UUID_PRI_SERVICE & 0xFF, (ESP_GATT_UUID_PRI_SERVICE >> 8) & 0xFF};
static const uint8_t character_declaration_uuid[2] = {ESP_GATT_UUID_CHAR_DECLARE & 0xFF, (ESP_GATT_UUID_CHAR_DECLARE >> 8) & 0xFF};
static const uint8_t character_client_config_uuid[2] = {ESP_GATT_UUID_CHAR_CLIENT_CONFIG & 0xFF, (ESP_GATT_UUID_CHAR_CLIENT_CONFIG >> 8) & 0xFF};

#define CHAR_DECLARATION_SIZE (sizeof(uint16_t))

also based on logs all 27 handles are successfully created

UUID128 bit_Logs_Code_Snippet.txt

@meakashrao
Copy link
Author

meakashrao commented Jun 16, 2024

#11916

Says a patch file needs to run 0001-fix-bt-bluedroid-Fix-uuid-length-error-when-uuid-is-.patch

when I run it

C:\Users\Akash\esp\v5.1\esp-idf>git apply 0001-fix-bt-bluedroid-Fix-uuid-length-error-when-uuid-is-.patch
error: patch failed: components/bt/host/bluedroid/stack/gatt/gatt_utils.c:1229
error: components/bt/host/bluedroid/stack/gatt/gatt_utils.c: patch does not apply

@zhp0406 Please help what is to be done next

@meakashrao meakashrao changed the title BLE 128Bit UUID's not reflecting only service and not in characteristics (IDFGH-13039) BLE 128Bit UUID's is not running (IDFGH-13039) Jun 16, 2024
@meakashrao
Copy link
Author

meakashrao commented Jun 16, 2024

image

#13673

Even the recent patch is failing for me, am I doing something wrong?

@meakashrao
Copy link
Author

meakashrao commented Jun 17, 2024

image

I updated to the stable release of 5.2.2 and still this is a trouble? I am applying the patch file to the location where my ESP Downloaded file is located, do I need to apply the patch file somewhere else?
I am applying the patch file to the location where my ESP files are located and the project files are located in a different directory.

@esp-zhp
Copy link
Collaborator

esp-zhp commented Jun 27, 2024

I will give you a patch base on ESP-IDF v5.1.2-666-ga5e3e0b90e to display usage of 128 bit uuid

@meakashrao
Copy link
Author

I am able to use 128 bit UUID's if I use this table definition, am I right? or i still need to use the patch?

static const esp_gatts_attr_db_t delishup_gatt_db[DELISHUP_IDX_NB] =
{
// Service Declaration
[DELISHUP_SVC_IDX] =
{{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&primary_service_uuid, ESP_GATT_PERM_READ, sizeof(DELISHUP_SERVICE_UUID), sizeof(DELISHUP_SERVICE_UUID),
(uint8_t *)&DELISHUP_SERVICE_UUID}},

    /* HEARTBEAT Characteristic Declaration */
    [HEARTBEAT_CHAR_IDX] =
        {{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_notify}},

    /* HEARTBEAT Characteristic Value */
    [HEARTBEAT_CHAR_VAL_IDX] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&HEARTBEAT_UUID, ESP_GATT_PERM_READ, sizeof(heartbeat_val), sizeof(heartbeat_val), (uint8_t *)heartbeat_val}},

    //HEARTBEAT data notify characteristic Declaration
    [HEARTBEAT_NTF_CFG] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE, sizeof(heartbeat_val_ccc), sizeof(heartbeat_val_ccc), (uint8_t *)heartbeat_val_ccc}},
    
    // data receive characteristic Declaration
    [WEIGHT_CHAR_IDX] =
        {{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_notify}},

    // data receive characteristic Value
    [WEIGHT_CHAR_VAL_IDX] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&WEIGHT_UUID, ESP_GATT_PERM_READ, sizeof(weight_val), sizeof(weight_val), (uint8_t *)weight_val}},

    // data notify characteristic Declaration
    [WEIGHT_NTF_CFG] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE, sizeof(weight_val_ccc), sizeof(weight_val_ccc), (uint8_t *)weight_val_ccc}},

    // data receive characteristic Declaration
    [TEMPERATURE_CHAR_IDX] =
        {{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_notify}},

    // data receive characteristic Value
    [TEMPERATURE_CHAR_VAL_IDX] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&TEMPERATURE_UUID, ESP_GATT_PERM_READ, sizeof(temperature_val), sizeof(temperature_val), (uint8_t *)temperature_val}},

    // data notify characteristic Declaration
    [TEMPERATURE_NTF_CFG] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE, sizeof(temperature_val_ccc), sizeof(temperature_val_ccc), (uint8_t *)temperature_val_ccc}},

    // data receive characteristic Declaration
    [JAR_LID_CHAR_IDX] =
        {{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_notify}},

    // data receive characteristic Value
    [JAR_LID_CHAR_VAL_IDX] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&JAR_LID_UUID, ESP_GATT_PERM_READ, sizeof(jar_lid_val), sizeof(jar_lid_val), (uint8_t *)jar_lid_val}},

    // data notify characteristic Declaration
    [JAR_LID_NTF_CFG] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE, sizeof(jar_lid_val_ccc), sizeof(jar_lid_val_ccc), (uint8_t *)jar_lid_val_ccc}},

    // data receive characteristic Declaration
    [MOTOR_CHAR_IDX] =
        {{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_notify}},

    // data receive characteristic Value
    [MOTOR_CHAR_VAL_IDX] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&MOTOR_UUID, ESP_GATT_PERM_READ, sizeof(motor_val), sizeof(motor_val), (uint8_t *)motor_val}},

    // data notify characteristic Declaration
    [MOTOR_NTF_CFG] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE, sizeof(motor_val_ccc), sizeof(motor_val_ccc), (uint8_t *)motor_val_ccc}},

    // data receive characteristic Declaration
    [FIRMWARE_CHAR_IDX] =
        {{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_notify}},

    // data receive characteristic Value
    [FIRMWARE_CHAR_VAL_IDX] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&FIRMWARE_UUID, ESP_GATT_PERM_READ, sizeof(firmware_val), sizeof(firmware_val), (uint8_t *)firmware_val}},

    // data notify characteristic Declaration
    [FIRMWARE_CHAR_NTF_CFG] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE, sizeof(firmware_val_ccc), sizeof(firmware_val_ccc), (uint8_t *)firmware_val_ccc}},

    // data receive characteristic Declaration
    [DIAL_CHAR_IDX] =
        {{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_notify}},

    // data receive characteristic Value
    [DIAL_CHAR_VAL_IDX] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&DIAL_UUID, ESP_GATT_PERM_READ, sizeof(dial_val), sizeof(dial_val), (uint8_t *)dial_val}},

    // data notify characteristic Declaration
    [DIAL_NTF_CFG] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE, sizeof(dial_val_ccc), sizeof(dial_val_ccc), (uint8_t *)dial_val_ccc}},

    // data receive characteristic Declaration
    [TEMPERATURE_PID_CHAR_IDX] =
        {{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_notify}},

    // data receive characteristic Value
    [TEMPERATURE_PID_CHAR_VAL_IDX] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&TEMPERATUREPID_UUID, ESP_GATT_PERM_READ, sizeof(temperature_pid_val), sizeof(temperature_pid_val), (uint8_t *)temperature_pid_val}},

    // data notify characteristic Declaration
    [TEMPERATURE_PID_NTF_CFG] =
        {{ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_16, (uint8_t *)&character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE, sizeof(temperature_pid_val_ccc), sizeof(temperature_pid_val_ccc), (uint8_t *)temperature_pid_val_ccc}},

    /* Characteristic Declaration */
    [WRITE_CHAR_IDX] = {
        {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_write}},

    /* Characteristic Value */
    [WRITE_CHAR_VAL_IDX] = {
        {ESP_GATT_AUTO_RSP}, {ESP_UUID_LEN_128, (uint8_t *)&WRITE_UUID, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE, sizeof(tablet_write_val), sizeof(tablet_write_val), (uint8_t *)tablet_write_val}},

};

@esp-zhp
Copy link
Collaborator

esp-zhp commented Jun 27, 2024

My patch only demonstrates how to use a 128-bit UUID and does not provide any fixes. Therefore, if you are already able to use a 128-bit UUID, you do not need to apply our patch.

It is important to note that 128-bit UUIDs can be classified into base 128-bit UUIDs and non-base 128-bit UUIDs. Base 128-bit UUIDs can be converted to 16-bit UUIDs, and this conversion will be done automatically.

For example, if you define a base 128-bit UUID on a GATT server, the GATT client will automatically convert the discovered 128-bit UUID to the corresponding 16-bit UUID.

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Jun 28, 2024
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: In Progress Work is in progress labels Dec 17, 2024
@Alvin1Zhang
Copy link
Collaborator

Thanks for reporting, will close due to inactivity, feel free to reopen if the issue still happens. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

4 participants