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

Parents
  • 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!

    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.

  • Hi Heidi


    Thank for your recomendation, I have a doubt whit AGPS sample, where is the recursivity or the interrup to take the gps data? I don't understand that part

Reply Children
  • Hi, let's start in the main file. 

    work_init() is called (L396) which calls 

    k_delayed_work_init(&gps_start_work, gps_start_work_fn); (L332)

    This initializes the work item gps_start_work as a delayed work item with the handler gps_start_work_fn(), which configures and starts the GPS.

    Then once the modem has been configured (L398) and the device binding for the nRF9160 GPS is complete (L405), the GPS is initialized (L411), which the device from the binding (gps_dev) and a gps_handler() that's defined earlier. 

    err = gps_init(gps_dev, gps_handler); is defined in nrf/include/drivers/gps.h L366.

  • Hi! 

    Thank you very much I understand better now the gps manage, however I don't undertand the modem manage because in  L348 require psm mode but then don't go out of psm mode again.

    In documentation I find that gps works better with modem en PSM and eDRX mode but when I wanna transmit how I active the modem to connect and transmit?

  • The modem will go in and out of Power Saving Mode by itself, based on the timers set by the network. That's not something the application has any control of. When the UE is in PSM, the GPS will be able to function and get a fix.

    It's important to request a time long enough for the GPS to be able to get a fix though. AT+CPSMS is used to request these parameters from the network. Be aware that you are free the request any values from the network, but the network can set different values.

  • Hi Heidi!

    The modem will go in and out of Power Saving Mode by itself, based on the timers set by the network

    how can I know the timers set by the network where my UE is conneted?

    Then once the modem has been configured (L398) and the device binding for the nRF9160 GPS is complete (L405)

    I have drawbacks in this part, I add the gsp_handler() and gps_init() of agps sample to aws_iot sample, omitting only cloud connection code, but at run time show this message:

    I try to read about what is binding operation but don't find documentation about this, the modem_configure(); in aws_iot (L372) is the same that agps (L336), I mean, can the gps work with the modem_configure(); of aws_iot?

    edit: I tried to debug but I don't know how to verify or control the binding function

  • tracking said:
    how can I know the timers set by the network where my UE is conneted?

     You can use AT%XMONITOR to read the Active Time and Periodic TAU set by the network. 

    Yes, you can use the modem_configure() in the AWS IoT sample, but you need to modify it to request PSM (L348). 

    Did you include the GPS driver (L13)? Can I see your main.c file?

Related