Skip to content

Commit 781b795

Browse files
authored
Add Hostname RPC command (#59)
* Add Device Info to BLE specification * Adding Wifi network scanning command to BLE spec * Changes from review * Add Hostname RPC command to serial and ble
1 parent 0002465 commit 781b795

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

src/ble.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ The client is able to send a `device info` to the Improv service if it is in the
3636
- 2.0 - Added Service Data `4677`
3737
- 2.1 - Added Device Info RPC command
3838
- 2.2 - Added Scan Wifi RPC command
39+
- 2.3 - Added Hostname RPC command
3940

4041
## GATT Services
4142

@@ -50,6 +51,8 @@ This characteristic has binary encoded byte(s) of the device’s capabilities.
5051
| `0` | 1 if the device supports the identify command. |
5152
| `1` | 1 if the device supports the device info command. |
5253
| `2` | 1 if the device supports the scan wifi command. |
54+
| `3` | 1 if the device supports the hostname command. |
55+
5356

5457
### Characteristic: Current State
5558

@@ -71,12 +74,13 @@ Characteristic UUID: `00467768-6228-2272-4663-277478268002`
7174
This characteristic will hold the current error of the provisioning service and will write and notify any listening clients for instant feedback.
7275

7376
| Value | State | Purpose |
74-
| ------ | ------------------- | --------------------------------------------------------------------------------------- |
77+
|--------|---------------------|-----------------------------------------------------------------------------------------|
7578
| `0x00` | No error | This shows there is no current error state. |
7679
| `0x01` | Invalid RPC packet | RPC packet was malformed/invalid. |
7780
| `0x02` | Unknown RPC command | The command sent is unknown. |
7881
| `0x03` | Unable to connect | The credentials have been received and an attempt to connect to the network has failed. |
7982
| `0x04` | Not Authorized | Credentials were sent via RPC but the Improv service is not authorized. |
83+
| `0x05` | Bad Hostname | The hostname provided was not valid or acceptable by the device. |
8084
| `0xFF` | Unknown Error |
8185

8286
### Characteristic: RPC Command
@@ -181,6 +185,38 @@ Example: `MyWirelessNetwork`, `-60`, `WPA2`, `MyOtherWirelessNetwork`, `-52`, `W
181185

182186
A response with no strings means no SSID was found.
183187

188+
### RPC Command: Get/Set Hostname
189+
190+
Sends a request for the device to either get or set its hostname.
191+
This operation is only available while the device is Authorized. Sending the command with no data will return
192+
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.
194+
195+
Hostnames must conform to [RFC 1123](https://datatracker.ietf.org/doc/html/rfc1123) and can contain only letters,
196+
numbers and hyphens with a length of up to 255 characters. Error code `0x05` will be returned if the hostname provided is not acceptable.
197+
198+
Command ID: `0x05`
199+
200+
Get Hostname:
201+
202+
| Byte | Description |
203+
|------|------------------------|
204+
| 05 | command (`0x05`) |
205+
| 00 | 0 data bytes / no data |
206+
| CS | checksum |
207+
208+
Set Hostname:
209+
210+
| Byte | Description |
211+
|------|--------------------|
212+
| 05 | command (`0x05`) |
213+
| XX | length of hostname |
214+
| | bytes of hostname |
215+
| CS | checksum |
216+
217+
This command will trigger one RPC Response which will contain the hostname of the device.
218+
219+
184220
### Characteristic: RPC Result
185221

186222
Characteristic UUID: `00467768-6228-2272-4663-277478268004`

src/serial.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Error state can be the following values:
7575
| `0x01` | Invalid RPC packet | RPC packet was malformed/invalid. |
7676
| `0x02` | Unknown RPC command | The command sent is unknown. |
7777
| `0x03` | Unable to connect | The credentials have been received and an attempt to connect to the network has failed. |
78+
| `0x05` | Bad Hostname | The hostname provided was not valid or acceptable by the device. |
7879
| `0xFF` | Unknown Error | |
7980

8081
## Packet: RPC Command
@@ -166,6 +167,36 @@ Example: `MyWirelessNetwork`, `-60`, `YES`.
166167

167168
The final response (or the first if no networks are found) will have 0 strings in the body.
168169

170+
### RPC Command: Get/Set Hostname
171+
172+
Sends a request for the device to either get or set its hostname.
173+
This operation is only available while the device is Authorized. Sending the command with no data will return
174+
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.
176+
177+
Hostnames must conform to [RFC 1123](https://datatracker.ietf.org/doc/html/rfc1123) and can contain only letters,
178+
numbers and hyphens with a length of up to 255 characters. Error code `0x05` will be returned if the hostname provided is not acceptable.
179+
180+
Type: `0x03`<br>
181+
Command ID: `0x05`
182+
183+
Get Hostname:
184+
185+
| Byte | Description |
186+
|------|------------------------|
187+
| 1 | command (`0x05`) |
188+
| 2 | 0 data bytes / no data |
189+
190+
Set Hostname:
191+
192+
| Byte | Description |
193+
|-------|--------------------|
194+
| 1 | command (`0x05`) |
195+
| 2 | length of hostname |
196+
| 3...X | bytes of hostname |
197+
198+
This command will trigger one RPC Response which will contain the hostname of the device.
199+
169200
## Packet: RPC Result
170201

171202
Type: `0x04`<br>

0 commit comments

Comments
 (0)