Skip to content

Config::getOrGenerateId opens NVS on every BLE handshake #7

Description

@hurui200320

Found in whole-codebase review.

NikonBLEClient::doHandshake (esp32/src/common/NikonBLEClient.cpp ~line 154) calls Config::getOrGenerateId(rnd) to rebuild the controller name for the ID characteristic write. The same value was already obtained once in main.cpp setup() to build the BLE device name — it never changes afterwards (generated once, persisted in NVS).

Each call re-opens the NVS namespace and re-reads the key on every (re)connect handshake. Harmless but wasteful.

Proposal: fetch the ID once at startup and pass it down (e.g. store it as a global/static set during setup(), or have NikonBLEClient take the full controller name as a constructor argument).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions