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

Support REST Api for sending configs and commands to devices (Device Communication API) #19

Open
gdimitropoulos-sotec opened this issue Feb 10, 2023 · 3 comments
Assignees

Comments

@gdimitropoulos-sotec
Copy link
Contributor

gdimitropoulos-sotec commented Feb 10, 2023

As we describe here This is an issue in order to qualify Hono as a replacement for Google IoT Core customers. In Google Iot Core clients can send commands and configs to a device through a REST API. Therefore we would like to add another REST API component to Hono as a replacement, named “Hono Device Communication API”. The new component will cover only communication via the MQTT adapter and will not communicate directly with the devices, but only with the command router.

Workflow

Client sends HTTP command/config requests to the Hono Device Communication API, api sends commands/configs to the command router which forwards them to the device.

Config Data

Config data does not need a specific schema and could be any binary data that a device understands. Configuration data will be stored with config version history.
Config Request
To update device configurations, the client should send a post request to the API and define fields versionToUpdate and binaryData in the request body.

POST https://API_URL/api/v1/config/{tenant-id}/{device-id}

Request body

Schema fields:

{
  "versionToUpdate":  string (int64 format),
  "binaryData": string (bytes format)
}

versionToUpdate field

Every device config has a version id (greater than 0). By updating device configs clients can update a specific config version or if the versionToUpdate field is set to 0, then the current version of configs will be always updated. Config update will fail if requested version does not exist.

binaryData

Any binary data that a specific device can understand.

Response body

If successful, api will return an DeviceConfig.



For more information see Google's IoT API documentation.


DeviceConfig DB

DeviceConfig objects will be saved in a Database so that a client can request them via the API. Database will be also used by MQTT adapter to make sure that all the desired configs have been delivered to the devices and also that all the devices have acknowledged their configs.

Keeping DeviceConfig sync

MQTT adapter after a configuration version was successfully updated, will publish the updated config version with retain set to true and so every device after a new start will always receive the updated current configurations to use.

Hono device communication API

Screenshot 2023-02-17 124422

@julian-sotec
Copy link
Contributor

@calohmn Hi there! May I ask you to assign someone for a review of this issue? If needed we can also do a quick walkthru in virtual meet to have a quick onboarding session

@calohmn
Copy link
Contributor

calohmn commented Feb 27, 2023

@julian-sotec Sorry for the delay. I'm having a look at this issue here and the PR.

@julian-sotec
Copy link
Contributor

julian-sotec commented Feb 27, 2023

@julian-sotec Sorry for the delay. I'm having a look at this issue here and the PR.

Great! Thank you very much. If you need a quick demo / walkthru let us know

calohmn pushed a commit that referenced this issue May 2, 2023
…evice Communication API) (#20)

Signed-off-by: g.dimitropoulos <[email protected]>
calohmn added a commit that referenced this issue May 2, 2023
Fix test error, apply minor corrections.
Also don't build docker-image by default and use
generic docker image name.

Signed-off-by: Carsten Lohmann <[email protected]>
mattkaem referenced this issue in sotec-iot/hono-extras Aug 9, 2023
* added support for device states
* added automatic Pub/Sub tenant topic & subscription creation and deletion
* added automatically sending of a config in case a config is requested or a new one created
* extended config table with error field

Signed-off-by: Matthias Kaemmer <[email protected]>
mattkaem referenced this issue in sotec-iot/hono-extras Aug 9, 2023
- handle commands and configs
- use pubsub as internal message
- updating db for device configs

Signed-off-by: Georgios Dimitropoulos <[email protected]>
mattkaem referenced this issue in sotec-iot/hono-extras Mar 11, 2024
- handle commands and configs
- use pubsub as internal message
- updating db for device configs

Signed-off-by: Georgios Dimitropoulos <[email protected]>
mattkaem referenced this issue in sotec-iot/hono-extras Mar 11, 2024
* added support for device states
* added support for request/response commands
* added automatic Pub/Sub tenant topic & subscription creation and deletion
* added automatically sending of a config in case a config is requested or a new one created
* extended config table with error field
* formatted device communication api code

Signed-off-by: Matthias Kaemmer <[email protected]>
mattkaem referenced this issue in sotec-iot/hono-extras Jun 3, 2024
- handle commands and configs
- use pubsub as internal message
- updating db for device configs

Signed-off-by: Georgios Dimitropoulos <[email protected]>
mattkaem referenced this issue in sotec-iot/hono-extras Jun 3, 2024
* Add support for device states
* Add support for request/response commands
* Add support for ack-required command type and change configs to use ack-required type
* Add retry mechanism for sending configs
* Add automatic Pub/Sub tenant topic & subscription creation and deletion
* Add automatically sending of a config in case a config is requested or a new one created
* Add possibility to change log level
* Update Quarkus dependency and migrated javax dependencies to jakarta
* Improve SQL connection handling
* Format and clean up device communication api code

Signed-off-by: Matthias Kaemmer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants