How to connect a device using direct device integration API(DDI) in Eclipse hawkbit

754 views Asked by At

I am new to hawkbit and I want to test things out a little bit, I am trying to eclipse hawkbit to the company I work in as an intern. There are a few things I understand and a few things I do not understand. I would really appreciate it if someone could explain how the DDI Direct Device Integration works in simple terms: On the hawkbit official website I read about it but I do not understand how I can connect my Raspberry Pi for example as a target in the management UI:

  1. What I have: Hawkbit running completely fine (Simulator, RabbitMQ, MySQL and Hawkbit update server in docker containers). I played around with the simulator seems to be working fine.

  2. What I need to know: How do i connect a device to the management UI as a target so i can rollout updates(DDI)? What commands do I have to use specifically(the curl commands for example and the header)I could really use a screenshot or an example on how the header and authorization token is done through the HTTP GET request. (I hope i am making sense) Last question: Do I make a client programm(like a python application) to run the updates(Please explain to me how this should exactly work)

There is lovely content on the official website and the github page to answer my questions but i read it and I am not able to figure it out 100%. Therefore I am here asking questions. Screenshots, example snippets, explanation would be much appreciated Thank you

2

There are 2 answers

3
Alexander Dobler On

Starting with the last part of your question, yes you will need some kind of client programm to run updates on your device. HawkBit itself only provides the server side service to manage the updates and assign them to devices. As the use cases on client side vary a lot hawkBit does not take assumption about the update content and process. The devices need to use the APIs to check for updates and can download them if offered, but they are in charge of handling the update process (e.g. unpack, copy the files to a directory, install firmware, but this all is client specific). There are update client solutions that are compatible with hawkBit itself though you can find a small collection on the hawkbit GitHub page, see here.

Regarding the first part of your question, for a good first overview of the update process there is a hawkBit101 tutorial, see here (you can navigate between slides using arrow keys or hjkl). It provides an introduction into the basic concept and also dynamic snippets to be executed in curl (note the curl2clipboard links) or a REST client. You can also execute them on your Pi (just adapt the hostname to point to your hawkbit machine instead of localhost). Also keep the hawkBit DDI API documentation at hand in case of the need for further details.

0
Zygmunt Krynicki On

You can trivially curl into the DDI api, all you need is to pick authentication (device token or shared token for all devices) and GET the URL listed in the DDI api documentation.

From there you can find things that HawkBit thinks the particular device should do - respond to configuration update request, cancel a deployment or perform a deployment. Most of this is somewhat simple but the devil is in the details.

The only header you need is to pass the authentication token ("Authentiation: TargetToken secret" or "Authentiation: GatewayToken: secret"). The URL to use is "$HOST/$TENANT/controller/v1/$TARGET_ID" where $HOST is the URL of hawkbit itself, $TENANT is usually "DEFAULT" and "$TARGET_ID" is the device identifier (controller_id and target_id are synonyms).

Be mindful of Accept headers, you want to accept "application/hal+json". Some (rare) endpoints require content type "application/json".

When you finally get a grip you have to know one more thing: you have to deliver feedback messages to drive hawkbit. The details are tricky. Read the DDI docs and try out with curl to see what really happens. The key thing to get is the "final" feedback that closes the action and prevents any further updates from being sent. You must sequence your feedback so that that message is always sent last.

I maintain a go-hawkbit library at gitlab.com/zygoon/go-hawkbit where I have some of the bits but DDI package is currently not open source, so you have to ask more specific questions or develop things yourself.