Skip to content

Update to Mynewt-NimBLE version 1.9#1104

Draft
h2zero wants to merge 1 commit intomasterfrom
nimble-1.9
Draft

Update to Mynewt-NimBLE version 1.9#1104
h2zero wants to merge 1 commit intomasterfrom
nimble-1.9

Conversation

@h2zero
Copy link
Owner

@h2zero h2zero commented Mar 4, 2026

This will update to the mainline Mynewt-nimble repo and pull in esp device support from the esp-nimble fork. Doing this allows for simplified maintenance and avoids having too much additional/unsupported upstream changes.

This also allows for using more recent NimBLE versions and being able to pull in important updates that are not in esp-nimble.

@h2zero h2zero requested a review from Copilot March 4, 2026 21:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the NimBLE stack from the esp-nimble fork to the mainline Mynewt-NimBLE v1.9.0. This simplifies maintenance by pulling from the upstream repo directly while incorporating ESP device support, and enables access to more recent NimBLE features and important updates.

Changes:

  • Updates NimBLE core to v1.9.0 with new features (Channel Sounding stubs, ISO improvements, ADV coding selection, periodic ADV ADI support, scan configuration VS commands)
  • Removes ESP-specific fork files (ble_esp_hs.h, ble_esp_gap.h, ble_esp_gatt.h) and refactors platform guards (#ifndef ESP_PLATFORM moved before license headers)
  • Refactors include paths from angle brackets to quotes, removes deprecated APIs, and fixes several bugs (IRK list indexing, scheduler null check, scan request PDU generation)

Reviewed changes

Copilot reviewed 122 out of 287 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/nimble/RELEASE_NOTES.md, NOTICE, LICENSE Updated to NimBLE v1.9.0 release info
src/nimble/nimble/host/include/host/ble_hs.h Removed ESP-specific includes and config fields (sm_sc_only, eatt)
src/nimble/nimble/host/include/host/ble_sm.h Added comprehensive doxygen documentation, reordered OOB fields
src/nimble/nimble/host/include/host/ble_l2cap.h Added COC CID range defines and ble_l2cap_remove_server
src/nimble/nimble/host/include/host/ble_att.h Reorganized ATT opcodes, added new error codes, removed EATT-specific APIs
src/nimble/nimble/host/include/host/ble_hs_hci.h Renamed ble_hs_hci_util_rand to ble_hs_hci_rand
src/nimble/nimble/host/include/host/ble_hs_log.h Switched to NPL-based logging
src/nimble/nimble/host/include/host/ble_cs.h New Channel Sounding host header
src/nimble/nimble/host/include/host/ble_eddystone.h Added documentation comments, renamed parameter
src/nimble/nimble/host/include/host/ble_uuid.h Added BLE_UUID128_INIT docs, reformatted comments
src/nimble/nimble/host/include/host/ble_aes_ccm.h Removed duplicate/unnecessary tinycrypt include
Mesh headers (model_srv/cli, mesh, heartbeat, health, cfg, cdb, atomic) Removed mesh include files
src/nimble/nimble/controller/include/controller/ble_ll.h Extended feature bits, replaced BLE_LL_BT5_PHY_SUPPORTED macro
src/nimble/nimble/controller/include/controller/ble_ll_conn.h Added encrypt_paused, conn_update_host_initd flags, renamed anchor API
src/nimble/nimble/controller/include/controller/ble_ll_scan.h Added VS scan config, refactored scan NRPA, added make_req_pdu
src/nimble/nimble/controller/include/controller/ble_ll_iso.h Major refactor with ble_ll_iso_conn struct and new APIs
src/nimble/nimble/controller/include/controller/ble_ll_isoal.h Added framed PDU support, mux improvements
src/nimble/nimble/controller/include/controller/ble_ll_cs.h New Channel Sounding controller header
src/nimble/nimble/controller/include/controller/ble_ll_sched.h Updated iso_big signature with fixed param
src/nimble/nimble/controller/include/controller/ble_ll_sync.h Changed periodic_ind API from bool to uint8_t mode
src/nimble/nimble/controller/include/controller/ble_ll_ctrl.h Removed data param from ctrl_proc_start, updated enc_allowed
src/nimble/nimble/controller/include/controller/ble_ll_adv.h Renamed rmvd callback, added v2 param API
src/nimble/nimble/controller/include/controller/ble_ll_resolv.h Added local IRK APIs
src/nimble/nimble/controller/src/*.c Platform guard refactoring, bug fixes, new features
src/nimble/nimble/drivers/nrf5x/, nrf51/ Platform guard refactoring, NRF53 removal, bug fixes
src/nimble/ext/tinycrypt/** Include path changes to quotes, removed metadata files
src/nimble/esp_port/** Include path fixes, added extern declarations
src/NimBLEUtils.cpp Added #ifdef guards for potentially removed GAP events

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +213 to +216
/** Read Multiple Variable Lenght Request */
#define BLE_ATT_OP_READ_MULT_VAR_REQ 0x20

/** Read Multiple Variable Lenght Response */
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word 'Lenght' should be 'Length' in both the request and response comments.

Suggested change
/** Read Multiple Variable Lenght Request */
#define BLE_ATT_OP_READ_MULT_VAR_REQ 0x20
/** Read Multiple Variable Lenght Response */
/** Read Multiple Variable Length Request */
#define BLE_ATT_OP_READ_MULT_VAR_REQ 0x20
/** Read Multiple Variable Length Response */

Copilot uses AI. Check for mistakes.
#define BLE_ATT_ERR_WRITE_REQ_REJECTED 0xFC

/**Client Characteristic Configuration Descriptor Improperly Configured. */
#define BLE_ATT_ERR_CCCD_IMPORER_CONF 0xFD
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The macro name BLE_ATT_ERR_CCCD_IMPORER_CONF contains a typo. It should be BLE_ATT_ERR_CCCD_IMPROPER_CONF.

Suggested change
#define BLE_ATT_ERR_CCCD_IMPORER_CONF 0xFD
#define BLE_ATT_ERR_CCCD_IMPROPER_CONF 0xFD
#define BLE_ATT_ERR_CCCD_IMPORER_CONF BLE_ATT_ERR_CCCD_IMPROPER_CONF

Copilot uses AI. Check for mistakes.
Comment on lines +323 to +325
* LTK and decrypt SIRK
*
* @return 0 if RSI was resolved succesfully; nonzero on failure.
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'succesfully' should be 'successfully'.

Suggested change
* LTK and decrypt SIRK
*
* @return 0 if RSI was resolved succesfully; nonzero on failure.
* otherwise peer address should be passed here to get
* LTK and decrypt SIRK
*
* @return 0 if RSI was resolved successfully; nonzero on failure.

Copilot uses AI. Check for mistakes.
#define BLE_ATT_OP_READ_MULT_VAR_RSP 0x21

/** Notify Multiple Request */
#define BLE_ATT_OP_NOTIFY_MULTI_REQ 0x23
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a missing blank line between BLE_ATT_OP_NOTIFY_MULTI_REQ and the /** Write Command. */ comment. Other opcode definitions in this file are separated by blank lines for readability.

Suggested change
#define BLE_ATT_OP_NOTIFY_MULTI_REQ 0x23
#define BLE_ATT_OP_NOTIFY_MULTI_REQ 0x23

Copilot uses AI. Check for mistakes.

/* there should be no ADI in Sync or chain, skip it */
if (ext_hdr_flags & (1 << BLE_LL_EXT_ADV_DATA_INFO_BIT)) {
if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PERIODIC_ADV_ADI_SUPPORT) {
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if on line 598 is missing parentheses around the condition. It should be if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PERIODIC_ADV_ADI_SUPPORT)) to follow C syntax correctly. While some compilers may accept this as a macro expansion, it's incorrect C syntax and can cause unexpected behavior with certain preprocessor configurations.

Suggested change
if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PERIODIC_ADV_ADI_SUPPORT) {
if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PERIODIC_ADV_ADI_SUPPORT)) {

Copilot uses AI. Check for mistakes.
uint8_t status;
} procedure_complete;
};

Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 38 has trailing whitespace.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines +640 to +641
ev->data[len] = 0;
hci_ev->length += len + 1;
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vsnprintf returns the number of characters that would have been written if the buffer were large enough, which can exceed the actual buffer size. If the formatted string exceeds BLE_HCI_MAX_DATA_LEN - sizeof(*ev), then len will be larger than the available buffer space, and ev->data[len] = 0 will write out of bounds. You should clamp len to BLE_HCI_MAX_DATA_LEN - sizeof(*ev) - 1 before using it.

Copilot uses AI. Check for mistakes.
* Initialized once per LE Connection.
*/
uint8_t nonce_v[16];
/* Cache bits generated with single DRBG transation */
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'transation' should be 'transaction'.

Suggested change
/* Cache bits generated with single DRBG transation */
/* Cache bits generated with single DRBG transaction */

Copilot uses AI. Check for mistakes.
#endif
#if MYNEWT_VAL(BLE_LL_HCI_VS_SET_SCAN_CFG)
BLE_LL_HCI_VS_CMD(BLE_HCI_OCF_VS_SET_SCAN_CFG,
ble_ll_hci_vs_set_scan_cfg)
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BLE_LL_HCI_VS_CMD entry for BLE_HCI_OCF_VS_SET_SCAN_CFG is missing a trailing comma. If BLE_LL_HCI_VS_SET_SCAN_CFG is enabled, this will cause a compilation error because subsequent array entries (if any) or the closing brace won't parse correctly. If this is the last entry in the array, it may compile but is inconsistent with the other entries that have trailing commas.

Suggested change
ble_ll_hci_vs_set_scan_cfg)
ble_ll_hci_vs_set_scan_cfg),

Copilot uses AI. Check for mistakes.
#endif /* if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) */
#endif


Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a double blank line before the closing #endif. One blank line would be sufficient.

Suggested change

Copilot uses AI. Check for mistakes.
@h2zero h2zero force-pushed the nimble-1.9 branch 3 times, most recently from 802cb8d to 85d2262 Compare March 5, 2026 17:41
This will update to the mainline Mynewt-nimble repo and pull in esp device support
from the esp-nimble fork. Doing this allows for simplified maintenance and avoids having
too much additional/unsupported upstream changes.

This also allows for using more recent NimBLE versions and being able to pull in important
updates that are not in esp-nimble.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants