fix(nimble): Fix for clang compilation issues

This commit is contained in:
Rahul Tank
2026-06-04 21:51:56 +05:30
parent 424a685692
commit 804755b4f8
21 changed files with 98 additions and 218 deletions
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
@@ -331,7 +332,7 @@ static int light_sleep(int argc, char **argv)
uint32_t causes = esp_sleep_get_wakeup_causes();
if (causes & BIT(ESP_SLEEP_WAKEUP_UNDEFINED)) {
ESP_LOGI(TAG, "Woke up from: unknown");
printf("%lx\n", causes);
printf("%" PRIx32 "\n", causes);
return 0;
}
if (causes & BIT(ESP_SLEEP_WAKEUP_GPIO)) {
@@ -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 &&
@@ -580,13 +580,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;
@@ -646,10 +642,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;
@@ -658,15 +650,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.
*/