Asset Tracker v2 application. How to subscribe to non-AWS specific topic:

I have built and successfully run this application with the nRF Cloud and then I achieved a partial success with running this application with the AWS IoT.

When I run this app with the AWS IoT, I can see all relevant data sent from my nRF9160DK to the shadow topics of my thing created on AWS IoT, like the battery voltage values and time stamp values. 

However, I would also like to see, in the relevant AWS IoT topics, the data sent from my nRF9160DK device that relates to button presses on the nRF9160DK device.

Apparently, the data that relates to the button presses on the nRF9160DK device should be available in the AWS IoT topic: "<imei>/messages" but there is no data that I could see in this AWS IoT topic, despite receiving without any problems the battery voltage values and time stamp values in the AWS IoT shadow topics of my thing created on the AWS IoT.

According to the info in the nRF9160DK Get Started guide, in order to subscribe to non AWS specific topics, you need to:

1. Specify the number of additional topics that needs to be subscribed to, by setting the option: CONFIG_AWS_IOT_APP_SUBSCRIPTION_LIST_COUNT. (I can see that this option is already set to: 3).

2. Pass a list containing application-specific topics in the function: aws_iot_subscription_topics_add() , after the function call: aws_iot_init() and before the function call: aws_iot_connect().

From my analysis of the file: aws_iot_integration.c  that is located in: asset_tracker_v2\src\cloud\aws_iot_integration.c , it appears that the topic: "<imei>/messages" is already included in the list of topics to which my nRF9160DK device will publish the relevant data.

I found a section of code in the main.c source file for sample: AWS-IoT that I consider to use in the app: Asset Tracker v2, in order to be able to subscribe to non AWS specific topics on AWS IoT,  while running the app: Asset Tracker v2 with AWS IoT. (I attach a copy of the section of code from the source file main.c for the sample:AWS-IoT).

I have two questions:

1. Is the non AWS specific topic the same as the application specific topic?

2. If  I need to insert the section of code from the main.c of the sample: AWS-IoT to the main.c of the app: Asset Tracker v2 (in order to be able to see the data in the AWS IoT topic:  <imei>/messages) , where exactly shall I insert this section of code in the main.c  source file for app: Asset Tracker v2 (or may be in another source .c file for this app)?

Regards,

JM

Section of code from the main.c for sample aws-IoT.docx

Parents
  • Hi,

    After some further analysis and experimenting I found that the data about the button presses on my nRF9160DK device was in fact being sent from my device to the aws IoT Core and it was available in the aws IoT topic: <IMEI>/messages , as expected.

    The only reason why I have not found this data was the incorrect value (number) that I was using for <IMEI> while trying to subscribe to the aws IoT topic: <IMEI>/messages.

    Once I used the correct value (number) for the <IMEI> , as per data obtained from the modem of my nRF9160DK device, using AT command: AT+CGSN , this problem has been resolved and I was able to see both:

    1. the data about the battery voltage (with its time stamp) sent from my device to the shadow topics of the aws IoT Core and     

    2. the data about the button presses on my device sent from my device to the topic: <IMEI>/messages on the aws IoT Core.

    However, when I thought that this problem has been resolved or good, something happened on the 14th January 2022. 

    I started receiving messages like:

    1. ERROR: cmake failed

    2. create_nordic_project.py failed

    3. CMake error at: C:/.../v1.7.0/zephyr/cmake/kconfig:268 (message): command failed with return code 1.

    4. src/watchdog/kconfig - not found (in 'rsource "src/watchdog/kconfig")

    As I run into problems on 14 January 2022 with creating Nordic projects using nRF Connect SDK 1.7.0 , I decided to upgrade to the latest version of the nRF Connect SDK 1.8.0 and I was able to successfully build and run the sample: AWS-IoT, using the nRF Connect SDK 1.8.0.

    However, there were issues when I tried to build and run the application: Asset Tracker v2, using nRF Connect SDK 1.8.0.

    In the past, when I was using the nRF Connect SDK 1.7.0 to build and run the application: Asset Tracker v2, I noticed that in order to be able to see the data sent from my nRF9160DK device to the AWS IoT in the relevant AWS IoT Core topics , I had to make the following changes in the prj.conf file for asset_tracker_v2 application:

    I had to disable the following option (by setting it to 'n'): CONFIG_NRF_CLOUD_MQTT=n

    and I had to enable the following option (by setting it to 'y'): CONFIG_AWS_IOT=y

    However, when I was using the nRF Connect SDK 1.8.0 and I tried to disable (by setting it to 'n') the option: CONFIG_NRF_CLOUD_MQTT=n in the prj.conf file for app: asset_tracker_v2, I was unable to complete the process of "Build Solution" in Segger IDE, with the following error messages popping up:  Build solution failed. Error was detected while compiling cloud_module.c. "A cloud transport service must be enabled".

    And in order to be able to successfully complete the process of "Build Solution" by Segger IDE, I had to enable this option (by setting it to 'y') as follows: CONFIG_NRF_CLOUD_MQTT=y

    This resulted in the successful build of the application: asset_tracker_v2, that I programmed into my nRF9160DK device.

    Once my nRF9160DK was programmed with the above version of the "Build Solution" for application: asset_tracker_v2, I could see ,via the Link Monitor, that all activities on my nRF9160DK device were running as expected and that my device was communicating with AWS IoT Core.

    However, I could not see any data from my device displayed in the relevant topics on the AWS IoT Core (neither in the shadow topics nor in the <IMEI>/messages topic).   This was in contrast to my earlier experience with the same application: asset_tracker_v2, that was built using the nRF Connect SDK 1.7.0 with the following option disabled by 'n': CONFIG_NRF_CLOUD_MQTT=n.

    What can be done to allow me to see the data sent from my nRF9160DK device to the AWS IoT Core, in the relevant topics of the AWS IoT Core that is: the shadow topics and the <IMEI>/messages topic?

    From my experience, it seems that one needs to be able to successfully complete the "Build Solution" process in Segger IDE with the following option in the prj.conf file disabled by 'n':  CONFIG_NRF_CLOUD_MQTT=n.

    What is the solution to this problem?

    Regards,

    JM

     

Reply
  • Hi,

    After some further analysis and experimenting I found that the data about the button presses on my nRF9160DK device was in fact being sent from my device to the aws IoT Core and it was available in the aws IoT topic: <IMEI>/messages , as expected.

    The only reason why I have not found this data was the incorrect value (number) that I was using for <IMEI> while trying to subscribe to the aws IoT topic: <IMEI>/messages.

    Once I used the correct value (number) for the <IMEI> , as per data obtained from the modem of my nRF9160DK device, using AT command: AT+CGSN , this problem has been resolved and I was able to see both:

    1. the data about the battery voltage (with its time stamp) sent from my device to the shadow topics of the aws IoT Core and     

    2. the data about the button presses on my device sent from my device to the topic: <IMEI>/messages on the aws IoT Core.

    However, when I thought that this problem has been resolved or good, something happened on the 14th January 2022. 

    I started receiving messages like:

    1. ERROR: cmake failed

    2. create_nordic_project.py failed

    3. CMake error at: C:/.../v1.7.0/zephyr/cmake/kconfig:268 (message): command failed with return code 1.

    4. src/watchdog/kconfig - not found (in 'rsource "src/watchdog/kconfig")

    As I run into problems on 14 January 2022 with creating Nordic projects using nRF Connect SDK 1.7.0 , I decided to upgrade to the latest version of the nRF Connect SDK 1.8.0 and I was able to successfully build and run the sample: AWS-IoT, using the nRF Connect SDK 1.8.0.

    However, there were issues when I tried to build and run the application: Asset Tracker v2, using nRF Connect SDK 1.8.0.

    In the past, when I was using the nRF Connect SDK 1.7.0 to build and run the application: Asset Tracker v2, I noticed that in order to be able to see the data sent from my nRF9160DK device to the AWS IoT in the relevant AWS IoT Core topics , I had to make the following changes in the prj.conf file for asset_tracker_v2 application:

    I had to disable the following option (by setting it to 'n'): CONFIG_NRF_CLOUD_MQTT=n

    and I had to enable the following option (by setting it to 'y'): CONFIG_AWS_IOT=y

    However, when I was using the nRF Connect SDK 1.8.0 and I tried to disable (by setting it to 'n') the option: CONFIG_NRF_CLOUD_MQTT=n in the prj.conf file for app: asset_tracker_v2, I was unable to complete the process of "Build Solution" in Segger IDE, with the following error messages popping up:  Build solution failed. Error was detected while compiling cloud_module.c. "A cloud transport service must be enabled".

    And in order to be able to successfully complete the process of "Build Solution" by Segger IDE, I had to enable this option (by setting it to 'y') as follows: CONFIG_NRF_CLOUD_MQTT=y

    This resulted in the successful build of the application: asset_tracker_v2, that I programmed into my nRF9160DK device.

    Once my nRF9160DK was programmed with the above version of the "Build Solution" for application: asset_tracker_v2, I could see ,via the Link Monitor, that all activities on my nRF9160DK device were running as expected and that my device was communicating with AWS IoT Core.

    However, I could not see any data from my device displayed in the relevant topics on the AWS IoT Core (neither in the shadow topics nor in the <IMEI>/messages topic).   This was in contrast to my earlier experience with the same application: asset_tracker_v2, that was built using the nRF Connect SDK 1.7.0 with the following option disabled by 'n': CONFIG_NRF_CLOUD_MQTT=n.

    What can be done to allow me to see the data sent from my nRF9160DK device to the AWS IoT Core, in the relevant topics of the AWS IoT Core that is: the shadow topics and the <IMEI>/messages topic?

    From my experience, it seems that one needs to be able to successfully complete the "Build Solution" process in Segger IDE with the following option in the prj.conf file disabled by 'n':  CONFIG_NRF_CLOUD_MQTT=n.

    What is the solution to this problem?

    Regards,

    JM

     

Children
Related