mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Component/bt: add some comment
This commit is contained in:
parent
7594127ca3
commit
7c777f40aa
@ -63,7 +63,7 @@ typedef enum {
|
|||||||
ESP_GATTC_UNREG_FOR_NOTIFY_EVT = 39, /*!< When unregister for notification of a service completes, the event comes */
|
ESP_GATTC_UNREG_FOR_NOTIFY_EVT = 39, /*!< When unregister for notification of a service completes, the event comes */
|
||||||
ESP_GATTC_CONNECT_EVT = 40, /*!< When the ble physical connection is set up, the event comes */
|
ESP_GATTC_CONNECT_EVT = 40, /*!< When the ble physical connection is set up, the event comes */
|
||||||
ESP_GATTC_DISCONNECT_EVT = 41, /*!< When the ble physical connection disconnected, the event comes */
|
ESP_GATTC_DISCONNECT_EVT = 41, /*!< When the ble physical connection disconnected, the event comes */
|
||||||
ESP_GATTC_READ_MUTIPLE_EVT = 42, /*!< When the ble characteristic or descriptor mutiple complete, the event comes */
|
ESP_GATTC_READ_MULTIPLE_EVT = 42, /*!< When the ble characteristic or descriptor multiple complete, the event comes */
|
||||||
ESP_GATTC_QUEUE_FULL_EVT = 43, /*!< When the gattc command queue full, the event comes */
|
ESP_GATTC_QUEUE_FULL_EVT = 43, /*!< When the gattc command queue full, the event comes */
|
||||||
} esp_gattc_cb_event_t;
|
} esp_gattc_cb_event_t;
|
||||||
|
|
||||||
|
@ -545,7 +545,7 @@ void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi,
|
|||||||
p_buf->hdr.layer_specific = conn_id;
|
p_buf->hdr.layer_specific = conn_id;
|
||||||
p_buf->auth_req = auth_req;
|
p_buf->auth_req = auth_req;
|
||||||
p_buf->num_attr = p_read_multi->num_attr;
|
p_buf->num_attr = p_read_multi->num_attr;
|
||||||
p_buf->cmpl_evt = BTA_GATTC_READ_MUTIPLE_EVT;
|
p_buf->cmpl_evt = BTA_GATTC_READ_MULTIPLE_EVT;
|
||||||
if (p_buf->num_attr > 0) {
|
if (p_buf->num_attr > 0) {
|
||||||
memcpy(p_buf->handles, p_read_multi->handles, sizeof(UINT16) * p_read_multi->num_attr);
|
memcpy(p_buf->handles, p_read_multi->handles, sizeof(UINT16) * p_read_multi->num_attr);
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ typedef UINT8 tBTA_GATT_STATUS;
|
|||||||
#define BTA_GATTC_ADV_VSC_EVT 34 /* ADV VSC event */
|
#define BTA_GATTC_ADV_VSC_EVT 34 /* ADV VSC event */
|
||||||
#define BTA_GATTC_CONNECT_EVT 35 /* GATTC CONNECT event */
|
#define BTA_GATTC_CONNECT_EVT 35 /* GATTC CONNECT event */
|
||||||
#define BTA_GATTC_DISCONNECT_EVT 36 /* GATTC DISCONNECT event */
|
#define BTA_GATTC_DISCONNECT_EVT 36 /* GATTC DISCONNECT event */
|
||||||
#define BTA_GATTC_READ_MUTIPLE_EVT 37 /* GATTC Read mutiple event */
|
#define BTA_GATTC_READ_MULTIPLE_EVT 37 /* GATTC Read mutiple event */
|
||||||
#define BTA_GATTC_QUEUE_FULL_EVT 38 /* GATTC queue full event */
|
#define BTA_GATTC_QUEUE_FULL_EVT 38 /* GATTC queue full event */
|
||||||
|
|
||||||
typedef UINT8 tBTA_GATTC_EVT;
|
typedef UINT8 tBTA_GATTC_EVT;
|
||||||
|
@ -128,8 +128,8 @@ static void btc_gattc_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
|||||||
// Allocate buffer for request data if necessary
|
// Allocate buffer for request data if necessary
|
||||||
switch (msg->act) {
|
switch (msg->act) {
|
||||||
case BTA_GATTC_READ_DESCR_EVT:
|
case BTA_GATTC_READ_DESCR_EVT:
|
||||||
case BTA_GATTC_READ_CHAR_EVT:
|
case BTA_GATTC_READ_CHAR_EVT:
|
||||||
case BTA_GATTC_READ_MUTIPLE_EVT: {
|
case BTA_GATTC_READ_MULTIPLE_EVT: {
|
||||||
if (p_src_data->read.p_value && p_src_data->read.p_value->p_value) {
|
if (p_src_data->read.p_value && p_src_data->read.p_value->p_value) {
|
||||||
p_dest_data->read.p_value = (tBTA_GATT_UNFMT *)osi_malloc(sizeof(tBTA_GATT_UNFMT) + p_src_data->read.p_value->len);
|
p_dest_data->read.p_value = (tBTA_GATT_UNFMT *)osi_malloc(sizeof(tBTA_GATT_UNFMT) + p_src_data->read.p_value->len);
|
||||||
p_dest_data->read.p_value->p_value = (uint8_t *)(p_dest_data->read.p_value + 1);
|
p_dest_data->read.p_value->p_value = (uint8_t *)(p_dest_data->read.p_value + 1);
|
||||||
@ -152,8 +152,8 @@ static void btc_gattc_free_req_data(btc_msg_t *msg)
|
|||||||
tBTA_GATTC *arg = (tBTA_GATTC *)(msg->arg);
|
tBTA_GATTC *arg = (tBTA_GATTC *)(msg->arg);
|
||||||
switch (msg->act) {
|
switch (msg->act) {
|
||||||
case BTA_GATTC_READ_DESCR_EVT:
|
case BTA_GATTC_READ_DESCR_EVT:
|
||||||
case BTA_GATTC_READ_CHAR_EVT:
|
case BTA_GATTC_READ_CHAR_EVT:
|
||||||
case BTA_GATTC_READ_MUTIPLE_EVT: {
|
case BTA_GATTC_READ_MULTIPLE_EVT: {
|
||||||
if (arg->read.p_value) {
|
if (arg->read.p_value) {
|
||||||
osi_free(arg->read.p_value);
|
osi_free(arg->read.p_value);
|
||||||
}
|
}
|
||||||
@ -809,9 +809,9 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
|
|||||||
btc_gattc_cb_to_app(ESP_GATTC_READ_DESCR_EVT, gattc_if, ¶m);
|
btc_gattc_cb_to_app(ESP_GATTC_READ_DESCR_EVT, gattc_if, ¶m);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTA_GATTC_READ_MUTIPLE_EVT: {
|
case BTA_GATTC_READ_MULTIPLE_EVT: {
|
||||||
set_read_value(&gattc_if, ¶m, &arg->read);
|
set_read_value(&gattc_if, ¶m, &arg->read);
|
||||||
btc_gattc_cb_to_app(ESP_GATTC_READ_MUTIPLE_EVT, gattc_if, ¶m);
|
btc_gattc_cb_to_app(ESP_GATTC_READ_MULTIPLE_EVT, gattc_if, ¶m);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTA_GATTC_WRITE_DESCR_EVT: {
|
case BTA_GATTC_WRITE_DESCR_EVT: {
|
||||||
|
@ -6,6 +6,14 @@
|
|||||||
CONDITIONS OF ANY KIND, either express or implied.
|
CONDITIONS OF ANY KIND, either express or implied.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* This is a demo for bluetooth config wifi connection to ap. You can config ESP32 to connect a softap
|
||||||
|
* or config ESP32 as a softap to be connected by other device. APP can be downloaded from github
|
||||||
|
* android source code: https://github.com/EspressifApp/EspBlufi
|
||||||
|
* iOS source code: https://github.com/EspressifApp/EspBlufiForiOS
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -351,14 +351,16 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
|
|||||||
case ESP_GAP_BLE_LOCAL_ER_EVT: /* BLE local ER event */
|
case ESP_GAP_BLE_LOCAL_ER_EVT: /* BLE local ER event */
|
||||||
ESP_LOGI(GATTC_TAG, "ESP_GAP_BLE_LOCAL_ER_EVT");
|
ESP_LOGI(GATTC_TAG, "ESP_GAP_BLE_LOCAL_ER_EVT");
|
||||||
break;
|
break;
|
||||||
case ESP_GAP_BLE_NC_REQ_EVT:
|
|
||||||
ESP_LOGI(GATTC_TAG, "ESP_GAP_BLE_NC_REQ_EVT");
|
|
||||||
break;
|
|
||||||
case ESP_GAP_BLE_SEC_REQ_EVT:
|
case ESP_GAP_BLE_SEC_REQ_EVT:
|
||||||
/* send the positive(true) security response to the peer device to accept the security request.
|
/* send the positive(true) security response to the peer device to accept the security request.
|
||||||
If not accept the security request, should sent the security response with negative(false) accept value*/
|
If not accept the security request, should sent the security response with negative(false) accept value*/
|
||||||
esp_ble_gap_security_rsp(param->ble_security.ble_req.bd_addr, true);
|
esp_ble_gap_security_rsp(param->ble_security.ble_req.bd_addr, true);
|
||||||
break;
|
break;
|
||||||
|
case ESP_GAP_BLE_NC_REQ_EVT:
|
||||||
|
/* The app will receive this evt when the IO has DisplayYesNO capability and the peer device IO also has DisplayYesNo capability.
|
||||||
|
show the passkey number to the user to confirm it with the number displayed by peer deivce. */
|
||||||
|
ESP_LOGI(GATTC_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%d", param->ble_security.key_notif.passkey);
|
||||||
|
break;
|
||||||
case ESP_GAP_BLE_PASSKEY_NOTIF_EVT: ///the app will receive this evt when the IO has Output capability and the peer device IO has Input capability.
|
case ESP_GAP_BLE_PASSKEY_NOTIF_EVT: ///the app will receive this evt when the IO has Output capability and the peer device IO has Input capability.
|
||||||
///show the passkey number to the user to input it in the peer deivce.
|
///show the passkey number to the user to input it in the peer deivce.
|
||||||
ESP_LOGI(GATTC_TAG, "The passkey Notify number:%d", param->ble_security.key_notif.passkey);
|
ESP_LOGI(GATTC_TAG, "The passkey Notify number:%d", param->ble_security.key_notif.passkey);
|
||||||
|
@ -295,7 +295,9 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
|
|||||||
ESP_LOGI(GATTS_TABLE_TAG, "ESP_GAP_BLE_LOCAL_ER_EVT");
|
ESP_LOGI(GATTS_TABLE_TAG, "ESP_GAP_BLE_LOCAL_ER_EVT");
|
||||||
break;
|
break;
|
||||||
case ESP_GAP_BLE_NC_REQ_EVT:
|
case ESP_GAP_BLE_NC_REQ_EVT:
|
||||||
ESP_LOGI(GATTS_TABLE_TAG, "ESP_GAP_BLE_NC_REQ_EVT");
|
/* The app will receive this evt when the IO has DisplayYesNO capability and the peer device IO also has DisplayYesNo capability.
|
||||||
|
show the passkey number to the user to confirm it with the number displayed by peer deivce. */
|
||||||
|
ESP_LOGI(GATTS_TABLE_TAG, "ESP_GAP_BLE_NC_REQ_EVT, the passkey Notify number:%d", param->ble_security.key_notif.passkey);
|
||||||
break;
|
break;
|
||||||
case ESP_GAP_BLE_SEC_REQ_EVT:
|
case ESP_GAP_BLE_SEC_REQ_EVT:
|
||||||
/* send the positive(true) security response to the peer device to accept the security request.
|
/* send the positive(true) security response to the peer device to accept the security request.
|
||||||
|
@ -38,7 +38,10 @@
|
|||||||
#define SAMPLE_DEVICE_NAME "ESP_GATTS_DEMO"
|
#define SAMPLE_DEVICE_NAME "ESP_GATTS_DEMO"
|
||||||
#define SVC_INST_ID 0
|
#define SVC_INST_ID 0
|
||||||
|
|
||||||
#define GATTS_DEMO_CHAR_VAL_LEN_MAX 100
|
/* The max length of characteristic value. When the gatt client write or prepare write,
|
||||||
|
* the data length must be less than GATTS_DEMO_CHAR_VAL_LEN_MAX.
|
||||||
|
*/
|
||||||
|
#define GATTS_DEMO_CHAR_VAL_LEN_MAX 500
|
||||||
#define PREPARE_BUF_MAX_SIZE 1024
|
#define PREPARE_BUF_MAX_SIZE 1024
|
||||||
#define CHAR_DECLARATION_SIZE (sizeof(uint8_t))
|
#define CHAR_DECLARATION_SIZE (sizeof(uint8_t))
|
||||||
|
|
||||||
@ -378,6 +381,7 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_
|
|||||||
break;
|
break;
|
||||||
case ESP_GATTS_WRITE_EVT:
|
case ESP_GATTS_WRITE_EVT:
|
||||||
if (!param->write.is_prep){
|
if (!param->write.is_prep){
|
||||||
|
// the data length of gattc write must be less than GATTS_DEMO_CHAR_VAL_LEN_MAX.
|
||||||
ESP_LOGI(GATTS_TABLE_TAG, "GATT_WRITE_EVT, handle = %d, value len = %d, value :", param->write.handle, param->write.len);
|
ESP_LOGI(GATTS_TABLE_TAG, "GATT_WRITE_EVT, handle = %d, value len = %d, value :", param->write.handle, param->write.len);
|
||||||
esp_log_buffer_hex(GATTS_TABLE_TAG, param->write.value, param->write.len);
|
esp_log_buffer_hex(GATTS_TABLE_TAG, param->write.value, param->write.len);
|
||||||
if (heart_rate_handle_table[IDX_CHAR_CFG_A] == param->write.handle && param->write.len == 2){
|
if (heart_rate_handle_table[IDX_CHAR_CFG_A] == param->write.handle && param->write.len == 2){
|
||||||
@ -420,7 +424,8 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_
|
|||||||
example_prepare_write_event_env(gatts_if, &prepare_write_env, param);
|
example_prepare_write_event_env(gatts_if, &prepare_write_env, param);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ESP_GATTS_EXEC_WRITE_EVT:
|
case ESP_GATTS_EXEC_WRITE_EVT:
|
||||||
|
// the length of gattc prapare write data must be less than GATTS_DEMO_CHAR_VAL_LEN_MAX.
|
||||||
ESP_LOGI(GATTS_TABLE_TAG, "ESP_GATTS_EXEC_WRITE_EVT");
|
ESP_LOGI(GATTS_TABLE_TAG, "ESP_GATTS_EXEC_WRITE_EVT");
|
||||||
example_exec_write_event_env(&prepare_write_env, param);
|
example_exec_write_event_env(&prepare_write_env, param);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user