General Questions on Asset_tracker_v2 application

Hi, I'm just experimenting with my nRF9160 DK and have run into some questions regarding the default asset_tracker_v2 program and how some of it works. I have read the documentation regarding the asset_tracker_v2 application at: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/nrf/applications/asset_tracker_v2/doc/asset_tracker_v2_description.html#configuration

I have the following questions:

1. In the nRF Cloud Terminal interface, there perodically appears a "Received" message with fields such as appID, messageType, data, and ts. I'm curious as to where the "appId" field is defined within the asset tracker source code?

2. I've tried to append some test values to the payload that is sent to the nRF Cloud, but they don't seem to be sent to nRF Cloud. As an example, I've tried to append a field called "newvalue1" with an integer value of 10 to be sent every time the battery voltage data is sent to nRF Cloud. After updating the structure definitions as appropriate, I added "modem_module_event->data.bat.newvalue1 = 10;" after the timestamp line within the battery_data_get() function within modem_module.c.

I have additionally added ".bat_newvalue = msg->module.modem.data.bat.newvalue1" to the if (IS_EVENT(msg, modem, MODEM_EVT_BATTERY_DATA_READY)) part of data_module.c and updated the cloud_data_battery definitions as appropriate. However, no additional data appears to be sent to nRF Cloud beyond the battery voltage and timestamp. I was wondering if there are any additional fields that I need to update in order for the data to send correctly?

3.I've been trying to implement functionality for the switches that are available on the nRF9160 DK, but am having some trouble with modifying the code such that it will respond to a change in state of the switches. A topic reply on another topic suggests referring to the http_update sample program, which has lent some insight into defining GPIO pins and reading them, but I was curious as to how this is handled within the asset_tracker_v2 program, as none of the modules seem to have explicit definition of the mappings of the buttons to physical GPIO pins. Thus, I was wondering if someone can explain where the pins are defined within this program, or maybe provide some more information regarding how to trigger an event when a switch is flipped as opposed to a button being pressed.

Thanks in advance to anyone who can offer any help!

Parents
  • Hello,

    Tester013 said:
    I was wondering if this is indeed where the mappings are defined, and if so, is there a similar file for buttons/switches?

    The general answer here is yes. Buttons and switches on development kits/custom boards are normally defined and configured in the Zephyr devicetree.

    Regarding the Asset Tracker v2, it uses the DK buttons and LEDs library in the UI module. The library supports triggering on the DK switches by default. To trigger on switch 1 and 2 you need to include if statements that filters for DK_BTN3_MSK (switch 1) and DK_BTN4_MSK (switch 2) triggers, like it has been done for the buttons in the button_handler, i.e.:

    if (has_changed & button_states & DK_BTN3_MSK) {
    
        struct ui_module_event *ui_module_event =
                        new_ui_module_event();
    
        ui_module_event->type = UI_EVT_BUTTON_DATA_READY;
        ui_module_event->data.ui.button_number = 1;
        ui_module_event->data.ui.timestamp = k_uptime_get();
    
        APP_EVENT_SUBMIT(ui_module_event);
    }

    Regards,

    Markus

Reply
  • Hello,

    Tester013 said:
    I was wondering if this is indeed where the mappings are defined, and if so, is there a similar file for buttons/switches?

    The general answer here is yes. Buttons and switches on development kits/custom boards are normally defined and configured in the Zephyr devicetree.

    Regarding the Asset Tracker v2, it uses the DK buttons and LEDs library in the UI module. The library supports triggering on the DK switches by default. To trigger on switch 1 and 2 you need to include if statements that filters for DK_BTN3_MSK (switch 1) and DK_BTN4_MSK (switch 2) triggers, like it has been done for the buttons in the button_handler, i.e.:

    if (has_changed & button_states & DK_BTN3_MSK) {
    
        struct ui_module_event *ui_module_event =
                        new_ui_module_event();
    
        ui_module_event->type = UI_EVT_BUTTON_DATA_READY;
        ui_module_event->data.ui.button_number = 1;
        ui_module_event->data.ui.timestamp = k_uptime_get();
    
        APP_EVENT_SUBMIT(ui_module_event);
    }

    Regards,

    Markus

Children
No Data
Related