fix(nimble): Address compilation issues in nimble examples

This commit is contained in:
Rahul Tank
2025-11-26 14:35:51 +05:30
parent e6b82fa4a0
commit 8f8be6cb18
34 changed files with 173 additions and 32 deletions
@@ -26,6 +26,7 @@ uint16_t attribute_handle[CONFIG_BT_NIMBLE_MAX_CONNECTIONS + 1];
static void ble_spp_client_scan(void);
static ble_addr_t connected_addr[CONFIG_BT_NIMBLE_MAX_CONNECTIONS + 1];
#if MYNEWT_VAL(BLE_GATTC)
static void ble_spp_client_write_subscribe(const struct peer *peer)
{
uint8_t value[2];
@@ -90,7 +91,6 @@ ble_spp_client_set_handle(const struct peer *peer)
value, sizeof(value), NULL, NULL);
}
/**
* Called when service discovery of the specified peer has completed.
*/
@@ -119,6 +119,7 @@ ble_spp_client_on_disc_complete(const struct peer *peer, int status, void *arg)
ble_spp_client_scan();
#endif
}
#endif
/**
* Initiates the GAP general discovery procedure.
@@ -306,6 +307,7 @@ ble_spp_client_gap_event(struct ble_gap_event *event, void *arg)
return 0;
}
#if MYNEWT_VAL(BLE_GATTC)
/* Perform service discovery. */
rc = peer_disc_all(event->connect.conn_handle,
ble_spp_client_on_disc_complete, NULL);
@@ -313,6 +315,7 @@ ble_spp_client_gap_event(struct ble_gap_event *event, void *arg)
MODLOG_DFLT(ERROR, "Failed to discover services; rc=%d\n", rc);
return 0;
}
#endif
} else {
/* Connection attempt failed; resume scanning. */
MODLOG_DFLT(ERROR, "Error: Connection failed; status=%d\n",
@@ -421,12 +424,14 @@ void ble_client_uart_task(void *pvParameters)
uart_read_bytes(UART_NUM_0, temp, event.size, portMAX_DELAY);
for ( i = 0; i <= CONFIG_BT_NIMBLE_MAX_CONNECTIONS; i++) {
if (attribute_handle[i] != 0) {
#if MYNEWT_VAL(BLE_GATTC)
rc = ble_gattc_write_flat(i, attribute_handle[i], temp, event.size, NULL, NULL);
if (rc == 0) {
ESP_LOGI(tag, "Write in uart task success!");
} else {
ESP_LOGI(tag, "Error in writing characteristic rc=%d", rc);
}
#endif
vTaskDelay(10);
}
}
@@ -63,7 +63,6 @@ ble_spp_server_advertise(void)
{
struct ble_gap_adv_params adv_params;
struct ble_hs_adv_fields fields;
const char *name;
int rc;
/**
@@ -90,6 +89,7 @@ ble_spp_server_advertise(void)
fields.tx_pwr_lvl_is_present = 1;
fields.tx_pwr_lvl = BLE_HS_ADV_TX_PWR_LVL_AUTO;
const char *name;
name = ble_svc_gap_device_name();
fields.name = (uint8_t *)name;
fields.name_len = strlen(name);
@@ -412,8 +412,6 @@ static void ble_spp_uart_init(void)
void
app_main(void)
{
int rc;
/* Initialize NVS — it is used to store PHY calibration data */
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
@@ -459,6 +457,8 @@ app_main(void)
ble_hs_cfg.sm_their_key_dist = 1;
#endif
#if MYNEWT_VAL(BLE_GATTS)
int rc;
/* Register custom service */
rc = gatt_svr_init();
assert(rc == 0);
@@ -466,6 +466,7 @@ app_main(void)
/* Set the default device name. */
rc = ble_svc_gap_device_name_set("nimble-ble-spp-svr");
assert(rc == 0);
#endif
/* XXX Need to have template for store */
ble_store_config_init();