RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

[POC] Azure Integration in RIOT OS

Open tanvirBsmrstu opened this issue 2 years ago • 3 comments

Contribution description (3 modules, one package, one application)

  1. Zero-touch device provisioning with Device Provisioning Service using X.509 certificate.
  2. Cloud-to-Device and Device-to-Cloud messaging with Azure IoT Hub.
  3. Receiving and parsing Direct method invocation from Azure IoT Hub.
  4. Receiving and parsing Device Twins update notifications from Azure IoT Hub.
  • Azure IoT SDK for embedded C is integrated using a new RIOT package
  • "gnrc_wolfssl_tls" module uses wolfssl and gnrc to achieve TLS
  • "mqtts_riot_iface" module uses paho mqtt package and gnrc_wolfssl_tls module to achieve MQTTS
  • "az_riot_pnp_iface" module is a wrapper on top of MQTTS and azure SDK to provide a Plug-and-play flavour.
  • Scripts are provided to facilitate generating self signed certificates.
  • A demo application /examples/az_pnp_demo is provided with a reach Readme.md file.

Testing procedure

  • A demo application /examples/az_pnp_demo is provided with a reach Readme.md file. Please read carefully the Readme

Current Limitations

DNS is not integrated yet, please see the readme and use IP at the mentioned place for testing. Error handling has to improve a lot.

  • [I will close/delete the other pull request(#20222) so that the code review is clean and easier ]

Thanks, Tanvir Hasan

authored-by: tanvirBsmrstu [email protected]

tanvirBsmrstu avatar Jan 03 '24 10:01 tanvirBsmrstu

I guess the new modules should go into different directories in sys/net.

OlegHahm avatar Jan 04 '24 23:01 OlegHahm

I think the mqtts module should exist in pkg/paho-mqtt/contrib and the tls module should exist in pkg/wolfssl/sock_tls.

WolfSSL already provides something for us in wolfio.h which seems to be something like your TLSContext.

#ifdef WOLFSSL_GNRC
    #include <sock_types.h>
    #include <net/gnrc.h>
    #include <net/af.h>
    #include <net/sock.h>
    #include <net/gnrc/tcp.h>
    #include <net/gnrc/udp.h>

    struct gnrc_wolfssl_ctx {
        union socket_connector {
        #ifdef MODULE_SOCK_TCP
            sock_tcp_t tcp;
        #endif
            sock_udp_t udp;
        } conn;
        WOLFSSL_CTX *ctx;
        WOLFSSL *ssl;

        int closing;
        struct _sock_tl_ep peer_addr;
    };

    typedef struct gnrc_wolfssl_ctx sock_tls_t;

    WOLFSSL_LOCAL int GNRC_ReceiveFrom(WOLFSSL* ssl, char* buf, int sz,
                                     void* ctx);
    WOLFSSL_LOCAL int GNRC_SendTo(WOLFSSL* ssl, char* buf, int sz, void* ctx);

#endif

fabian18 avatar Jan 07 '24 00:01 fabian18

Hi @fabian18, Thank you so much for your time and comments. There are so many things to improve. I would love to have more comments and ideas on how this work can be refactored.

I have seen the structure in the library, but it, by default, includes udp. That's why I did not use that. There might be some scenario where UDP is not needed. Secondly, the implementation of GNRC_** functions are specific to UDP again. I thought changing in the third party code would not be a good idea, that's why I wrote my custom implementation.

tanvirBsmrstu avatar Jan 07 '24 03:01 tanvirBsmrstu