From c8de5d78477efeac6fb2a7bd187d2c82eb7bd519 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Thu, 19 Oct 2023 13:27:29 +0300 Subject: [PATCH] doc: basic message types --- 107.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/107.md b/107.md index 0bcac5b0..030d56d4 100644 --- a/107.md +++ b/107.md @@ -26,23 +26,32 @@ Where the `user` registers 'device'(s) and its keys, then updates the `device`(s ### Device -The `device` uses a client like nostr-arduino to receive commands from the `user` or another `device`. +The `device` uses a client like nostr-arduino to receive commands from the `user` or another `device`. 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: | Kind | | Description | NIP | |---------|------------------|---------------------------------------------------------------------------------------------------------------|-----------------------------------------| -| `4 ` | `direct_message` | Communicate between two `devices` or between a `device` and a `user`.
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`.
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**: ```json { - "id": , + "type": , "device_id": , "name": , "description": ,