feat: BLE provisioning for WiFi and MQTT credentials - #10
Merged
Conversation
DigitalActuatorService had a virtual setLevel and a virtual destructor that were never overridden. The substitution seam is the IDigitalActuator port, not the service, so drop the speculative polymorphism.
Turn on Bluetooth with the NimBLE host in peripheral-only mode for the BLE provisioning module, and add the bt requirement to the app component.
Introduce a connectivity layer following the hexagonal structure: - config: device/wifi/mqtt configuration ports with flash-backed adapters (read-through/write-through to NVS, with NVS keys injected at construction). - provisioning: a NimBLE GATT server exposing device_id (read-only), WiFi and MQTT settings as characteristics and persisting writes to flash; passwords are write-only. Exposes start()/stop() for flexible availability. Add the NVS keys, project name and BLE UUIDs to the central config header.
Rename setup.{hpp,cpp} to build.{hpp,cpp} with beginPeripherals(). Instantiate
the connectivity config stores and the provisioning server in main, starting
BLE provisioning after the peripheral begin() sequence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a BLE provisioning capability so a deployed ESP32-C3 can be configured in the field over BLE, complementing the host provisioner (which still seeds
device_idinto NVS). A NimBLE GATT server exposes the device identity plus the WiFi and MQTT settings, persisting every change to flash.New
connectivity/layer (hexagonal: domain ports → application → infrastructure adapters):IDeviceConfig/IWifiConfig/IMqttConfigports with flash-backed adapters.device_id(read-only),wifi_ssid(rw),wifi_password(write-only),mqtt_host/mqtt_port/mqtt_user(rw),mqtt_password(write-only). Each carries a 0x2901 user description.start()readsdevice_idand advertises as<project_name>-<first device_id section>; fails if the device is not provisioned.stop()halts advertising.Notes
sdkconfig.config).setup.{hpp,cpp}renamed tobuild.{hpp,cpp}(beginPeripherals());config.hppis imported only bymain.cpp.Verification
make -C firmwarebuilds cleanly (flash ~53.6%, fits the default app partition).device_id, connect with a BLE app, read/write the characteristics, reboot and confirm values persist from flash.