update nimble lib

This commit is contained in:
technyon
2022-04-22 22:30:50 +02:00
parent cf7e2464bd
commit 097604f6d0
43 changed files with 2148 additions and 174 deletions

View File

@@ -42,7 +42,7 @@ esp_err_t esp_nimble_hci_init(void);
* transport buffers to be exchanged between NimBLE host and ESP controller.
* It also registers required host callbacks with the controller.
*
* Below is the sequence of APIs to be called to initialize/enable NimBLE host and ESP controller:
* Below is the sequence of APIs to be called to init/enable NimBLE host and ESP controller:
*
* @code{c}
* void ble_host_task(void *param)

View File

@@ -93,11 +93,11 @@ int tc_hmac_set_key(TCHmacState_t ctx, const uint8_t *key,
unsigned int key_size);
/**
* @brief HMAC initialize procedure
* @brief HMAC init procedure
* Initializes ctx to begin the next HMAC operation
* @return returns TC_CRYPTO_SUCCESS (1)
* returns TC_CRYPTO_FAIL (0) if: ctx == NULL or key == NULL
* @param ctx IN/OUT -- struct tc_hmac_state_struct buffer to initialize
* @param ctx IN/OUT -- struct tc_hmac_state_struct buffer to init
*/
int tc_hmac_init(TCHmacState_t ctx);

View File

@@ -107,7 +107,7 @@ typedef struct tc_hmac_prng_struct *TCHmacPrng_t;
* nonce. TinyCrypts requires instead a non-null personalization
* (which is easily computed) and indirectly requires an entropy
* seed (since the reseed function is mandatorily called after
* initialize)
* init)
* @param prng IN/OUT -- the PRNG state to initialize
* @param personalization IN -- personalization string
* @param plen IN -- personalization length in bytes

View File

@@ -379,7 +379,7 @@ struct ble_dev_addr
* -> AdvA (6 bytes)
* -> LLData (22 bytes)
* -> Access address (4 bytes)
* -> CRC initialize (3 bytes)
* -> CRC init (3 bytes)
* -> WinSize (1 byte)
* -> WinOffset (2 bytes)
* -> Interval (2 bytes)

View File

@@ -1425,7 +1425,7 @@ ble_ll_reset(void)
/* Reset connection module */
ble_ll_conn_module_reset();
/* All this does is re-initialize the event masks so call the hci initialize */
/* All this does is re-initialize the event masks so call the hci init */
ble_ll_hci_init();
/* Reset scheduler */

View File

@@ -3037,7 +3037,7 @@ ble_ll_init_rx_isr_end(uint8_t *rxbuf, uint8_t crcok,
/* Get connection state machine to use if connection to be established */
connsm = g_ble_ll_conn_create_sm;
/* This could happen if connection initialize was cancelled while isr end was
/* This could happen if connection init was cancelled while isr end was
* already pending
*/
if (!connsm) {

View File

@@ -3942,12 +3942,12 @@ ble_ll_scan_reset(void)
os_mempool_clear(&ext_scan_aux_pool);
#endif
/* Call the common initialize function again */
/* Call the common init function again */
ble_ll_scan_common_init();
}
/**
* ble ll scan initialize
* ble ll scan init
*
* Initialize a scanner. Must be called before scanning can be started.
* Expected to be called with a un-initialized scanning state machine.

View File

@@ -835,7 +835,7 @@ ble_phy_isr(void)
}
/**
* ble phy initialize
* ble phy init
*
* Initialize the PHY.
*

View File

@@ -1381,7 +1381,7 @@ ble_phy_dbg_time_setup(void)
}
/**
* ble phy initialize
* ble phy init
*
* Initialize the PHY.
*

View File

@@ -451,7 +451,7 @@ struct bt_mesh_model_cb {
*/
int (*const settings_commit)(struct bt_mesh_model *model);
/** @brief Model initialize callback.
/** @brief Model init callback.
*
* Called on every model instance during mesh initialization.
*

View File

@@ -243,7 +243,7 @@ static inline struct os_mbuf * NET_BUF_SIMPLE(uint16_t size)
static inline void net_buf_simple_init(struct os_mbuf *buf,
size_t reserve_head)
{
/* This is called in Zephyr after initialize.
/* This is called in Zephyr after init.
* Note in Mynewt case we don't care abour reserved head*/
buf->om_data = &buf->om_databuf[buf->om_pkthdr_len] + reserve_head;
buf->om_len = 0;

View File

@@ -317,7 +317,7 @@ void bt_mesh_adv_init(void)
int rc;
/* Advertising should only be initialized once. Calling
* os_task initialize the second time will result in an assert. */
* os_task init the second time will result in an assert. */
if (adv_initialized) {
return;
}

View File

@@ -70,7 +70,7 @@ static inline int bt_mesh_beacon_key(const u8_t net_key[16],
}
int bt_mesh_beacon_auth(const u8_t beacon_key[16], u8_t flags,
const u8_t net_id[16], u32_t iv_index,
const u8_t net_id[8], u32_t iv_index,
u8_t auth[8]);
static inline int bt_mesh_app_id(const u8_t app_key[16], u8_t app_id[1])

View File

@@ -1422,7 +1422,7 @@ dummy_access_cb(uint16_t conn_handle, uint16_t attr_handle,
/*
* We should never never enter this callback - it's attached to notify-only
* characteristic which are notified directly from mbuf. And we can't pass
* NULL as access_cb because gatts will assert on initialize...
* NULL as access_cb because gatts will assert on init...
*/
BLE_HS_DBG_ASSERT(0);
return 0;

View File

@@ -482,10 +482,6 @@ ble_gap_conn_find(uint16_t handle, struct ble_gap_conn_desc *out_desc)
{
struct ble_hs_conn *conn;
if (!ble_hs_is_enabled()) {
return BLE_HS_EDISABLED;
}
ble_hs_lock();
conn = ble_hs_conn_find(handle);
@@ -2147,10 +2143,6 @@ ble_gap_set_event_cb(uint16_t conn_handle, ble_gap_event_fn *cb, void *cb_arg)
{
struct ble_hs_conn *conn;
if (!ble_hs_is_enabled()) {
return BLE_HS_EDISABLED;
}
ble_hs_lock();
conn = ble_hs_conn_find(conn_handle);
@@ -2754,10 +2746,6 @@ ble_gap_adv_rsp_set_fields(const struct ble_hs_adv_fields *rsp_fields)
uint8_t buf_sz;
int rc;
if (!ble_hs_is_enabled()) {
return BLE_HS_EDISABLED;
}
rc = ble_hs_adv_set_fields(rsp_fields, buf, &buf_sz, sizeof buf);
if (rc != 0) {
return rc;

View File

@@ -552,20 +552,21 @@ ble_hs_hci_evt_le_rd_rem_used_feat_complete(uint8_t subevent, const void *data,
static int
ble_hs_hci_decode_legacy_type(uint16_t evt_type)
{
switch (evt_type) {
case BLE_HCI_LEGACY_ADV_EVTYPE_ADV_IND:
return BLE_HCI_ADV_RPT_EVTYPE_ADV_IND;
case BLE_HCI_LEGACY_ADV_EVTYPE_ADV_DIRECT_IND:
return BLE_HCI_ADV_RPT_EVTYPE_DIR_IND;
case BLE_HCI_LEGACY_ADV_EVTYPE_ADV_SCAN_IND:
return BLE_HCI_ADV_RPT_EVTYPE_SCAN_IND;
case BLE_HCI_LEGACY_ADV_EVTYPE_ADV_NONCON_IND:
return BLE_HCI_ADV_RPT_EVTYPE_NONCONN_IND;
case BLE_HCI_LEGACY_ADV_EVTYPE_SCAN_RSP_ADV_IND:
return BLE_HCI_ADV_RPT_EVTYPE_SCAN_RSP;
default:
return -1;
}
switch (evt_type) {
case BLE_HCI_LEGACY_ADV_EVTYPE_ADV_IND:
return BLE_HCI_ADV_RPT_EVTYPE_ADV_IND;
case BLE_HCI_LEGACY_ADV_EVTYPE_ADV_DIRECT_IND:
return BLE_HCI_ADV_RPT_EVTYPE_DIR_IND;
case BLE_HCI_LEGACY_ADV_EVTYPE_ADV_SCAN_IND:
return BLE_HCI_ADV_RPT_EVTYPE_SCAN_IND;
case BLE_HCI_LEGACY_ADV_EVTYPE_ADV_NONCON_IND:
return BLE_HCI_ADV_RPT_EVTYPE_NONCONN_IND;
case BLE_HCI_LEGACY_ADV_EVTYPE_SCAN_RSP_ADV_IND:
case BLE_HCI_LEGACY_ADV_EVTYPE_SCAN_RSP_ADV_SCAN_IND:
return BLE_HCI_ADV_RPT_EVTYPE_SCAN_RSP;
default:
return -1;
}
}
#endif

View File

@@ -37,7 +37,7 @@ ble_hs_startup_read_sup_f_tx(void)
return rc;
}
/* for now we don't use it outside of initialize sequence so check this here
/* for now we don't use it outside of init sequence so check this here
* LE Supported (Controller) byte 4, bit 6
*/
if (!(rsp.features & 0x0000006000000000)) {

View File

@@ -65,6 +65,20 @@ static struct trng_dev *g_trng;
#endif
#endif
/**
* Keep forward-compatibility with Mbed TLS 3.x.
*
* Direct access to fields of structures declared in public headers is no longer
* supported. In Mbed TLS 3, the layout of structures is not considered part of
* the stable API, and minor versions (3.1, 3.2, etc.) may add, remove, rename,
* reorder or change the type of structure fields.
*/
#if (MBEDTLS_VERSION_NUMBER < 0x03000000)
#ifndef MBEDTLS_PRIVATE
#define MBEDTLS_PRIVATE(member) member
#endif
#endif
static void
ble_sm_alg_xor_128(const uint8_t *p, const uint8_t *q, uint8_t *r)
{
@@ -533,15 +547,15 @@ ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_
mbedtls_mpi_init(&z);
/* Below 3 steps are to validate public key on curve secp256r1 */
if (mbedtls_ecp_group_load(&keypair.grp, MBEDTLS_ECP_DP_SECP256R1) != 0) {
if (mbedtls_ecp_group_load(&keypair.MBEDTLS_PRIVATE(grp), MBEDTLS_ECP_DP_SECP256R1) != 0) {
goto exit;
}
if (mbedtls_ecp_point_read_binary(&keypair.grp, &pt, pub, 65) != 0) {
if (mbedtls_ecp_point_read_binary(&keypair.MBEDTLS_PRIVATE(grp), &pt, pub, 65) != 0) {
goto exit;
}
if (mbedtls_ecp_check_pubkey(&keypair.grp, &pt) != 0) {
if (mbedtls_ecp_check_pubkey(&keypair.MBEDTLS_PRIVATE(grp), &pt) != 0) {
goto exit;
}
@@ -552,7 +566,7 @@ ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_
}
/* Prepare point Q from pub key */
if (mbedtls_ecp_point_read_binary(&keypair.grp, &Q, pub, 65) != 0) {
if (mbedtls_ecp_point_read_binary(&keypair.MBEDTLS_PRIVATE(grp), &Q, pub, 65) != 0) {
goto exit;
}
@@ -560,7 +574,7 @@ ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_
goto exit;
}
rc = mbedtls_ecdh_compute_shared(&keypair.grp, &z, &Q, &d,
rc = mbedtls_ecdh_compute_shared(&keypair.MBEDTLS_PRIVATE(grp), &z, &Q, &d,
mbedtls_ctr_drbg_random, &ctr_drbg);
if (rc != 0) {
goto exit;
@@ -640,14 +654,14 @@ mbedtls_gen_keypair(uint8_t *public_key, uint8_t *private_key)
goto exit;
}
if (( rc = mbedtls_mpi_write_binary(&keypair.d, private_key, 32)) != 0) {
if (( rc = mbedtls_mpi_write_binary(&keypair.MBEDTLS_PRIVATE(d), private_key, 32)) != 0) {
goto exit;
}
size_t olen = 0;
uint8_t pub[65] = {0};
if ((rc = mbedtls_ecp_point_write_binary(&keypair.grp, &keypair.Q, MBEDTLS_ECP_PF_UNCOMPRESSED,
if ((rc = mbedtls_ecp_point_write_binary(&keypair.MBEDTLS_PRIVATE(grp), &keypair.MBEDTLS_PRIVATE(Q), MBEDTLS_ECP_PF_UNCOMPRESSED,
&olen, pub, 65)) != 0) {
goto exit;
}

View File

@@ -50,7 +50,7 @@ static const uint8_t ble_sm_lgcy_init_ioa[5 /*resp*/ ][5 /*init*/ ] =
/* This is the responder passkey action action depending on the io
* capabilities of both parties
*/
static const uint8_t ble_sm_lgcy_resp_ioa[5 /*resp*/ ][5 /*initialize*/ ] =
static const uint8_t ble_sm_lgcy_resp_ioa[5 /*resp*/ ][5 /*init*/ ] =
{
{IOACT_NONE, IOACT_NONE, IOACT_DISP, IOACT_NONE, IOACT_DISP},
{IOACT_NONE, IOACT_NONE, IOACT_DISP, IOACT_NONE, IOACT_DISP},

View File

@@ -70,7 +70,7 @@ static const uint8_t ble_sm_sc_init_ioa[5 /*resp*/ ][5 /*init*/ ] =
*/
static const uint8_t ble_sm_sc_resp_ioa[5 /*resp*/ ][5 /*init*/ ] =
{
/* initialize */
/* init */
/*r*/ {IOACT_NONE, IOACT_NONE, IOACT_DISP, IOACT_NONE, IOACT_DISP},
/*e*/ {IOACT_NONE, IOACT_NUMCMP, IOACT_DISP, IOACT_NONE, IOACT_NUMCMP},
/*s*/ {IOACT_INPUT, IOACT_INPUT, IOACT_INPUT, IOACT_NONE, IOACT_INPUT},

View File

@@ -437,7 +437,7 @@ nrf52_timer5_irq_handler(void)
#endif
/**
* hal timer initialize
* hal timer init
*
* Initialize platform specific timer items
*
@@ -457,7 +457,7 @@ hal_timer_init(int timer_num, void *cfg)
NRF52_HAL_TIMER_RESOLVE(timer_num, bsptimer);
/* If timer is enabled do not allow initialize */
/* If timer is enabled do not allow init */
if (bsptimer->tmr_enabled) {
rc = EINVAL;
goto err;