Skip to content

Commit

Permalink
fix(nimble): Replace ESP_LOG* with esp_rom_printf in controller conte…
Browse files Browse the repository at this point in the history
…xt callback
  • Loading branch information
rahult-github committed Nov 19, 2024
1 parent 0f4b994 commit c2a34ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions components/bt/host/nimble/esp-hci/src/esp_nimble_hci.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ static void ble_hci_rx_acl(uint8_t *data, uint16_t len)
m = ble_transport_alloc_acl_from_ll();

if (!m) {
ESP_LOGD(TAG,"Failed to allocate buffer, retrying ");
esp_rom_printf("Failed to allocate buffer, retrying ");
/* Give some time to free buffer and try again */
vTaskDelay(1);
}
}while(!m);

if ((rc = os_mbuf_append(m, data, len)) != 0) {
ESP_LOGE(TAG, "%s failed to os_mbuf_append; rc = %d", __func__, rc);
esp_rom_printf("%s failed to os_mbuf_append; rc = %d", __func__, rc);
os_mbuf_free_chain(m);
return;
}
Expand Down Expand Up @@ -223,7 +223,7 @@ static int host_rcv_pkt(uint8_t *data, uint16_t len)

if(!ble_hs_enabled_state) {
/* If host is not enabled, drop the packet */
ESP_LOGE(TAG, "Host not enabled. Dropping the packet!");
esp_rom_printf("Host not enabled. Dropping the packet!");
return 0;
}

Expand All @@ -236,7 +236,7 @@ static int host_rcv_pkt(uint8_t *data, uint16_t len)
assert(totlen <= UINT8_MAX + BLE_HCI_EVENT_HDR_LEN);

if (totlen > MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE)) {
ESP_LOGE(TAG, "Received HCI data length at host (%d) exceeds maximum configured HCI event buffer size (%d).",
esp_rom_printf("Received HCI data length at host (%d) exceeds maximum configured HCI event buffer size (%d).",
totlen, MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE));
ble_hs_sched_reset(BLE_HS_ECONTROLLER);
return 0;
Expand Down
14 changes: 7 additions & 7 deletions examples/bluetooth/hci/ble_adv_scan_combined/main/app_bt.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* BLE Combined Advertising and Scanning Example.
*
* SPDX-FileCopyrightText: 2021-2022 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 @@ -56,27 +56,27 @@ static int host_rcv_pkt(uint8_t *data, uint16_t len)
host_rcv_data_t send_data;
uint8_t *data_pkt;
/* Check second byte for HCI event. If event opcode is 0x0e, the event is
* HCI Command Complete event. Sice we have recieved "0x0e" event, we can
* HCI Command Complete event. Sice we have received "0x0e" event, we can
* check for byte 4 for command opcode and byte 6 for it's return status. */
if (data[1] == 0x0e) {
if (data[6] == 0) {
ESP_LOGI(TAG, "Event opcode 0x%02x success.", data[4]);
esp_rom_printf("Event opcode 0x%02x success.", data[4]);
} else {
ESP_LOGE(TAG, "Event opcode 0x%02x fail with reason: 0x%02x.", data[4], data[6]);
esp_rom_printf("Event opcode 0x%02x fail with reason: 0x%02x.", data[4], data[6]);
return ESP_FAIL;
}
}

data_pkt = (uint8_t *)malloc(sizeof(uint8_t) * len);
if (data_pkt == NULL) {
ESP_LOGE(TAG, "Malloc data_pkt failed!");
esp_rom_printf("Malloc data_pkt failed!");
return ESP_FAIL;
}
memcpy(data_pkt, data, len);
send_data.q_data = data_pkt;
send_data.q_data_len = len;
if (xQueueSend(adv_queue, (void *)&send_data, ( TickType_t ) 0) != pdTRUE) {
ESP_LOGD(TAG, "Failed to enqueue advertising report. Queue full.");
esp_rom_printf("Failed to enqueue advertising report. Queue full.");
/* If data sent successfully, then free the pointer in `xQueueReceive'
* after processing it. Or else if enqueue in not successful, free it
* here. */
Expand Down Expand Up @@ -114,7 +114,7 @@ static void hci_cmd_send_ble_scan_params(void)
uint16_t scan_window = 0x30; /* 30 ms */

uint8_t own_addr_type = 0x00; /* Public Device Address (default). */
uint8_t filter_policy = 0x00; /* Accept all packets excpet directed advertising packets (default). */
uint8_t filter_policy = 0x00; /* Accept all packets except directed advertising packets (default). */
uint16_t sz = make_cmd_ble_set_scan_params(hci_cmd_buf, scan_type, scan_interval, scan_window, own_addr_type, filter_policy);
esp_vhci_host_send_packet(hci_cmd_buf, sz);
}
Expand Down

0 comments on commit c2a34ad

Please sign in to comment.