doc: basic message types

This commit is contained in:
Vlad Stan 2023-10-19 13:27:29 +03:00 committed by GitHub
parent 993fe1b883
commit c8de5d7847
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

19
107.md
View File

@ -26,23 +26,32 @@ Where the `user` registers 'device'(s) and its keys, then updates the `device`(s
### Device ### Device
The `device` uses a client like <a href="https://github.com/lnbits/arduino-nostr">nostr-arduino</a> to receive commands from the `user` or another `device`. The `device` uses a client like <a href="https://github.com/lnbits/arduino-nostr">nostr-arduino</a> to receive commands from the `user` or another `device`.
The `device` can also push data such as sensor readings and updates. The `device` can also push data such as sensor readings and updates.
## `User` OR `device` registering/updating a `user` OR `device` ## Events
A `device` or a `user` can publish these event kinds: A `device` or a `user` can publish these event kinds:
| Kind | | Description | NIP | | Kind | | Description | NIP |
|---------|------------------|---------------------------------------------------------------------------------------------------------------|-----------------------------------------| |---------|------------------|---------------------------------------------------------------------------------------------------------------|-----------------------------------------|
| `4 ` | `direct_message` | Communicate between two `devices` or between a `device` and a `user`.<br/>The messages must be a JSON following the structure defined In this NIP. | [NIP04](https://github.com/nostr-protocol/nips/blob/master/04.md) | | `4 ` | `direct_message` | Communicate between two `devices` or between a `device` and a `user`.<br/>The messages must be a JSON following the structures defined In this NIP. | [NIP04](https://github.com/nostr-protocol/nips/blob/master/04.md) |
### Messages
JSON messages that represent different actions or states can be exchanged between two or more `devices` or between `users` and `devices`.
Each `JSON` message `MUST` have a `type` field indicating the what the JSON represents. Possible types:
### Event: Register a `device` | Message Type | Sent By | Description |
|--------------|----------------|------------------|
| 0 | User | Configure Device |
| 1 | User \| Device | Command |
| 2 | Device | State Data |
### Event: Configure `device`
**Event Content**: **Event Content**:
```json ```json
{ {
"id": <String, UUID generated by the user.Sequential IDs (`0`, `1`, `2`...) are discouraged>, "type": <String, UUID generated by the user.Sequential IDs (`0`, `1`, `2`...) are discouraged>,
"device_id": <String, UUID of the device>, "device_id": <String, UUID of the device>,
"name": <String, device name>, "name": <String, device name>,
"description": <String (optional), device description>, "description": <String (optional), device description>,