mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/protocomm_update_params' into 'master'
fix(protocomm): added Protocomm BLE Event Structure and Event Handling See merge request espressif/esp-idf!26707
This commit is contained in:
commit
e689cc55d8
@ -59,6 +59,35 @@ typedef struct name_uuid {
|
||||
uint16_t uuid;
|
||||
} protocomm_ble_name_uuid_t;
|
||||
|
||||
/**
|
||||
* @brief Structure for BLE events in Protocomm.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* This field indicates the type of BLE event that occurred.
|
||||
*/
|
||||
uint16_t evt_type;
|
||||
/**
|
||||
* The handle of the relevant connection.
|
||||
*/
|
||||
uint16_t conn_handle;
|
||||
|
||||
union {
|
||||
/**
|
||||
* The status of the connection attempt;
|
||||
* o 0: the connection was successfully established.
|
||||
* o BLE host error code: the connection attempt failed for
|
||||
* the specified reason.
|
||||
*/
|
||||
uint16_t conn_status;
|
||||
|
||||
/**
|
||||
* Return code indicating the reason for the disconnect.
|
||||
*/
|
||||
uint16_t disconnect_reason;
|
||||
};
|
||||
} protocomm_ble_event_t;
|
||||
|
||||
/**
|
||||
* @brief Config parameters for protocomm BLE service
|
||||
*/
|
||||
|
@ -345,7 +345,13 @@ static void transport_simple_ble_disconnect(esp_gatts_cb_event_t event, esp_gatt
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "error closing the session after disconnect");
|
||||
} else {
|
||||
if (esp_event_post(PROTOCOMM_TRANSPORT_BLE_EVENT, PROTOCOMM_TRANSPORT_BLE_DISCONNECTED, NULL, 0, portMAX_DELAY) != ESP_OK) {
|
||||
protocomm_ble_event_t ble_event = {};
|
||||
/* Assign the event type */
|
||||
ble_event.evt_type = PROTOCOMM_TRANSPORT_BLE_DISCONNECTED;
|
||||
/* Set the Disconnection handle */
|
||||
ble_event.conn_handle = param->disconnect.conn_id;
|
||||
|
||||
if (esp_event_post(PROTOCOMM_TRANSPORT_BLE_EVENT, PROTOCOMM_TRANSPORT_BLE_DISCONNECTED, &ble_event, sizeof(protocomm_ble_event_t), portMAX_DELAY) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to post transport disconnection event");
|
||||
}
|
||||
}
|
||||
@ -371,7 +377,13 @@ static void transport_simple_ble_connect(esp_gatts_cb_event_t event, esp_gatt_if
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "error creating the session");
|
||||
} else {
|
||||
if (esp_event_post(PROTOCOMM_TRANSPORT_BLE_EVENT, PROTOCOMM_TRANSPORT_BLE_CONNECTED, NULL, 0, portMAX_DELAY) != ESP_OK) {
|
||||
protocomm_ble_event_t ble_event = {};
|
||||
/* Assign the event type */
|
||||
ble_event.evt_type = PROTOCOMM_TRANSPORT_BLE_CONNECTED;
|
||||
/* Set the Connection handle */
|
||||
ble_event.conn_handle = param->connect.conn_id;
|
||||
|
||||
if (esp_event_post(PROTOCOMM_TRANSPORT_BLE_EVENT, PROTOCOMM_TRANSPORT_BLE_CONNECTED, &ble_event, sizeof(protocomm_ble_event_t), portMAX_DELAY) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to post transport pairing event");
|
||||
}
|
||||
}
|
||||
|
@ -569,7 +569,14 @@ static void transport_simple_ble_disconnect(struct ble_gap_event *event, void *a
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "error closing the session after disconnect");
|
||||
} else {
|
||||
if (esp_event_post(PROTOCOMM_TRANSPORT_BLE_EVENT, PROTOCOMM_TRANSPORT_BLE_DISCONNECTED, NULL, 0, portMAX_DELAY) != ESP_OK) {
|
||||
protocomm_ble_event_t ble_event = {};
|
||||
/* Assign the event type */
|
||||
ble_event.evt_type = PROTOCOMM_TRANSPORT_BLE_DISCONNECTED;
|
||||
/* Set the Disconnection handle */
|
||||
ble_event.conn_handle = event->disconnect.conn.conn_handle;
|
||||
ble_event.disconnect_reason = event->disconnect.reason;
|
||||
|
||||
if (esp_event_post(PROTOCOMM_TRANSPORT_BLE_EVENT, PROTOCOMM_TRANSPORT_BLE_DISCONNECTED, &ble_event, sizeof(protocomm_ble_event_t), portMAX_DELAY) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to post transport disconnection event");
|
||||
}
|
||||
}
|
||||
@ -595,7 +602,14 @@ static void transport_simple_ble_connect(struct ble_gap_event *event, void *arg)
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "error creating the session");
|
||||
} else {
|
||||
if (esp_event_post(PROTOCOMM_TRANSPORT_BLE_EVENT, PROTOCOMM_TRANSPORT_BLE_CONNECTED, NULL, 0, portMAX_DELAY) != ESP_OK) {
|
||||
protocomm_ble_event_t ble_event = {};
|
||||
/* Assign the event type */
|
||||
ble_event.evt_type = PROTOCOMM_TRANSPORT_BLE_CONNECTED;
|
||||
/* Set the Connection handle */
|
||||
ble_event.conn_handle = event->connect.conn_handle;
|
||||
ble_event.conn_status = event->connect.status;
|
||||
|
||||
if (esp_event_post(PROTOCOMM_TRANSPORT_BLE_EVENT, PROTOCOMM_TRANSPORT_BLE_CONNECTED, &ble_event, sizeof(protocomm_ble_event_t), portMAX_DELAY) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to post transport pairing event");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user