mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-12-23 00:45:53 -05:00
doc: basic message types
This commit is contained in:
parent
993fe1b883
commit
c8de5d7847
19
107.md
19
107.md
|
@ -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>,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user