Skip to content

Add GET_CAPABILITIES command and Capability flags#34

Open
kbx81 wants to merge 4 commits into
improv-wifi:mainfrom
kbx81:add-get-capabilities
Open

Add GET_CAPABILITIES command and Capability flags#34
kbx81 wants to merge 4 commits into
improv-wifi:mainfrom
kbx81:add-get-capabilities

Conversation

@kbx81

@kbx81 kbx81 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a GET_CAPABILITIES (0x05) RPC command and a Capability bitfield returned in its response, so a device can report its general connectivity and which network interfaces it has — independent of the Wi-Fi-only provisioning state machine.

This supports Improv on multi-interface devices: for example, a device that's already online via Ethernet (Wi-Fi disabled) can advertise that fact so a client knows it needn't provision Wi-Fi, rather than overloading STATE_PROVISIONED. This allows the proper display of UI elements based on what is/isn't available on the device -- for example, we can indicate that a device has connectivity, even if wifi is available but not yet configured. As another example, if wifi is disabled at runtime, the UI can react accordingly.

Changes

  • Command: add GET_CAPABILITIES = 0x05 (next free value after GET_WIFI_NETWORKS).
  • New enum class Capability : uint8_t returned in the first byte of the GET_CAPABILITIES response:
    • ONLINE — device currently has network connectivity via any interface
    • WIFI_SUPPORTED / ETHERNET_SUPPORTED / THREAD_SUPPORTED / MODEM_SUPPORTED
    • Reachable device URL(s) follow as subsequent string elements when ONLINE is set.
  • Documented as a distinct bitfield from CAPABILITY_IDENTIFY (the BLE identify capability) — the two are not interchangeable.

Compatibility

Fully additive. No parser changes are needed: parse_improv_data already passes unknown commands through and build_rpc_response writes any command byte, so older clients/devices are unaffected (an old device replies ERROR_UNKNOWN_RPC to 0x05; an old client never sends it).

The matching REQUEST_CAPABILITIES = 0x05 and capability flags have been implemented in the Improv serial JS SDK and consumed by ESP Web Tools. Related PRs:

@kbx81 kbx81 force-pushed the add-get-capabilities branch from 0a1d2ea to d4d8341 Compare June 12, 2026 07:02
balloob
balloob previously approved these changes Jun 12, 2026
Adds a GET_CAPABILITIES (0x07) RPC command. Its response returns the device
capability bitmask in the first byte; when CAPABILITY_ONLINE is set, reachable
device URL(s) follow as subsequent string elements.

Extends the existing capability bitmask (previously just CAPABILITY_IDENTIFY)
into a shared `Capability` enum -- ONLINE plus the supported network interfaces
(WIFI/ETHERNET/THREAD/MODEM). The same mask is advertised over BLE, so this is
purely additive (existing clients read only the bits they know). CAPABILITY_ONLINE
is dynamic; a live serial query reflects it, while the BLE capabilities value is
set at setup and must be updated/notified by the device to be meaningful there.

0x05 (Get/Set Hostname) and 0x06 (Get/Set Device Name) are reserved by the
Improv spec, so the command uses the next free value, 0x07.

No parser changes are needed: parse_improv_data passes unknown commands through
and build_rpc_response writes any command byte, so older clients/devices remain
compatible.
@kbx81 kbx81 force-pushed the add-get-capabilities branch from 02847ca to f3f9742 Compare June 15, 2026 22:20
jesserockz and others added 2 commits June 16, 2026 11:17
Per the Improv spec, the capabilities bitmask reports which RPC commands a
device supports. This reworks the connectivity reporting so it doesn't overload
that bitmask:

- Rename the command GET_CAPABILITIES -> GET_NETWORK_STATE (0x07).
- Replace the extended capability bits with a separate NetworkState enum
  (NETWORK_IS_ONLINE + present interfaces NETWORK_SUPPORTS_WIFI/ETHERNET/THREAD/
  MODEM), restoring CAPABILITY_IDENTIFY as the lone capability constant.

Keeps connectivity ("is it online, what interfaces") distinct from capabilities
("which commands are supported"), and avoids colliding with the in-flight
Improv 2.4 capabilities work (improv-wifi#32).
@kbx81 kbx81 force-pushed the add-get-capabilities branch from 666ed33 to 4de6eda Compare June 16, 2026 01:09
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.

3 participants