This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Some example using AWS IoT library (subsys/net/lib/aws_iot/)

Hello guys,

We are developing a device that will based on nRF9160 SiP. We use nRFConnect SDK v1.3.0. The goal would be to connect to AWS IoT through MQTT and exchange messages. I used cloud_client example from nrf/samples/nrf9160 as a starting point and was able to establish a connection with the AWS IoT Thing (details here).

I noticed there is an AWS IoT library located at nrf/subsys/net/lib/aws_iot/ that would probably be more suitable for us to use.

Is there any sample that can help us understand how to use that library? Basically, what we need to put inside Kconfig and prj.conf files to properly configure our project?

Thanks in advance for your time and efforts.

Sincerely,

Bojan.

Parents Reply Children
  • Hi! The case you linked to has been assigned to another engineer who will answer that question for you.

    I can tell you that modem_configure returning error 120 means the socket is already connected, i.e. you don't need to configure the modem again. You are disconnecting from the cloud backend, not the network, so you don't need to run modem_configure every time you disconnect. 

    cloud_uninit returning error 134 means not supported, which I think might be because the AWS IoT library does not have an uninit function. To disconnect from the cloud, it should be enough to run the cloud_disconnect function. 

  • Hello, .

    Thanks for the great explanation. You were right about both:

    1) There is no cloud_uninit(cloud_backend)function in AWS_IoT library. Consequently, we can delete that line of the code from the disconnect procedure.

    2) The socket was already connected so there was no need to call modem_configure()

    So, if we disconnect from the cloud by simply calling cloud_disconnect(cloud_backend)function, we were able to re-connect by omitting modem_configure() function.

    However, in our system, the modem should be normally off and active only during the rare periods when we want to upload data. If we keep the socket connected, that would suck the juice from our battery so there is a need to completely turn off the modem between connection periods.

    I tried to onclude two more functions that would turn off the modem after disconnection from the cloud:

    cloud_disconnect(cloud_backend);
    lte_lc_offline();
    lte_lc_power_off();

    However, with those two functions included, we were unable to re-connect (with and without modem_configure() function included)!

    What would be the steps to completely turn off the modem and re-activate it again when we need it?

    Thanks in advance!

    Bojan.

  • Hello again, if you're worried about battery consumption, completely disconnecting from the network each time is not the best way to go about this.

    I recommend you have a look at Power Saving Mode and check if your network operator supports this feature, and then go into PSM instead of completely de-attaching from the network. 

Related