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

AWS IoT how change the messagge type 1?

Hello 

I'm using nRF910 DK and need to transmit to aws iot core just like the sample aws iot does, but instead of battery voltage I need to transmit gps data.

In sample I don't find where change the value of type 1 mesagge to transmit, I look for it in the code but I can't find the function in charge of this.

thanks in advance for your help 

Julio

  • Hi!

    Here are the relevant lines when modifying what message to post to AWS IoT. 

    In L108-L109, the data (battery voltage and date and time) is added to the JSON objects. Here is where you would instead add the GPS data.

    Then the object is made into a message string in L118.

    L125-L130 is where the struct that is used to transmit packages in the AWS IoT library is created. 

    And it is published in L134.

    You will also need to add GPS functionality in the sample, as this is not included. Use the GPS sample in NCS as a reference. Remember that GPS and LTE cannot work concurrently so you will either need to put the modem in PSM mode or turn it off before activating the GPS. 

    Best regards,

    Heidi

  • Hi Heidi

    thanks for your response, I identify the lines you mention and I've saw the GPS sample and joint the samples in one, over aws iot sample I put the gps sample functions, the project compiles but in terminal show this

    I don't know what is err:9, I searched but i could not find   and the failed to initializa modem I supose that is due to GPS and LTE cannot work concurrently, where I can find information about this manage

  • Hi! 

    The errors are defined in newlib's errno.h:

    #define EBADF 9 /* Bad file number */

    You are correct, the GPS and LTE functionality of the modem cannot work concurrently. So you can either put the modem in offline mode every time you want to use the GPS, though we do not recommend this method because the UE will disconnect from the network and has to go through the attach process every time you turn the modem back on which takes time and increases the current consumption of the application. 

    Instead, you can find out of your network supports PSM or eDRX and then put the modem in one of these modes before activating the GPS. 

  • Hi Heidi!

    I can see the errors thanks for that, now analazing the aws_iot sample to know how implement PSM or eDRX mode and I don´t undestand the work_init() function, how works k_delayed_work_init()?

    I undertand that in main.c transmition is in L497, but just after this line can I put LTE modem in PSM or eDRX mode and then activate GPS?   

    edition I: I don't undertand what nrf_modem_lib_dfu_handler() does and what is the meaninig of this #define MODEM_DFU_RESULT_OK 0x5500001u?

    edition II: how I can find the errors meaning? i.e. this function lte_lc_func_mode_get() return -22, but I can't find its meaning

  • Hi!

    work_init() initializes three delayed work items (shadow_update_work, connect_work and shadow_update_version_work) prior to their first use (see: Zephyr: Submitting a Delayed Work Item). 

    nrf_modem_lib_dfu_handler() initializes the nRF Modem Libary (formerly called BSD Lib) which is the library used to run the modem on the nRF9160 SiP (see nrf_modem_lib.h#L24-L48 for a full description). It then has a switch case for the error code from the function. Lastly, it initializes the AT Cmd and AT Notif libraries. 

    I linked the meaning of the errors in my previous comment. EINVAL (22) is invalid argument. If you want to know why that function is returning this, you can take a look at where it is used in the code and the function definition (see lte_lc.c#811-L1871).

    Looks like the sample already requests to set the modem in PSM mode (see main.c#L250), so you don't have to think about this. Try integrating a GPS handler and GPS init function like in the AGPS sample.

Related