mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-03 03:31:41 +03:00
fix(nimble): Fix for clang compilation issues
This commit is contained in:
+17
-17
@@ -1,9 +1,10 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
@@ -325,23 +326,22 @@ static int light_sleep(int argc, char **argv)
|
||||
fflush(stdout);
|
||||
uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
|
||||
esp_light_sleep_start();
|
||||
esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();
|
||||
const char *cause_str;
|
||||
switch (cause) {
|
||||
case ESP_SLEEP_WAKEUP_GPIO:
|
||||
cause_str = "GPIO";
|
||||
break;
|
||||
case ESP_SLEEP_WAKEUP_UART:
|
||||
cause_str = "UART";
|
||||
break;
|
||||
case ESP_SLEEP_WAKEUP_TIMER:
|
||||
cause_str = "timer";
|
||||
break;
|
||||
default:
|
||||
cause_str = "unknown";
|
||||
printf("%d\n", cause);
|
||||
|
||||
uint32_t causes = esp_sleep_get_wakeup_causes();
|
||||
if (causes & BIT(ESP_SLEEP_WAKEUP_UNDEFINED)) {
|
||||
ESP_LOGI(TAG, "Woke up from: unknown");
|
||||
printf("%" PRIx32 "\n", causes);
|
||||
return 0;
|
||||
}
|
||||
if (causes & BIT(ESP_SLEEP_WAKEUP_GPIO)) {
|
||||
ESP_LOGI(TAG, "Woke up from: GPIO");
|
||||
}
|
||||
if (causes & BIT(ESP_SLEEP_WAKEUP_UART)) {
|
||||
ESP_LOGI(TAG, "Woke up from: UART");
|
||||
}
|
||||
if (causes & BIT(ESP_SLEEP_WAKEUP_TIMER)) {
|
||||
ESP_LOGI(TAG, "Woke up from: timer");
|
||||
}
|
||||
ESP_LOGI(TAG, "Woke up from: %s", cause_str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,10 @@ union ble_store_key;
|
||||
#define BLECENT_CHR_UNR_ALERT_STAT_UUID 0x2A45
|
||||
#define BLECENT_CHR_ALERT_NOT_CTRL_PT 0x2A44
|
||||
|
||||
#define PEER_ADDR_VAL_SIZE 6
|
||||
|
||||
/** Misc. */
|
||||
int peer_addr_parse(const char *addr_str, uint8_t addr[PEER_ADDR_VAL_SIZE]);
|
||||
void print_bytes(const uint8_t *bytes, int len);
|
||||
void print_mbuf(const struct os_mbuf *om);
|
||||
char *addr_str(const void *addr);
|
||||
|
||||
@@ -570,7 +570,7 @@ ext_blecent_should_connect(const struct ble_gap_ext_disc_desc *disc)
|
||||
int offset = 0;
|
||||
int ad_struct_len = 0;
|
||||
uint8_t test_addr[6];
|
||||
uint32_t peer_addr[6];
|
||||
uint8_t parsed_addr[6];
|
||||
uint8_t phy_uuid_found = 0;
|
||||
if (disc->legacy_event_type != BLE_HCI_ADV_RPT_EVTYPE_ADV_IND &&
|
||||
disc->legacy_event_type != BLE_HCI_ADV_RPT_EVTYPE_DIR_IND) {
|
||||
@@ -579,13 +579,9 @@ ext_blecent_should_connect(const struct ble_gap_ext_disc_desc *disc)
|
||||
if (strlen(CONFIG_EXAMPLE_PEER_ADDR) && (strncmp(CONFIG_EXAMPLE_PEER_ADDR, "ADDR_ANY", strlen("ADDR_ANY")) != 0)) {
|
||||
// ESP_LOGI(tag, "Peer address from menuconfig: %s", CONFIG_EXAMPLE_PEER_ADDR);
|
||||
/* Convert string to address */
|
||||
sscanf(CONFIG_EXAMPLE_PEER_ADDR, "%lx:%lx:%lx:%lx:%lx:%lx",
|
||||
&peer_addr[5], &peer_addr[4], &peer_addr[3],
|
||||
&peer_addr[2], &peer_addr[1], &peer_addr[0]);
|
||||
|
||||
/* Conversion */
|
||||
for (int i=0; i<6; i++) {
|
||||
test_addr[5 - i] = (uint8_t )peer_addr[i];
|
||||
peer_addr_parse(CONFIG_EXAMPLE_PEER_ADDR, parsed_addr);
|
||||
for (int i = 0; i < 6; i++) {
|
||||
test_addr[5 - i] = parsed_addr[i];
|
||||
}
|
||||
if (memcmp(test_addr, disc->addr.val, sizeof(disc->addr.val)) != 0) {
|
||||
return 0;
|
||||
@@ -641,10 +637,6 @@ blecent_should_connect(const struct ble_gap_disc_desc *disc)
|
||||
int rc;
|
||||
int i;
|
||||
uint8_t test_addr[6];
|
||||
uint32_t peer_addr[6];
|
||||
|
||||
memset(peer_addr, 0x0, sizeof peer_addr);
|
||||
|
||||
rc = ble_hs_adv_parse_fields(&fields, disc->data, disc->length_data);
|
||||
if (rc != 0) {
|
||||
return 0;
|
||||
@@ -653,15 +645,7 @@ blecent_should_connect(const struct ble_gap_disc_desc *disc)
|
||||
if (strlen(CONFIG_EXAMPLE_PEER_ADDR) && (strncmp(CONFIG_EXAMPLE_PEER_ADDR, "ADDR_ANY", strlen("ADDR_ANY")) != 0)) {
|
||||
ESP_LOGI(tag, "Peer address from menuconfig: %s", CONFIG_EXAMPLE_PEER_ADDR);
|
||||
/* Convert string to address */
|
||||
sscanf(CONFIG_EXAMPLE_PEER_ADDR, "%lx:%lx:%lx:%lx:%lx:%lx",
|
||||
&peer_addr[5], &peer_addr[4], &peer_addr[3],
|
||||
&peer_addr[2], &peer_addr[1], &peer_addr[0]);
|
||||
|
||||
/* Conversion */
|
||||
for (int i=0; i<6; i++) {
|
||||
test_addr[i] = (uint8_t )peer_addr[i];
|
||||
}
|
||||
|
||||
peer_addr_parse(CONFIG_EXAMPLE_PEER_ADDR, test_addr);
|
||||
if (memcmp(test_addr, disc->addr.val, sizeof(disc->addr.val)) != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -11,6 +11,17 @@
|
||||
#include "host/ble_uuid.h"
|
||||
#include "gattc.h"
|
||||
|
||||
int
|
||||
peer_addr_parse(const char *addr_str, uint8_t addr[PEER_ADDR_VAL_SIZE])
|
||||
{
|
||||
if (addr_str == NULL) {
|
||||
return 0;
|
||||
}
|
||||
return sscanf(addr_str, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
|
||||
&addr[5], &addr[4], &addr[3],
|
||||
&addr[2], &addr[1], &addr[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to log an array of bytes.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user