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

asset_tracker_v2 without aws

Hello all,

I try to get the asset tracker v2 to work against a eclipse mqtt broker. For the first steps I use the mqtt.eclipseprojects.io broker before I hosting my own broker.

First step was I use the mqtt simple project and get this running against that broker.

Second step was I try to implement my own cloud libary and use aws_iot.c/aws_iot.h/aws_iot_integration.c as an inspiration and put this library into the asset_tracker_v2 instead of AWS, but this was a little bit overwhelming and I run all the time in build errors.

So I thought  to get a better understanding of what everything does, how the messages look, etc. I use the asset_tracker_v2 sample as it is, disable all the tls an fota stuff manually, wrote some more logs and then use the mqtt.eclipseprojects.io instead of an aws broker. I know this this not will be working correctly, cause asset_tracker check it's settings against cloud, etc. But just to get a little bit more insight here and there.

At the moment I be able to publish the first mqtt message $aws/things/CLIENTID/shadow/get with an empty message payload against the mqtt.eclipseprojects.io broker (request of the shadow document), get the Cloud module to sub_state_cloud connected. After a while the SENSOR_EVT_ENVIRONMENTAL_DATA_READY event happens, but the modem tells me MODEM_EVT_MODEM_STATIC_DATA_NOT_READY / MODEM_EVT_MODEM_DYNAMIC_DATA_NOT_READY / MODEM_EVT_BATTERY_DATA_NOT_READY, (all with the 3 errors:

<err> modem_info_params: Link data not obtained: 20 -5

<err> modem_info_params: Network data not obtained: -5

<err> modem_module: modem_info_params_get, error: -11

but the Event handler goes in mode DATA_EVT_DATA_READY and DATA_EVT_DATA_SEND

then I get a log I implemented of the Json message which should be published and then (when it try's to publish this message via mqtt) the firmware breaks and zephyr booted new.

Is this all because the application doesn't get any configuration from the cloud?

What I not really get is, that the modem is ready to send the empty message (shadow document request) in the first place (I also see it with a client which is subscribed to the mqtt.eclipseprojects.io broker) but after this it seem's to be not ready anymore, but I get no log message or anything about a Event or state change in it.

My goal is to collect the sensor data and gps data of the thingy and then publish it to a own eclipse broker hosted in the Open Telekom Cloud
in a first step I don't want to use communication via tls and also no update of the device, so no subscribes from the device are necesary (just to simplify everything a little bit). 

later on I want to use tls and the other fancy stuff, I also find the passive mode really interesting and I really like the asset_tracker_v2 firmware, everything is nice handled via own threads and events. And this is the reason because I started to change asset_tracker_v2 in the first place. It has so many features I want to use later on as well.

Do you think there is any chance for me to go on, or should I step back to mqtt simple and go from there with implementation of sensor data collection, cJSON, build my own Eventhandler and so on.

thank you very much in Advance for any advice.

Have a nice Day.
Greetings

Rudolph

  • Hello Rudolph, 

    I've discussed your issue with our developers working with the Asset Tracker v2. Basically you need to look at the cloud folder (nrf\applications\asset_tracker_v2\src\cloud), specifically aws_iot_integration.h and cloud_wrapper.h. The best way is copy the aws_iot_integration, and base you communication on this. Just change e.g. aws_iot_send to mqtt_publish. Have a look at mqtt_simple to test the mqtt communication to your broker first.

    Second step was I try to implement my own cloud libary and use aws_iot.c/aws_iot.h/aws_iot_integration.c as an inspiration and put this library into the asset_tracker_v2 instead of AWS, but this was a little bit overwhelming and I run all the time in build errors.

     You should not touch these files as these are more specific to AWS. 

     

    Do you think there is any chance for me to go on, or should I step back to mqtt simple and go from there with implementation of sensor data collection, cJSON, build my own Eventhandler and so on.

     Yes, you should be able to do this. For cJSON, have a look at aws_iot_codec.c, found under nrf\applications\asset_tracker_v2\src\cloud\cloud_codec\

    Lets start with me know how that works for you!

    Kind regards,
    Øyvind

  • Hello Rudolph, 

    Our developers have been testing and have tested and configure something similar to what you should need in this Git branch: https://github.com/jhn-nordic/sdk-nrf/tree/atv2_mqtt_backend_poc/applications/asset_tracker_v2

    Just have a look at the latest changes, then change what you need for your project Slight smile

    Kind regards,
    Øyvind

  • Hey Øyvind,

    thanks a lot for your two statements. I was nearly done with my first code version of using mqtt statements insted of the aws_iot ones, but now I will try the implementation from th git first. I will let you know the result.

    best regards!

    Rudolph

  • Hey Øyvind,

    I simply had to change my broker and everything is working out of the box (getting the sensor data published in active mode to the broker and received it via a subscribed client on the same topic. Really nice work and thanks a lot for your help and also many thanks to the developer team. A nice gift for me at the end of the week!

    I will verify your answer and close the ticket, but will send some more response to this thread when I will continue to test the passive mode and other things!

    Have a nice weekend and again thanks a lot!

    Kind regards

    Rudolph

  • Short Update:
    I also was able to send data to my self hosted broker, using mqtt username and password as verification. Still using active mode only. I will post updates on how passive mode is working if i am ready.

Related