Skip to content

Commit c767007

Browse files
yinzaraballoob
andauthored
Adding "Device Name" RPC for version 2.4 (#60)
* Adding "Device Name" RPC for version 2.4 * Minor spelling fix * Changes from review related to character encoding * Changes from review * Clarify authorization requirement for set hostname and set device name * Clarifications for wifi scanning auth type * Changes to device info spec from review * Fix to ordering of arguments from review * Apply suggestion from @balloob --------- Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
1 parent 781b795 commit c767007

File tree

2 files changed

+80
-10
lines changed

2 files changed

+80
-10
lines changed

src/ble.md

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ The client is able to send an `identify` to the Improv service if it is in the s
3030

3131
The client is able to send a `device info` to the Improv service if it is in the states "Require Authorization" and "Authorized". When received, and supported, the gadget will return the device information in the RPC response characteristic.
3232

33+
All strings are assumed to be UTF-8 encoded.
34+
3335
## Revision history
3436

3537
- 1.0 - Initial release
3638
- 2.0 - Added Service Data `4677`
3739
- 2.1 - Added Device Info RPC command
3840
- 2.2 - Added Scan Wifi RPC command
3941
- 2.3 - Added Hostname RPC command
42+
- 2.4 - Added Device Name RPC command
4043

4144
## GATT Services
4245

@@ -160,9 +163,12 @@ Should only be sent if the capability characteristic indicates that device info
160163

161164
This command will generate an RPC result. There will be at least 4 entries in the list response.
162165

163-
Order of strings: Firmware name, firmware version, hardware chip/variant, device name.
166+
Order of strings: Firmware name, firmware version, hardware chip/variant, device name. Optionally, the OS name and OS
167+
version can be appended if applicable and different from the firmware name/version.
168+
169+
Example without OS Name: `ESPHome`, `2021.11.0`, `esp32-s3-devkitc-1/esp32-s3`, `Temperature Monitor`.
164170

165-
Example: `ESPHome`, `2021.11.0`, `ESP32-C3`, `Temperature Monitor`.
171+
Example with OS Name: `Bluetooth Proxy`, `v1.0.0`, `denky_d4/esp32`, `My Bluetooth Proxy`, `ESPHome`, `2025.12.2`.
166172

167173
### RPC Command: Request scanned Wi-Fi networks
168174

@@ -177,11 +183,12 @@ Command ID: `0x04`
177183
| CS | checksum |
178184

179185
This command will trigger one RPC Response which will contain a multiple of 3 strings where the first contains the SSID,
180-
the second the RSSI and the third the authentication type of either WEP, WPA, WPA2 or NO.
186+
the second the RSSI and the third the authentication type of either WEP, WPA, WPA2, WPA2 EAP, WPA3, WAPI or NO. If
187+
multiple authentication types are supported they should be separated by a forward slash `/`.
181188

182189
Order of strings: Wi-Fi SSID 1, RSSI 1, Auth type 1, Wi-Fi SSID 2, RSSI 2, Auth type 2, ...
183190

184-
Example: `MyWirelessNetwork`, `-60`, `WPA2`, `MyOtherWirelessNetwork`, `-52`, `WEP`,...
191+
Example: `MyWirelessNetwork`, `-60`, `WPA2`, `MyOtherWirelessNetwork`, `-52`, `WPA/WPA2`,...
185192

186193
A response with no strings means no SSID was found.
187194

@@ -190,7 +197,7 @@ A response with no strings means no SSID was found.
190197
Sends a request for the device to either get or set its hostname.
191198
This operation is only available while the device is Authorized. Sending the command with no data will return
192199
the current hostname in the response. Sending the command with data will set the hostname to the data and also
193-
return the updated hostname in the response.
200+
return the updated hostname in the response. Setting this property requires the device to be in an 'Authorized' state.
194201

195202
Hostnames must conform to [RFC 1123](https://datatracker.ietf.org/doc/html/rfc1123) and can contain only letters,
196203
numbers and hyphens with a length of up to 255 characters. Error code `0x05` will be returned if the hostname provided is not acceptable.
@@ -214,7 +221,37 @@ Set Hostname:
214221
| | bytes of hostname |
215222
| CS | checksum |
216223

217-
This command will trigger one RPC Response which will contain the hostname of the device.
224+
This command will trigger one RPC Response which will contain the hostname of the device. Setting this
225+
property should reset the authorization timeout.
226+
227+
### RPC Command: Get/Set Device Name
228+
229+
Sends a request for the device to either get or set its name. This could mean different things depending on the device
230+
manufacturer. It may alter the default "hostname" or not. If setting both this property and hostname, it is recommended
231+
to set the device name first then the hostname. Getting this property should return the same value as the Device Info's
232+
"Device Name" (4th) property. Setting this property requires the device to be in an 'Authorized' state.
233+
234+
Command ID: `0x06`
235+
236+
Get Device Name:
237+
238+
| Byte | Description |
239+
|------|------------------------|
240+
| 06 | command (`0x06`) |
241+
| 00 | 0 data bytes / no data |
242+
| CS | checksum |
243+
244+
Set Device Name:
245+
246+
| Byte | Description |
247+
|-----|--------------------------------|
248+
| 06 | command (`0x06`) |
249+
| XX | length of device name in bytes |
250+
| | bytes of device name |
251+
| CS | checksum |
252+
253+
This command will trigger one RPC Response which will contain the Device Name of the device. Setting this
254+
property should reset the authorization timeout.
218255

219256

220257
### Characteristic: RPC Result

src/serial.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ The Improv service will receive Wi-Fi credentials from the client via the serial
1414

1515
The Improv client asks for the current state and sends the Wi-Fi credentials.
1616

17+
All strings are assumed to be UTF-8 encoded.
18+
1719
## Packet format
1820

1921
All packets are sent in the following format:
@@ -143,9 +145,12 @@ Command ID: `0x03`
143145

144146
This command will trigger one packet, the `Device Information` formatted as a RPC result. This result will contain at least 4 strings.
145147

146-
Order of strings: Firmware name, firmware version, hardware chip/variant, device name.
148+
Order of strings: Firmware name, firmware version, hardware chip/variant, device name. Optionally, the OS name and OS
149+
version can be appended if applicable and different from the firmware name/version.
150+
151+
Example without OS Name: `ESPHome`, `2021.11.0`, `esp32-s3-devkitc-1/esp32-s3`, `Temperature Monitor`.
147152

148-
Example: `ESPHome`, `2021.11.0`, `ESP32-C3`, `Temperature Monitor`.
153+
Example with OS Name: `Bluetooth Proxy`, `v1.0.0`, `denky_d4/esp32`, `My Bluetooth Proxy`, `ESPHome`, `2025.12.2`.
149154

150155
### RPC Command: Request scanned Wi-Fi networks
151156

@@ -172,7 +177,7 @@ The final response (or the first if no networks are found) will have 0 strings i
172177
Sends a request for the device to either get or set its hostname.
173178
This operation is only available while the device is Authorized. Sending the command with no data will return
174179
the current hostname in the response. Sending the command with data will set the hostname to the data and also
175-
return the updated hostname in the response.
180+
return the updated hostname in the response. Setting this property requires the device to be in an 'Authorized' state.
176181

177182
Hostnames must conform to [RFC 1123](https://datatracker.ietf.org/doc/html/rfc1123) and can contain only letters,
178183
numbers and hyphens with a length of up to 255 characters. Error code `0x05` will be returned if the hostname provided is not acceptable.
@@ -195,7 +200,35 @@ Set Hostname:
195200
| 2 | length of hostname |
196201
| 3...X | bytes of hostname |
197202

198-
This command will trigger one RPC Response which will contain the hostname of the device.
203+
This command will trigger one RPC Response which will contain the hostname of the device. Setting this
204+
property should reset the authorization timeout.
205+
206+
### RPC Command: Get/Set Device Name
207+
208+
Sends a request for the device to either get or set its name. This could mean different things depending on the device
209+
manufacturer. It may alter the default "hostname" or not. If setting both this property and hostname, it is recommended
210+
to set the device name first then the hostname. Getting this property should return the same value as the Device Info's
211+
"Device Name" (4th) property. Setting this property requires the device to be in an 'Authorized' state.
212+
213+
Command ID: `0x06`
214+
215+
Get Device Name:
216+
217+
| Byte | Description |
218+
|------|------------------------|
219+
| 1 | command (`0x06`) |
220+
| 2 | 0 data bytes / no data |
221+
222+
Set Device Name:
223+
224+
| Byte | Description |
225+
|-------|--------------------------------|
226+
| 1 | command (`0x06`) |
227+
| 2 | length of device name in bytes |
228+
| 3...X | bytes of device name |
229+
230+
This command will trigger one RPC Response which will contain the Device Name of the device. Setting this
231+
property should reset the authorization timeout.
199232

200233
## Packet: RPC Result
201234

0 commit comments

Comments
 (0)