Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial doc for imperial #7

Merged
merged 14 commits into from
Nov 10, 2021
4 changes: 3 additions & 1 deletion src/_includes/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
- - /
- Home
- - /documentation/
- Documentation
- BLE Documentation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't fit in the header. Maybe just do BLE ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change to just BLE and Serial

- - /serial_documentation/
- Serial Documentation
- - /code/
- Code
---
Expand Down
3 changes: 1 addition & 2 deletions src/documentation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: base
title: Documentation
Copy link
Contributor

@balloob balloob Oct 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update the filename too, and add a Netlify redirect so the old URL remains working. Do that by creating a _redirects file like this in the public folder https://github.com/home-assistant/home-assistant.io/blob/current/source/_redirects

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had this exact thought..haha

title: Improv via BLE
description: All the implementation details necessary to make your own client and service implementation.
---

Expand Down Expand Up @@ -143,4 +143,3 @@ This characteristic is where the client can read results from the RPC service if
| X...Y | String 2 |
| ... | etc |
| last byte | Checksum - A simple sum checksum keeping only the LSB |

118 changes: 118 additions & 0 deletions src/serial_documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
layout: base
title: Improv via Serial
description:
---

## Improv via Serial Service

Improv via Serial allows a client to send the Wi-Fi credentials to a device to save via a serial connection.

### Serial packet format

| Byte | Purpose |
| ------ | ------------------------------- |
| 1-6 | Header will equal `IMPROV` |
| 7 | Version CURRENT VERSION = `1` |
| 8 | Type (see below) |
| 9 | Length |
| 10...X | Data |
| X + 10 | Checksum (Not for RPC/Response) |


### Current State (_Device to client_)

Current state type: `0x01`

The current status of the provisioning service and will write and notify any listening clients for instant feedback.

| Value | State | Purpose |
| ------ | ---------------------- | ------------------------------------------------ |
| `0x02` | Ready (Authorized) | Ready to accept credentials. |
| `0x03` | Provisioning | Credentials received, attempt to connect. |
| `0x04` | Provisioned | Connection successful. |
| 3 | Length of string 1 |
| 4...X | String 1 |
| X | Length of string 2 |
| X...Y | String 2 |

### Error state (_Device to client_)

Error state type: `0x02`

This message will be sent with the current error state if it changes for instant feedback.

| Value | State | Purpose |
| ------ | ------------------- | --------------------------------------------------------------------------------------- |
| `0x00` | No error | This shows there is no current error state. |
| `0x01` | Invalid RPC packet | RPC packet was malformed/invalid. |
| `0x02` | Unknown RPC command | The command sent is unknown. |
| `0x03` | Unable to connect | The credentials have been received and an attempt to connect to the network has failed. |
| `0xFF` | Unknown Error | |

### RPC (_Client to device_)

RPC type: `0x03`

This message type is used for the client to send commands to the device.

| Byte | Description |
| ----- | ----------------------------------------------------- |
| 1 | Command (see below) |
| 2 | Data length |
| 3...X | Data |
| X + 3 | Checksum - A simple sum checksum keeping only the LSB |

#### RPC Command: Send Wi-Fi settings

Submit Wi-Fi credentials to the Improv Service to attempt to connect to.

Command ID: `0x01`

| Byte | Description |
| ----- | ---------------- |
| 1 | command (`0x01`) |
| 2 | data length |
| 3 | ssid length |
| 4...X | ssid bytes |
| X | password length |
| X...Y | password bytes |
| Y | checksum |

Example: SSID = MyWirelessAP, Password = mysecurepassword

```
01 1E 0C {MyWirelessAP} 10 {mysecurepassword} CS
```

This command will generate an RPC result. The first entry in the list is an URL to redirect the user to. If there is no URL, omit the entry or add an empty string.

#### RPC Command: Request current state

Sends a request for the device to send the current state of improv to the client.

Command ID: `0x02`

| Byte | Description |
| ---- | ---------------- |
| 1 | command (`0x02`) |

This command will trigger at least one packet, the `Current State` (see above) and if already provisioned, the same response you would get if device provisioning was successful (see below).


### RPC Result (_Device to client_)

RCP response type: `0x04`

This message type contains the response to a RPC command. Results are returned as a list of strings. An empty list is allowed.

| Byte | Description |
| --------- | ----------------------------------------------------- |
| 1 | Command being responded to (see above) |
| 2 | Data length |
| 3 | Length of string 1 |
| 4...X | String 1 |
| X | Length of string 2 |
| X...Y | String 2 |
| ... | etc |
| last byte | Checksum - A simple sum checksum keeping only the LSB |