Skip to content

feat(ble_gatt_server): add is_initialized() and document one-server-per-boot - #914

Merged
finger563 merged 2 commits into
mainfrom
feat/ble-gatt-server-is-initialized
Nov 18, 2026
Merged

finger563 merged 2 commits into
mainfrom
feat/ble-gatt-server-is-initialized

Conversation

@finger563

Copy link
Copy Markdown
Contributor

What

Adds BleGattServer::is_initialized() and documents the one-server-per-boot constraint of the underlying NimBLE stack.

is_initialized() returns whether this server currently owns the stack (between a successful init() and deinit()), so an application that manages one BLE personality at a time can ask "is the radio up as this server?" without tracking it in parallel. It reports server_ != nullptr, the same flag init()/deinit() already maintain.

The class doc now states explicitly that NimBLE owns a single GATT server (NimBLEDevice::createServer() returns that one server) and that init()/deinit() bring the whole stack up and down, so a design that switches between two GATT layouts must deinit() one before init()-ing the next rather than hold two initialized instances at once.

Why

Header-only, additive, no behavior change. It surfaces state the class already tracks, and writes down a constraint that is easy to trip over when a peripheral hosts more than one GATT personality across its lifetime.

Test

Builds the ble_gatt_server example on esp32s3.

…er-boot

is_initialized() returns whether this server currently owns the NimBLE stack
(between a successful init() and deinit()), so an application that manages one
BLE personality at a time can ask "is the radio up as this server?" without
tracking it in parallel. It reports server_ != nullptr, the flag init()/deinit()
already maintain.

The class doc now states explicitly that NimBLE owns a single GATT server
(NimBLEDevice::createServer() returns that one server) and that init()/deinit()
bring the whole stack up and down, so a design switching between two GATT layouts
must deinit() one before init()-ing the next rather than hold two initialized
instances at once.

Header-only and additive. Builds the ble_gatt_server example on esp32s3.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
@finger563
finger563 marked this pull request as ready for review November 18, 2026 02:22
@github-actions

Copy link
Copy Markdown

✅Static analysis result - no issues found! ✅

The @note claimed deinit() "should only be called after NimBLEDevice::deinit(true)
has been called", but deinit() itself calls NimBLEDevice::deinit(true). Reword it
to say so and warn against calling NimBLEDevice::deinit() separately. Found while
reviewing the is_initialized() change in the same doc block.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
@finger563
finger563 merged commit 2089027 into main Nov 18, 2026
182 checks passed
@finger563
finger563 deleted the feat/ble-gatt-server-is-initialized branch November 18, 2026 04:18
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.

1 participant