esp32-c3 例程esp-idf-v4.4中gatt_client作为主机模式,连接从机的注册方式怎么改成indicate方式[已解决]

lala51
Posts: 9
Joined: Thu May 12, 2022 9:25 am

esp32-c3 例程esp-idf-v4.4中gatt_client作为主机模式,连接从机的注册方式怎么改成indicate方式[已解决]

Postby lala51 » Thu May 12, 2022 9:47 am

在esp32-c3 例程esp-idf-v4.4中gatt_client作为主机模式,连接从机的注册方式怎么改成indicate方式?

例程中定义了NOTIFY的UUID
//#define REMOTE_SERVICE_UUID 0x00FF
//#define REMOTE_NOTIFY_CHAR_UUID 0xFF01

现在想使用esp32-c3 作为客户端通过indicate的方式链接 蓝牙服务端模块,例程只是描述了NOTIFY的方式,这种方式读写是在一个UUID上的,但是indicate的读写和特征描述都是在不同的UUID上,请问作为客户端模式下怎么使用indicate的方式 蓝牙服务端模块,同时能够实现读写操作?
  1.                     status = esp_ble_gattc_get_char_by_uuid( gattc_if,
  2.                                                              p_data->search_cmpl.conn_id,
  3.                                                              gl_profile_tab[PROFILE_A_APP_ID].service_start_handle,
  4.                                                              gl_profile_tab[PROFILE_A_APP_ID].service_end_handle,
  5.                                                              remote_filter_char_uuid,
  6.                                                              char_elem_result,
  7.                                                              &count);
  8.                     if (status != ESP_GATT_OK){
  9.                         ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_char_by_uuid error");
  10.                     }
  11.  
  12.                     /*  Every service have only one char in our 'ESP_GATTS_DEMO' demo, so we used first 'char_elem_result' */
  13.                     if (count > 0 && (char_elem_result[0].properties & ESP_GATT_CHAR_PROP_BIT_NOTIFY)){
  14.                         gl_profile_tab[PROFILE_A_APP_ID].char_handle = char_elem_result[0].char_handle;
  15. [color=#FF0000]                        esp_ble_gattc_register_for_notify (gattc_if, gl_profile_tab[PROFILE_A_APP_ID].remote_bda, char_elem_result[0].char_handle);
  16. //此处怎么怎么更改?[/color]
  17.                     }

ESP_XuLZ
Posts: 173
Joined: Fri Mar 26, 2021 6:04 am

Re: esp32-c3 例程esp-idf-v4.4中gatt_client作为主机模式,连接从机的注册方式怎么改成indicate方式

Postby ESP_XuLZ » Sun May 15, 2022 2:25 am

以 gatt_client 和 gatt_server_service_table 为例, 首先 server 端的对应 characteristic 应当具有 indicate 权限,修改如下
20220515101252.png
20220515101252.png (162.97 KiB) Viewed 1837 times
在 gattc_client 判断 characteristic 权限时也进行相应修改
20220515101119.png
20220515101119.png (111.04 KiB) Viewed 1837 times
最后使用 esp_ble_gattc_write_char_descr 进行写入使能 indicate,如下
20220515095443.png
20220515095443.png (119.03 KiB) Viewed 1837 times
同一个 CCCD 描述符仅能选择使能 notify或者 indicate ,两者不能同时使用

lala51
Posts: 9
Joined: Thu May 12, 2022 9:25 am

Re: esp32-c3 例程esp-idf-v4.4中gatt_client作为主机模式,连接从机的注册方式怎么改成indicate方式[已解决]

Postby lala51 » Fri Jul 01, 2022 12:36 am

谢谢您的回复!!!

Who is online

Users browsing this forum: No registered users and 50 guests