From 093b674703629ca133a6f8a630d9614577504498 Mon Sep 17 00:00:00 2001 From: h2zero Date: Thu, 6 Apr 2023 09:11:34 -0600 Subject: [PATCH] Update to esp-nimble (1.4.0 branch) @0fc6282 --- .../esp_port/port/include/esp_nimble_cfg.h | 4 ++ src/nimble/nimble/host/include/host/ble_gap.h | 12 ++++ src/nimble/nimble/host/mesh/src/adv.c | 8 +++ src/nimble/nimble/host/mesh/src/cfg_srv.c | 8 +++ src/nimble/nimble/host/mesh/src/glue.c | 8 +++ src/nimble/nimble/host/mesh/src/proxy.c | 8 +++ src/nimble/nimble/host/mesh/src/transport.c | 8 +++ src/nimble/nimble/host/src/ble_att.c | 9 +++ src/nimble/nimble/host/src/ble_att_clt.c | 11 +++- src/nimble/nimble/host/src/ble_att_svr.c | 5 +- src/nimble/nimble/host/src/ble_gap.c | 18 ++++++ src/nimble/nimble/host/src/ble_gattc.c | 9 +++ src/nimble/nimble/host/src/ble_hs_hci.c | 9 ++- src/nimble/nimble/host/src/ble_hs_hci_util.c | 8 +++ src/nimble/nimble/host/src/ble_hs_resolv.c | 22 ++----- src/nimble/nimble/host/src/ble_l2cap_coc.c | 8 +++ src/nimble/nimble/host/src/ble_sm.c | 9 +++ .../nimble/include/nimble/nimble_port.h | 27 +++++++-- src/nimble/porting/nimble/include/os/os.h | 8 --- .../porting/nimble/include/syscfg/syscfg.h | 4 ++ src/nimble/porting/nimble/src/nimble_port.c | 60 +++++++++++++++---- src/nimble/porting/nimble/src/os_mbuf.c | 8 +++ 22 files changed, 226 insertions(+), 45 deletions(-) diff --git a/src/nimble/esp_port/port/include/esp_nimble_cfg.h b/src/nimble/esp_port/port/include/esp_nimble_cfg.h index fb00ae11..44c6fd4a 100644 --- a/src/nimble/esp_port/port/include/esp_nimble_cfg.h +++ b/src/nimble/esp_port/port/include/esp_nimble_cfg.h @@ -451,6 +451,10 @@ #define MYNEWT_VAL_BLE_GATT_WRITE_RELIABLE (MYNEWT_VAL_BLE_ROLE_CENTRAL) #endif +#ifndef MYNEWT_VAL_BLE_GATT_BLOB_TRANSFER +#define MYNEWT_VAL_BLE_GATT_BLOB_TRANSFER (0) +#endif + #ifndef MYNEWT_VAL_BLE_HOST #define MYNEWT_VAL_BLE_HOST (1) #endif diff --git a/src/nimble/nimble/host/include/host/ble_gap.h b/src/nimble/nimble/host/include/host/ble_gap.h index e75dd73c..58225eae 100644 --- a/src/nimble/nimble/host/include/host/ble_gap.h +++ b/src/nimble/nimble/host/include/host/ble_gap.h @@ -1443,6 +1443,18 @@ int ble_gap_ext_adv_remove(uint8_t instance); * other error code on failure. */ int ble_gap_ext_adv_clear(void); + +/** + * Indicates whether an advertisement procedure is currently in progress on + * the specified Instance + * + * @param instance Instance Id + * + * @return 0 if there is no active advertising procedure for the instance, + * 1 otherwise + * + */ +int ble_gap_ext_adv_active(uint8_t instance); #endif /* Periodic Advertising */ diff --git a/src/nimble/nimble/host/mesh/src/adv.c b/src/nimble/nimble/host/mesh/src/adv.c index 95960ddb..f1f86cf5 100644 --- a/src/nimble/nimble/host/mesh/src/adv.c +++ b/src/nimble/nimble/host/mesh/src/adv.c @@ -40,6 +40,14 @@ #define ADV_INT_DEFAULT_MS 100 #define ADV_INT_FAST_MS 20 +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + static int32_t adv_int_min = ADV_INT_DEFAULT_MS; /* TinyCrypt PRNG consumes a lot of stack space, so we need to have diff --git a/src/nimble/nimble/host/mesh/src/cfg_srv.c b/src/nimble/nimble/host/mesh/src/cfg_srv.c index 14ada332..fe7501fd 100644 --- a/src/nimble/nimble/host/mesh/src/cfg_srv.c +++ b/src/nimble/nimble/host/mesh/src/cfg_srv.c @@ -34,6 +34,14 @@ #include "settings.h" #include "cfg.h" +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + void (*bt_mesh_app_key_cb_list[1]) (uint16_t app_idx, uint16_t net_idx, enum bt_mesh_key_evt evt); diff --git a/src/nimble/nimble/host/mesh/src/glue.c b/src/nimble/nimble/host/mesh/src/glue.c index 34d46cfd..980921f6 100644 --- a/src/nimble/nimble/host/mesh/src/glue.c +++ b/src/nimble/nimble/host/mesh/src/glue.c @@ -41,6 +41,14 @@ extern uint8_t g_mesh_addr_type; static struct ble_gap_adv_params ble_adv_cur_conf[2]; #endif +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + const char * bt_hex(const void *buf, size_t len) { diff --git a/src/nimble/nimble/host/mesh/src/proxy.c b/src/nimble/nimble/host/mesh/src/proxy.c index bfd0336b..50214dfd 100644 --- a/src/nimble/nimble/host/mesh/src/proxy.c +++ b/src/nimble/nimble/host/mesh/src/proxy.c @@ -90,6 +90,14 @@ ble_uuid16_t BT_UUID_MESH_PROXY_DATA_OUT = BLE_UUID16_INIT(0x2ade); #define CLIENT_BUF_SIZE 68 +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + static const struct ble_gap_adv_params slow_adv_param = { .conn_mode = (BLE_GAP_CONN_MODE_UND), .disc_mode = (BLE_GAP_DISC_MODE_GEN), diff --git a/src/nimble/nimble/host/mesh/src/transport.c b/src/nimble/nimble/host/mesh/src/transport.c index 8ec7dcfe..0b08289c 100644 --- a/src/nimble/nimble/host/mesh/src/transport.c +++ b/src/nimble/nimble/host/mesh/src/transport.c @@ -70,6 +70,14 @@ /* How long to wait for available buffers before giving up */ #define BUF_TIMEOUT K_NO_WAIT +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + static struct seg_tx { struct bt_mesh_subnet *sub; void *seg[CONFIG_BT_MESH_TX_SEG_MAX]; diff --git a/src/nimble/nimble/host/src/ble_att.c b/src/nimble/nimble/host/src/ble_att.c index 8aab7f91..b8484e51 100644 --- a/src/nimble/nimble/host/src/ble_att.c +++ b/src/nimble/nimble/host/src/ble_att.c @@ -22,6 +22,15 @@ #include "ble_hs_priv.h" #if NIMBLE_BLE_CONNECT + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + static uint16_t ble_att_preferred_mtu_val; /** Dispatch table for incoming ATT requests. Sorted by op code. */ diff --git a/src/nimble/nimble/host/src/ble_att_clt.c b/src/nimble/nimble/host/src/ble_att_clt.c index 938b8a6a..43cf3843 100644 --- a/src/nimble/nimble/host/src/ble_att_clt.c +++ b/src/nimble/nimble/host/src/ble_att_clt.c @@ -707,6 +707,8 @@ ble_att_clt_tx_write_cmd(uint16_t conn_handle, uint16_t handle, struct ble_att_write_cmd *cmd; struct os_mbuf *txom2; + +#if MYNEWT_VAL(BLE_HS_DEBUG) uint8_t b; int rc; int i; @@ -720,7 +722,7 @@ ble_att_clt_tx_write_cmd(uint16_t conn_handle, uint16_t handle, assert(rc == 0); BLE_HS_LOG(DEBUG, "0x%02x", b); } - +#endif cmd = ble_att_cmd_get(BLE_ATT_OP_WRITE_CMD, sizeof(*cmd), &txom2); if (cmd == NULL) { @@ -767,10 +769,17 @@ ble_att_clt_tx_prep_write(uint16_t conn_handle, uint16_t handle, goto err; } +#if MYNEWT_VAL(BLE_GATT_BLOB_TRANSFER) + if (OS_MBUF_PKTLEN(txom) > BLE_ATT_ATTR_MAX_LEN) { + rc = BLE_HS_EINVAL; + goto err; + } +#else if (offset + OS_MBUF_PKTLEN(txom) > BLE_ATT_ATTR_MAX_LEN) { rc = BLE_HS_EINVAL; goto err; } +#endif if (OS_MBUF_PKTLEN(txom) > ble_att_mtu(conn_handle) - BLE_ATT_PREP_WRITE_CMD_BASE_SZ) { diff --git a/src/nimble/nimble/host/src/ble_att_svr.c b/src/nimble/nimble/host/src/ble_att_svr.c index fb96c72f..76388b79 100644 --- a/src/nimble/nimble/host/src/ble_att_svr.c +++ b/src/nimble/nimble/host/src/ble_att_svr.c @@ -2133,7 +2133,9 @@ ble_att_svr_prep_validate(struct ble_att_prep_entry_list *prep_list, { struct ble_att_prep_entry *entry; struct ble_att_prep_entry *prev; +#if !MYNEWT_VAL(BLE_GATT_BLOB_TRANSFER) int cur_len; +#endif prev = NULL; SLIST_FOREACH(entry, prep_list, bape_next) { @@ -2153,12 +2155,13 @@ ble_att_svr_prep_validate(struct ble_att_prep_entry_list *prep_list, } } +#if !MYNEWT_VAL(BLE_GATT_BLOB_TRANSFER) cur_len = entry->bape_offset + OS_MBUF_PKTLEN(entry->bape_value); if (cur_len > BLE_ATT_ATTR_MAX_LEN) { *err_handle = entry->bape_handle; return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN; } - +#endif prev = entry; } diff --git a/src/nimble/nimble/host/src/ble_gap.c b/src/nimble/nimble/host/src/ble_gap.c index fffe74b3..a8f55e6a 100644 --- a/src/nimble/nimble/host/src/ble_gap.c +++ b/src/nimble/nimble/host/src/ble_gap.c @@ -26,6 +26,14 @@ #include "ble_hs_priv.h" #include "ble_hs_resolv_priv.h" +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + #if MYNEWT #include "bsp/bsp.h" #else @@ -1445,6 +1453,16 @@ ble_gap_adv_active_instance(uint8_t instance) } #endif +#if MYNEWT_VAL(BLE_EXT_ADV) +int ble_gap_ext_adv_active(uint8_t instance) +{ + if (instance >= BLE_ADV_INSTANCES) { + return 0; + } + return ble_gap_adv_active_instance(instance); +} +#endif + /** * Clears advertisement and discovery state. This function is necessary * when the controller loses its active state (e.g. on stack reset). diff --git a/src/nimble/nimble/host/src/ble_gattc.c b/src/nimble/nimble/host/src/ble_gattc.c index c0d79c89..13bcfdc8 100644 --- a/src/nimble/nimble/host/src/ble_gattc.c +++ b/src/nimble/nimble/host/src/ble_gattc.c @@ -61,6 +61,15 @@ #include "ble_hs_priv.h" #if NIMBLE_BLE_CONNECT + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + /***************************************************************************** * $definitions / declarations * *****************************************************************************/ diff --git a/src/nimble/nimble/host/src/ble_hs_hci.c b/src/nimble/nimble/host/src/ble_hs_hci.c index 4b1bd6d7..bf9d1bef 100644 --- a/src/nimble/nimble/host/src/ble_hs_hci.c +++ b/src/nimble/nimble/host/src/ble_hs_hci.c @@ -407,6 +407,7 @@ ble_hs_hci_rx_evt(uint8_t *hci_ev, void *arg) return 0; } +#if !(SOC_ESP_NIMBLE_CONTROLLER) /** * Calculates the largest ACL payload that the controller can accept. */ @@ -420,6 +421,7 @@ ble_hs_hci_max_acl_payload_sz(void) */ return ble_hs_hci_buf_sz; } +#endif /** * Allocates an mbuf to contain an outgoing ACL data fragment. @@ -524,8 +526,11 @@ ble_hs_hci_acl_tx_now(struct ble_hs_conn *conn, struct os_mbuf **om) /* Send fragments until the entire packet has been sent. */ while (txom != NULL && ble_hs_hci_avail_pkts > 0) { - frag = mem_split_frag(&txom, ble_hs_hci_max_acl_payload_sz(), - ble_hs_hci_frag_alloc, NULL); +#if SOC_ESP_NIMBLE_CONTROLLER + frag = mem_split_frag(&txom, BLE_ACL_MAX_PKT_SIZE, ble_hs_hci_frag_alloc, NULL); +#else + frag = mem_split_frag(&txom, ble_hs_hci_max_acl_payload_sz(), ble_hs_hci_frag_alloc, NULL); +#endif if (frag == NULL) { *om = txom; return BLE_HS_EAGAIN; diff --git a/src/nimble/nimble/host/src/ble_hs_hci_util.c b/src/nimble/nimble/host/src/ble_hs_hci_util.c index d5d50585..f583c85e 100644 --- a/src/nimble/nimble/host/src/ble_hs_hci_util.c +++ b/src/nimble/nimble/host/src/ble_hs_hci_util.c @@ -22,6 +22,14 @@ #include "nimble/nimble/host/include/host/ble_hs_hci.h" #include "ble_hs_priv.h" +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + uint16_t ble_hs_hci_util_handle_pb_bc_join(uint16_t handle, uint8_t pb, uint8_t bc) { diff --git a/src/nimble/nimble/host/src/ble_hs_resolv.c b/src/nimble/nimble/host/src/ble_hs_resolv.c index d70a9bdc..1c79356e 100644 --- a/src/nimble/nimble/host/src/ble_hs_resolv.c +++ b/src/nimble/nimble/host/src/ble_hs_resolv.c @@ -111,17 +111,16 @@ static void ble_rpa_peer_dev_rec_clear_all(void) { uint8_t i; + int num_peer_dev_rec = ble_store_num_peer_dev_rec; /* As NVS record need to be deleted one by one, we loop through * peer_records */ - for (i = 0; i < ble_store_num_peer_dev_rec; i++) { + for (i = 0; i < num_peer_dev_rec; i++) { ble_store_num_peer_dev_rec--; - - if ((i != ble_store_num_peer_dev_rec) && (ble_store_num_peer_dev_rec != 0)) { - memmove(&peer_dev_rec[i], &peer_dev_rec[i + 1], - (ble_store_num_peer_dev_rec - i + 1) * sizeof(struct ble_hs_dev_records )); - } - + memmove(&peer_dev_rec[0], &peer_dev_rec[1], + ble_store_num_peer_dev_rec * sizeof(struct ble_hs_dev_records)); + memset(&peer_dev_rec[ble_store_num_peer_dev_rec], 0, + sizeof(struct ble_hs_dev_records)); ble_store_persist_peer_records(); } return; @@ -230,15 +229,6 @@ ble_rpa_resolv_add_peer_rec(uint8_t *peer_addr) { struct ble_hs_dev_records *p_dev_rec = &peer_dev_rec[ble_store_num_peer_dev_rec]; - uint8_t idx = 0; - - while (p_dev_rec->rec_used) { - p_dev_rec++; - idx++; - if (idx > MYNEWT_VAL(BLE_STORE_MAX_BONDS)) { - return BLE_HS_ESTORE_CAP; - } - } p_dev_rec->rec_used = 1; memcpy(p_dev_rec->pseudo_addr, peer_addr, BLE_DEV_ADDR_LEN); diff --git a/src/nimble/nimble/host/src/ble_l2cap_coc.c b/src/nimble/nimble/host/src/ble_l2cap_coc.c index fa9e61be..83b55731 100644 --- a/src/nimble/nimble/host/src/ble_l2cap_coc.c +++ b/src/nimble/nimble/host/src/ble_l2cap_coc.c @@ -40,6 +40,14 @@ static os_membuf_t ble_l2cap_coc_srv_mem[ static struct os_mempool ble_l2cap_coc_srv_pool; +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + static void ble_l2cap_coc_dbg_assert_srv_not_inserted(struct ble_l2cap_coc_srv *srv) { diff --git a/src/nimble/nimble/host/src/ble_sm.c b/src/nimble/nimble/host/src/ble_sm.c index 5a7ffbb4..ca16faac 100644 --- a/src/nimble/nimble/host/src/ble_sm.c +++ b/src/nimble/nimble/host/src/ble_sm.c @@ -51,6 +51,15 @@ #include "../store/config/src/ble_store_config_priv.h" #if NIMBLE_BLE_CONNECT + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + #if NIMBLE_BLE_SM /** Procedure timeout; 30 seconds. */ diff --git a/src/nimble/porting/nimble/include/nimble/nimble_port.h b/src/nimble/porting/nimble/include/nimble/nimble_port.h index 677b43d0..27360b25 100644 --- a/src/nimble/porting/nimble/include/nimble/nimble_port.h +++ b/src/nimble/porting/nimble/include/nimble/nimble_port.h @@ -40,13 +40,24 @@ extern "C" { #endif -void nimble_port_init(void); -void nimble_port_deinit(void); +#ifdef ESP_PLATFORM +/** +* @brief nimble_port_init - Initialize controller and NimBLE host stack +* +* @return esp_err_t - ESP_OK ( if success) +* Error code in case of failure +*/ +esp_err_t nimble_port_init(void); + +/** +* @brief nimble_port_deinit - Deinitialize controller and NimBLE host stack +* +* @return esp_err_t - ESP_OK ( if success) +* Error code in case of failure +*/ +esp_err_t nimble_port_deinit(void); -void nimble_port_run(void); -int nimble_port_stop(void); -#ifdef ESP_PLATFORM /** * @brief esp_nimble_init - Initialize the NimBLE host stack * @@ -60,8 +71,14 @@ esp_err_t esp_nimble_init(void); * @return esp_err_t */ esp_err_t esp_nimble_deinit(void); +#else +void nimble_port_init(void); +void nimble_port_deinit(void); #endif // ESP_PLATFORM +void nimble_port_run(void); +int nimble_port_stop(void); + struct ble_npl_eventq *nimble_port_get_dflt_eventq(void); #if NIMBLE_CFG_CONTROLLER diff --git a/src/nimble/porting/nimble/include/os/os.h b/src/nimble/porting/nimble/include/os/os.h index bc456b2a..c07f3cfc 100644 --- a/src/nimble/porting/nimble/include/os/os.h +++ b/src/nimble/porting/nimble/include/os/os.h @@ -30,14 +30,6 @@ extern "C" { #define static_assert _Static_assert #endif -#ifndef min -#define min(a, b) ((a)<(b)?(a):(b)) -#endif - -#ifndef max -#define max(a, b) ((a)>(b)?(a):(b)) -#endif - #include "../syscfg/syscfg.h" #include "nimble/nimble/include/nimble/nimble_npl.h" diff --git a/src/nimble/porting/nimble/include/syscfg/syscfg.h b/src/nimble/porting/nimble/include/syscfg/syscfg.h index e9721312..91ac58d5 100644 --- a/src/nimble/porting/nimble/include/syscfg/syscfg.h +++ b/src/nimble/porting/nimble/include/syscfg/syscfg.h @@ -745,6 +745,10 @@ #define MYNEWT_VAL_BLE_GATT_WRITE_RELIABLE (MYNEWT_VAL_BLE_ROLE_CENTRAL) #endif +#ifndef MYNEWT_VAL_BLE_GATT_BLOB_TRANSFER +#define MYNEWT_VAL_BLE_GATT_BLOB_TRANSFER (0) +#endif + #ifndef MYNEWT_VAL_BLE_HOST #define MYNEWT_VAL_BLE_HOST (1) #endif diff --git a/src/nimble/porting/nimble/src/nimble_port.c b/src/nimble/porting/nimble/src/nimble_port.c index b10a4d25..0f5f127d 100644 --- a/src/nimble/porting/nimble/src/nimble_port.c +++ b/src/nimble/porting/nimble/src/nimble_port.c @@ -151,10 +151,20 @@ esp_err_t esp_nimble_deinit(void) } #endif +#ifdef ESP_PLATFORM +/** + * @brief nimble_port_init - Initialize controller and NimBLE host stack + * + * @return esp_err_t + */ +esp_err_t +#else void +#endif nimble_port_init(void) { #ifdef ESP_PLATFORM + esp_err_t ret; #if false // Arduino disabled #if CONFIG_IDF_TARGET_ESP32 @@ -162,21 +172,28 @@ nimble_port_init(void) #endif #if CONFIG_BT_CONTROLLER_ENABLED esp_bt_controller_config_t config_opts = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); - if(esp_bt_controller_init(&config_opts) != ESP_OK) { + + ret = esp_bt_controller_init(&config_opts); + if (ret != ESP_OK) { ESP_LOGE(NIMBLE_PORT_LOG_TAG, "controller init failed\n"); - return; + return ret; } - if(esp_bt_controller_enable(ESP_BT_MODE_BLE) != ESP_OK) { + + ret = esp_bt_controller_enable(ESP_BT_MODE_BLE); + if (ret != ESP_OK) { ESP_LOGE(NIMBLE_PORT_LOG_TAG, "controller enable failed\n"); - return; + return ret; } #endif #endif // Arduino disabled - if(esp_nimble_init() != 0) { + ret = esp_nimble_init(); + if (ret != ESP_OK) { ESP_LOGE(NIMBLE_PORT_LOG_TAG, "nimble host init failed\n"); - return; + return ret; } + + return ESP_OK; #else #if CONFIG_NIMBLE_STACK_USE_MEM_POOLS /* Initialize the function pointers for OS porting */ @@ -201,23 +218,42 @@ nimble_port_init(void) #endif // ESP_PLATFORM } +#ifdef ESP_PLATFORM +/** + * @brief nimble_port_deinit - Deinitialize controller and NimBLE host stack + * + * @return esp_err_t + */ + +esp_err_t +#else void +#endif nimble_port_deinit(void) { #ifdef ESP_PLATFORM - if(esp_nimble_deinit() != 0) { + esp_err_t ret; + + ret = esp_nimble_deinit(); + if(ret != ESP_OK) { ESP_LOGE(NIMBLE_PORT_LOG_TAG, "nimble host deinit failed\n"); - return; + return ret; } + #if CONFIG_BT_CONTROLLER_ENABLED - if(esp_bt_controller_disable() != ESP_OK) { + ret = esp_bt_controller_disable(); + if(ret != ESP_OK) { ESP_LOGE(NIMBLE_PORT_LOG_TAG, "controller disable failed\n"); - return; + return ret; } - if(esp_bt_controller_deinit() != ESP_OK) { + + ret = esp_bt_controller_deinit(); + if(ret != ESP_OK) { ESP_LOGE(NIMBLE_PORT_LOG_TAG, "controller deinit failed\n"); - return; + return ret; } + + return ESP_OK; #endif #else ble_npl_eventq_deinit(&g_eventq_dflt); diff --git a/src/nimble/porting/nimble/src/os_mbuf.c b/src/nimble/porting/nimble/src/os_mbuf.c index a6bf0414..a3236e43 100644 --- a/src/nimble/porting/nimble/src/os_mbuf.c +++ b/src/nimble/porting/nimble/src/os_mbuf.c @@ -41,6 +41,14 @@ #include #include +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + /** * @addtogroup OSKernel * @{