Skip to content

Commit

Permalink
Merge branch 'refactor/ble_example_print_on_bluedroid' into 'master'
Browse files Browse the repository at this point in the history
refactor(bt/bluedroid): Refactor the print for BLE examples

Closes BLERP-904, BLERP-910, BLERP-1026, and BLERP-1031

See merge request espressif/esp-idf!33296
  • Loading branch information
Isl2017 committed Sep 18, 2024
2 parents cb2624f + 53a8345 commit 5f865a8
Show file tree
Hide file tree
Showing 37 changed files with 561 additions and 400 deletions.
26 changes: 15 additions & 11 deletions examples/bluetooth/bluedroid/ble/ble_ibeacon/main/ibeacon_demo.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
Expand Down Expand Up @@ -82,13 +82,17 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
case ESP_GAP_BLE_SCAN_START_COMPLETE_EVT:
//scan start complete event to indicate scan start successfully or failed
if ((err = param->scan_start_cmpl.status) != ESP_BT_STATUS_SUCCESS) {
ESP_LOGE(DEMO_TAG, "Scan start failed: %s", esp_err_to_name(err));
ESP_LOGE(DEMO_TAG, "Scanning start failed, error %s", esp_err_to_name(err));
} else {
ESP_LOGI(DEMO_TAG, "Scanning start successfully");
}
break;
case ESP_GAP_BLE_ADV_START_COMPLETE_EVT:
//adv start complete event to indicate adv start successfully or failed
if ((err = param->adv_start_cmpl.status) != ESP_BT_STATUS_SUCCESS) {
ESP_LOGE(DEMO_TAG, "Adv start failed: %s", esp_err_to_name(err));
ESP_LOGE(DEMO_TAG, "Advertising start failed, error %s", esp_err_to_name(err));
} else {
ESP_LOGI(DEMO_TAG, "Advertising start successfully");
}
break;
case ESP_GAP_BLE_SCAN_RESULT_EVT: {
Expand All @@ -99,15 +103,15 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
if (esp_ble_is_ibeacon_packet(scan_result->scan_rst.ble_adv, scan_result->scan_rst.adv_data_len)){
esp_ble_ibeacon_t *ibeacon_data = (esp_ble_ibeacon_t*)(scan_result->scan_rst.ble_adv);
ESP_LOGI(DEMO_TAG, "----------iBeacon Found----------");
ESP_LOG_BUFFER_HEX("IBEACON_DEMO: Device address:", scan_result->scan_rst.bda, ESP_BD_ADDR_LEN );
ESP_LOG_BUFFER_HEX("IBEACON_DEMO: Proximity UUID:", ibeacon_data->ibeacon_vendor.proximity_uuid, ESP_UUID_LEN_128);
ESP_LOGI(DEMO_TAG, "Device address: "ESP_BD_ADDR_STR"", ESP_BD_ADDR_HEX(scan_result->scan_rst.bda));
ESP_LOG_BUFFER_HEX("IBEACON_DEMO: Proximity UUID", ibeacon_data->ibeacon_vendor.proximity_uuid, ESP_UUID_LEN_128);

uint16_t major = ENDIAN_CHANGE_U16(ibeacon_data->ibeacon_vendor.major);
uint16_t minor = ENDIAN_CHANGE_U16(ibeacon_data->ibeacon_vendor.minor);
ESP_LOGI(DEMO_TAG, "Major: 0x%04x (%d)", major, major);
ESP_LOGI(DEMO_TAG, "Minor: 0x%04x (%d)", minor, minor);
ESP_LOGI(DEMO_TAG, "Measured power (RSSI at a 1m distance):%d dbm", ibeacon_data->ibeacon_vendor.measured_power);
ESP_LOGI(DEMO_TAG, "RSSI of packet:%d dbm", scan_result->scan_rst.rssi);
ESP_LOGI(DEMO_TAG, "Measured power (RSSI at a 1m distance): %d dBm", ibeacon_data->ibeacon_vendor.measured_power);
ESP_LOGI(DEMO_TAG, "RSSI of packet: %d dbm", scan_result->scan_rst.rssi);
}
break;
default:
Expand All @@ -118,19 +122,19 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par

case ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT:
if ((err = param->scan_stop_cmpl.status) != ESP_BT_STATUS_SUCCESS){
ESP_LOGE(DEMO_TAG, "Scan stop failed: %s", esp_err_to_name(err));
ESP_LOGE(DEMO_TAG, "Scanning stop failed, error %s", esp_err_to_name(err));
}
else {
ESP_LOGI(DEMO_TAG, "Stop scan successfully");
ESP_LOGI(DEMO_TAG, "Scanning stop successfully");
}
break;

case ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT:
if ((err = param->adv_stop_cmpl.status) != ESP_BT_STATUS_SUCCESS){
ESP_LOGE(DEMO_TAG, "Adv stop failed: %s", esp_err_to_name(err));
ESP_LOGE(DEMO_TAG, "Advertising stop failed, error %s", esp_err_to_name(err));
}
else {
ESP_LOGI(DEMO_TAG, "Stop adv successfully");
ESP_LOGI(DEMO_TAG, "Advertising stop successfully");
}
break;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
menu "Example 'GATT CLIENT THROUGHPUT' Config"

config GATTS_NOTIFY_THROUGHPUT
config EXAMPLE_GATTS_NOTIFY_THROUGHPUT
bool "test the gatts notify throughput"
help
If this config item is set, then the 'GATTC_WRITE_THROUGHPUT' config should be close, it can't test both
write or notify at the same time at this demo
If this config item is set, then the 'EXAMPLE_GATTC_WRITE_THROUGHPUT' config should be close,
it can't test both write or notify at the same time at this demo

config GATTC_WRITE_THROUGHPUT
config EXAMPLE_GATTC_WRITE_THROUGHPUT
bool "test the gattc write throughput"
help
If this config item is set, then the 'GATTS_NOTIFY_THROUGHPUT' config should be close, it can't test both
write or notify at the same time at this demo
If this config item is set, then the 'EXAMPLE_GATTS_NOTIFY_THROUGHPUT' config should be close,
it can't test both write or notify at the same time at this demo

config EXAMPLE_CI_ID
int
default 60
help
This config the example id for CI test. Only for internal used.

config EXAMPLE_CI_PIPELINE_ID
int "The pipeline id for CI test"
default 0
help
This config the pipeline id for CI test. Only for internal used.

endmenu
Loading

0 comments on commit 5f865a8

Please sign in to comment.