Skip to content

Commit

Permalink
Merge branch 'dev' into 'master'
Browse files Browse the repository at this point in the history
Merge request release 3.1.0

See merge request smartme.io/arancino/arancino-library!42
  • Loading branch information
andrea-83 committed Apr 14, 2023
2 parents 8597c9f + 564f73a commit 81f1f9d
Show file tree
Hide file tree
Showing 101 changed files with 3,341 additions and 3,236 deletions.
50 changes: 32 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

#### v 3.1.0 - 2023.04.06
* Upd: Implemented new Cortex protocol [#1jdx7ak](https://app.clickup.com/t/1jdx7ak)
* Add: Added support to ESP32 [#863gbd6ym](https://app.clickup.com/t/863gbd6ym)
* Add: Added support to NRF52 [#863gbd74b](https://app.clickup.com/t/863gbd74b)
* Upd: Increased Serial timeout [#33kn3c2](https://app.clickup.com/t/33kn3c2)
* Upd: Renamed task GetBlinkId [#31ewyzv](https://app.clickup.com/t/31ewyzv)
* Upd: Updated examples [#23n7teq](https://app.clickup.com/t/23n7teq)
* Upd: Manage new DB instance for configuration keys [#23fqct7](https://app.clickup.com/t/23fqct7)
* Upd: Introduced ACK in `SET` methods [#23fpyp2](https://app.clickup.com/t/23fpyp2)
* Upd: Service functions in a single task [#861mjudeh](https://app.clickup.com/t/861mjudeh)
* Upd: Ifaces adapted to new protocol [#861mjue8p](https://app.clickup.com/t/861mjue8p)
* Upd: Fixed warnings in `const char*` conversion [#863gbd62q](https://app.clickup.com/t/863gbd62q)
* Upd: Added check for client connection when using MQTT [#863ge1z5k](https://app.clickup.com/t/863ge1z5k)

#### v 3.0.0 - 2022.10.10
* Add: added interface system with MQTT and BLE_UART communication mediums [#1nwtwna]
* Upd: improved debug messages handling [#1ww0cnr]
Expand All @@ -12,32 +26,32 @@
* Fix: fixed an error in STORE_packet example

#### v 2.1.0 - 2022.07.29
* Upd: ERR_GENERIC was redefined as ERR [#1jz91mu] (https://app.clickup.com/t/1jz91mu)
* Upd: ID_PREFIX removed from `store`, `mstore` and `storeTags` commands [#23v2xn3] (https://app.clickup.com/t/23v2xn3)
* Add: added executeCommandFast command [#394mek4] (https://app.clickup.com/t/394mek4)
* Add: added `mstore` with timestamp argument [#394memb] (https://app.clickup.com/t/394memb)
* Upd: ERR_GENERIC was redefined as ERR [#1jz91mu](https://app.clickup.com/t/1jz91mu)
* Upd: ID_PREFIX removed from `store`, `mstore` and `storeTags` commands [#23v2xn3](https://app.clickup.com/t/23v2xn3)
* Add: added executeCommandFast command [#394mek4](https://app.clickup.com/t/394mek4)
* Add: added `mstore` with timestamp argument [#394memb](https://app.clickup.com/t/394memb)

#### v 2.0.1 - 2022.05.27
* Fix: bug debug for arancino mignon board. [#2g4fxvx] (https://app.clickup.com/t/2g4fxvx)
* Fix: bug debug for arancino mignon board. [#2g4fxvx](https://app.clickup.com/t/2g4fxvx)

#### v 2.0.0 - 2022.01.17
* Upd: updated unit test examples. [#1uqbjbp] (https://app.clickup.com/t/1uqbjbp)
* Add: added useFreeRtos parameter in `start` command. [#1vht0nc] (https://app.clickup.com/t/1vht0nc)
* Fix: bug into `deviceIdentification` task. [#1w8qx9m] (https://app.clickup.com/t/1w8qx9m)
* Add: added examples wthout freeRtos. [#1vhrhj2] (https://app.clickup.com/t/1vhrhj2)
* Fix: read internal temperature for STM32. [#pbbnm1] (https://app.clickup.com/t/pbbnm1)
* Udp: code revision. [#j58vz6] (https://app.clickup.com/t/j58vz6)
* Udp: examples revision. [#jd3yjq] (https://app.clickup.com/t/jd3yjq)
* Add: read internal temperature for STM32. [#pbbnm1] (https://app.clickup.com/t/pbbnm1)
* Upd: updated unit test examples. [#1uqbjbp](https://app.clickup.com/t/1uqbjbp)
* Add: added useFreeRtos parameter in `start` command. [#1vht0nc](https://app.clickup.com/t/1vht0nc)
* Fix: bug into `deviceIdentification` task. [#1w8qx9m](https://app.clickup.com/t/1w8qx9m)
* Add: added examples wthout freeRtos. [#1vhrhj2](https://app.clickup.com/t/1vhrhj2)
* Fix: read internal temperature for STM32. [#pbbnm1](https://app.clickup.com/t/pbbnm1)
* Udp: code revision. [#j58vz6](https://app.clickup.com/t/j58vz6)
* Udp: examples revision. [#jd3yjq](https://app.clickup.com/t/jd3yjq)
* Add: read internal temperature for STM32. [#pbbnm1](https://app.clickup.com/t/pbbnm1)
* Add: Arduino `loop` as FreeRtos task. [#p59vhb](https://app.clickup.com/t/p59vhb)
* Fix: fixed bug with float and double using FreeRtos. [#n990qu](https://app.clickup.com/t/n990qu)
* Add: added interocep function. [#d2x5yt](https://app.clickup.com/t/d2x5yt)
* Add: added `setReserved` function. [#n1amcu](https://app.clickup.com/t/n1amcu)
* Upd: removed deprecated arguments on the `begin` function. [fb6jve] (https://app.clickup.com/t/fb6jve)
* Upd: removed `metadata` function. [fb6hyw] (https://app.clickup.com/t/fb6hyw)
* Upd: removed check on reserved command. [fv2dmy] (https://app.clickup.com/t/fv2dmy)
* Upd: updated sync/async mode. [fd59jj] (https://app.clickup.com/t/fd59jj)
* Add: added persistent mode to `mset` and `hset` function. [aex4by] (https://app.clickup.com/t/aex4by)
* Upd: removed deprecated arguments on the `begin` function. [fb6jve](https://app.clickup.com/t/fb6jve)
* Upd: removed `metadata` function. [fb6hyw](https://app.clickup.com/t/fb6hyw)
* Upd: removed check on reserved command. [fv2dmy](https://app.clickup.com/t/fv2dmy)
* Upd: updated sync/async mode. [fd59jj](https://app.clickup.com/t/fd59jj)
* Add: added persistent mode to `mset` and `hset` function. [aex4by](https://app.clickup.com/t/aex4by)
* Add: added `getReserved` function. [g31n4z](https://app.clickup.com/t/g31n4z)
* Add: added `store` function. [#gk4cn8](https://app.clickup.com/t/gk4cn8)
* Add: added `storetags` function. [#hf2fg6](https://app.clickup.com/t/hf2fg6)
Expand Down
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,19 @@ Arancino Library allows to export/import data to/from the Linux environment usin

- [FreeRTOS](docs/FREERTOS.md)

- Insights

- [Cortex Protocol](CORTEX_PROTOCOL.md)
- [Cortex Protocol](docs/CORTEX.md)

- [Debug](docs/DEBUG.md)

- [Reserved Keys](docs/RESERVED_KEYS.md)

## Compatibility list
The Arancino Library `2.1.0` officially supports the following Arancino Core versions:
The Arancino Library `3.1.0` officially supports the following Arancino Core versions:
|Board| Core Version |
|--|--|
| SAMD21 | 1.3.0 |
| nRF52 | 1.1.0 |
| RP2040 | 1.1.0 |
| STM32 | 1.0.0 |
| SAMD21 | 1.4.0 |
| nRF52 | 1.1.1 |
| RP2040 | 1.2.1 |


## Credits
Expand All @@ -40,4 +37,4 @@ Most of this documentation has been extrapolated from [Redis Command](https://re



Redis, Arduino, Atmel, Nordic, STMicroelectronics, RaspberryPi and FreeRTOS are trademarks of their respective owners.
Redis, Arduino, Atmel, Nordic, STMicroelectronics, RaspberryPi and FreeRTOS are trademarks of their respective owners.
139 changes: 4 additions & 135 deletions docs/CORTEX.md
Original file line number Diff line number Diff line change
@@ -1,139 +1,8 @@
## Cortex Protocol
Arancino Library uses a simple protocol, called **Cortex**, to communicate with the Arancino Module over serial connection. Cortex Protocol is designed to be easy to read and processed. Arancino Library, Arancino Module and Cortex Protocol are designed to be monodirectional and synchronous. In this scenario the Arancino Library within the microcontroller acts as *master*, and the Arancino Module as *slave*.


Each command sent using Cortex Protocol is composed by a *command identifier* and one or more *parameters*. *Command identifiers* and *parameters* are separated by a separator character, and the command ends with an end character. Each command sent will receive a response, formed by a Response Code and one or more returned values. All the items are separated by the same separtor character and ends with the same end character. The commands receive Response within a timeout interval of `100ms`. If no Response is received, the Command will be skipped.

### Commands identifier:


| API | Command Identifiers |
| ------------------ |:-------------:|
| [`begin`](#begin) | START |
| [`set`](#set) | SET |
| [`get`](#get) | GET |
| [`mset`](#mset) | MSET |
| [`mget`](#mget) | MGET |
| [`del`](#del) | DEL |
| [`keys`](#keys) | KEYS |
| [`hget`](#hget) | HGET |
| [`hset`](#hset) | HSET |
| [`hkeys`](#hkeys) | HKEYS |
| [`hvals`](#hvals) | HVALS |
| [`hdel`](#hdel) | HDEL |
| [`flush`](#flush) | FLUSH |
| [`publish`](#publish) | PUB |
| [`mset`](#mset) | MSET |
| [`mget`](#mget) | MGET |
| [`store`](#store) | STORE |
| [`storetags`](#storetags)| STORETAGS|

### Commands separator chars
**Important**: Do not use these character codes to compose string values to pass to the API

| Separator | Char Code |
| --------------------- |:-------------:|
| Command Sepatator | `4` |
| Array separator | `16` |
| NULL character | `25` |
| End of transmission | `30` |


### Response Codes
| Response Code | Type | Description | Note |
|-------|-----------|-------------|------|
| `100` | Success | Generic operation successfully completed ||
| `101` | Success | Setted value into a new field ||
| `103` | Success | Setted value into an existing field ||
| `200` | Error | Generic Error | |
| `201` | Error | Retrivied Null Value | Deprecated|
| `202` | Error | Error during SET command ||
| `203` | Error | Command not found ||
| `204` | Error | Error during SET command ||
| `205` | Error | Invalid parameter number ||
| `206` | Error | Generic Redis Error ||
| `207` | Error | Key exists in the Standard Data Store ||
| `208` | Error | Key exists in the Persistent Data Store ||
| `209` | Error | Non compatibility between Arancino Daemon and Library ||
| `210` | Error | Generic Invalid Arguments ||
| `211` | Error | Invalid Value ||
| `212` | Error | Not yet implemented functionality ||
Arancino Library uses a simple protocol, called **Cortex**, to communicate with the Arancino Module using multiple connection Interfaces (MQTT,Serial,Bluetooth). Cortex Protocol is designed to be easy to read and processed. Arancino Library, Arancino Module and Cortex Protocol are designed to be monodirectional and synchronous. In this scenario the Arancino Library within the microcontroller acts as *master*, and the Arancino Module as *slave*.

Each command sent using Cortex Protocol is composed by a *command identifier* and one or more *parameters*. *Command identifiers* and *parameters* are formatted inside a *JSON* and the message itself is compressed into a *MessagePack*. Each command sent will receive a response, formed by a Response Code and one or more returned values. The commands receive Response within a timeout interval. If no Response is received, the Command will be skipped.

### Commands and Protocol
As exaplained above, when an API function is called, a command is sent over the `SerialUSB` and a response is received.
In the next paragraphs, for simplicity we are considering each command returns an *OK* response and using the following representation for *Separator Codes*:

- Command Sepatator → `4``#`
- Array separator → `16``%`
- End of transmission → `30`` @`

#### begin
- Command Sent: `START#<lib vers>#<fwname>#<fwversion>#<compiletime>#<coreversion>@`
- Response Received: `100@`

#### set
- Command Sent: `SET#<key>#<value>@`
- Response Received: `100@`

#### get
- Command Sent: `GET#<key>@`
- Response Received: `100#<value>@`

#### mset
- Command Sent: `MSET#<key-1>%<key-2>...%<key-n>#<val-1>%<val-2>...%<val-n>@`
- Response Received: `100#@`

#### mget
- Command Sent: `MGET#<key-1>%<key-2>...%<key-n>@`
- Response Received: `100#<val-1>#<val-2>...#<val-n>]@`

#### del
- Command Sent: `DEL#<key>@`
- Response Received: `100#1@`

#### keys
- Command Sent: `KEYS#<pattern>@`
- Response Received: `100[#<key-1>#<key-2>#<key-n>]@`

#### hset
- Command Sent: `HSET#<key>#<field>#<value>@`
- Response Received: 101@

#### hget
- Command Sent: `HGET#<key>#<field>@`
- Response Received: `100#<value>@`

#### hgetall
- Command Sent: `HGETALL#<key>@`
- Response Received: `100#<field-1>#<value-1>#<field-2>#<value-2>@`

#### hkeys
- Command Sent: `HKEYS#<key>@`
- Response Received: `100HKEYS#<key>@`

#### hvals
- Command Sent: `HVALS#<key>@`
- Response Received: `100#<value-1>#<value-2>@`

#### hdel
- Command Sent: `HDEL#<key>#<field>@`
- Response Received: `100#1@`

#### flush
- Command Sent: `FLUSH@`
- Response Received: `100@`

#### storetag
- Command Sent: `STORE#<key>#<tag1>%<tag2>%<tag3>#<value1>%<value2>%<value3>#<timestamp>@`
- Response Received: `100@`

- Command Sent: `STORE#<key>#<tag1>%<tag2>%<tag3>#<value1>%<value2>%<value3>@`
- Response Received: `100@`

#### store
- Command Sent: `STORE#<key>#<values>@`
- Response Received: `100#<timestamp>@`

- Command Sent: `STORE#<key>#<values>#<timestamp>@`
- Response Received: `100#<timestamp>@`
As exaplained above, when an API function is called, a command is sent over the `ArancinoInterface` and a response is received.
More details about the command structure and relative responses may be found in the [Cortex Protocol](Cortex_Protocol/README.md) section.
88 changes: 88 additions & 0 deletions docs/Cortex_Protocol/DEL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# `DEL`
Delete the specified *keys*.

>Note:
>
>- A *key* is ignored if it does not exist.
>- The specified *keys* will be deleted even if they were previously stored in a *persistent* way based on the `pers` configuration. You can only delete "application" keys (`"type":"appl"`)
## **Command**

**Arguments:**

| Args Type | Desc | Mandatory |
| ----- | --------- | --------- |
| `items`: String Array | Array of *keys* to delete | **Yes** |

**Configuration:**

| Key | Desc | Mandatory |
| :------ | :-------------------------------------- | -------------------------------- |
| `pers:` Number | Allows to del keys from the persistent datatstore. To use only with `"type": "appl"`. Allowed values: `0` is *False* and `1` is *True* | **No** |
| `ack:` Number | Indicates whether a *response* (the ack) should be sent for the *command*. *True* by default. Allowed values: `0` is *False* and `1` is *True*| **No** |
| `sgntr`: String | Signature used for ECDSA Authentication | **No**: used only in *Secure Mode* |

**Example:**

```json
{
"cmd": "DEL",
"args":{
"items":[
"<key1>"
]
},
"cfg":{
"ack": 1,
"pers": 0,
"sgntr": "<Signature>"
}
}
```

```json
{
"cmd": "DEL",
"args":{
"items":[
"<key-1>", "<key-2>", "<key-n>"
]
},
"cfg":{
"ack": 0,
"pers": 1,
"sgntr": "<Signature>"
}
}
```

## **Response**

**Arguments:** Empty
| Key | Desc | Mandatory |
| ------- | ----------------------------------------- | -------------------------------- |
| `keys`: Number | Number of deleted keys | **Yes** |

**Configuration:**

| Key | Desc | Mandatory |
| ------- | ----------------------------------------- | -------------------------------- |
| `chlng` | Challenge useful to sign the next command | No: used only in Secure Protocol |

**Examples:**

```json
{
"rsp_code": "100",
"args":{
"keys": <n>
},
"cfg":{
"chlng": "<challenge>"
}
}
```

>Note:
>
>- List of possible Error Codes for `DEL`: `200`,`206` **Da controllare per aggiunta anche di errori presenti durante il protocollo sicuro
58 changes: 58 additions & 0 deletions docs/Cortex_Protocol/FLUSH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#### `FLUSH`
Delete all the keys.

>Note:
>
>- This command never fails.
## **Command**

**Arguments:** Empty

**Configuration:**

| Key | Desc | Mandatory |
| :------ | :-------------------------------------- | -------------------------------- |
| `pers:` Number | Allows to delete persistent or volatile keys. False by default. Allowed values: `0` is _False_ and `1` is _True_ | **No** |
| `ack:` Number | Indicates whether a *response* (the ack) should be sent for the *command*. *True* by default. Allowed values: `0` is *False* and `1` is *True*| **No** |
| `sgntr`: String | Signature used for ECDSA Authentication | No: used only in Secure Protocol |

**Example:**

```json
{
"cmd": "FLUSH",
"args":{},
"cfg":{
"pers": 0,
"ack": 1,
"sgntr": "<Signature>"
}
}
```

## **Response**

**Arguments:** None

**Configuration:**

| Key | Desc | Mandatory |
| ------- | ----------------------------------------- | -------------------------------- |
| `chlng`: String | Challenge useful to sign the next command | No: used only in Secure Protocol |

**Examples:**

```json
{
"rsp_code": "100",
"args":{},
"cfg":{
"chlng": "<challenge>"
}
}
```

>Note:
>
>- List of possible Error Codes for `FLUSH`: `200`, `206` **Da controllare per l'aggiunta anche di errori presenti durante il protocollo sicuro
Loading

0 comments on commit 81f1f9d

Please sign in to comment.