Change asset tracker (thingy91) example to PASSIVE MODE

Hi all,

I'm new to the whole kconfig system, and I can't seem to change the Asset Tracker to passive mode. 

I've tried adding these lines to the prj.conf file:

CONFIG_DATA_DEVICE_MODE_PASSIVE=y
CONFIG_DATA_DEVICE_MODE_ACTIVE=n
and I changed the default of the DATA_DEVICE_MODE choice in Kconfig.data_module to DATA_DEVICE_MODE_PASSIVE
 
Which does seem to add the following line to the autogenerated autoconf.h file:
#define CONFIG_DATA_DEVICE_MODE_PASSIVE 1
But the asset tracker is still in active mode. I checked this by placing break points in the 
apply_config() function in sensor_module.c, which shows me that it is still configuring the system based on messages that turn it into active mode, so it is calling:
accelerometer_callback_set(false);

Where do these messages come from, and how do I change this?
Parents
  • Hello, 

    Looking at the documentation for the Data Module of the Asset Tracker v2,  CONFIG_DATA_DEVICE_MODE_PASSIVE is default mode for Thingy:91. 

    Could you please elaborate more on where you are configuring the settings? What version of nRF Connect SDK you using?

    Kind regards,
    Øyvind

  • Thank you for the response, but it does seem to initialise in active mode. 


    This is what is encountered when stepping through the initialization:

    Upon booting, in sensor_module.c, this function is called:

    /* Message handler for STATE_INIT. */
    static void on_state_init(struct sensor_msg_data *msg)
    {
    	if (IS_EVENT(msg, data, DATA_EVT_CONFIG_INIT)) {
    		apply_config(msg);
    		state_set(STATE_RUNNING);
    	}
    }

    From there, the apply_config function is called:

    static void apply_config(struct sensor_msg_data *msg)
    {
    #if defined(CONFIG_EXTERNAL_SENSORS)
    	configure_acc(&msg->module.data.data.cfg);
    
    	if (msg->module.data.data.cfg.active_mode) {
    		accelerometer_callback_set(false);
    	} else {
    		accelerometer_callback_set(true);
    	}
    #endif /* CONFIG_EXTERNAL_SENSORS */
    }
    

    Which then sets the accelerometer callback to false (so the msg passed to it has active_mode set to true). 
    As far as I understand, this deactivates any possibility to trigger movement registered by the Zephyr os.

    I believe this innitial configuragtion message is based upon this struct in data_module.c:

    /* Default device configuration. */
    static struct cloud_data_cfg current_cfg = {
    	.gnss_timeout		 = CONFIG_DATA_GNSS_TIMEOUT_SECONDS,
    	.active_mode		 = IS_ENABLED(CONFIG_DATA_DEVICE_MODE_ACTIVE),
    	.active_wait_timeout	 = CONFIG_DATA_ACTIVE_TIMEOUT_SECONDS,
    	.movement_resolution	 = CONFIG_DATA_MOVEMENT_RESOLUTION_SECONDS,
    	.movement_timeout	 = CONFIG_DATA_MOVEMENT_TIMEOUT_SECONDS,
    	.accelerometer_activity_threshold	= CONFIG_DATA_ACCELEROMETER_ACT_THRESHOLD,
    	.accelerometer_inactivity_threshold	= CONFIG_DATA_ACCELEROMETER_INACT_THRESHOLD,
    	.accelerometer_inactivity_timeout	= CONFIG_DATA_ACCELEROMETER_INACT_TIMEOUT_SECONDS,
    	.no_data.gnss		 = !IS_ENABLED(CONFIG_DATA_SAMPLE_GNSS_DEFAULT),
    	.no_data.neighbor_cell	 = !IS_ENABLED(CONFIG_DATA_SAMPLE_NEIGHBOR_CELLS_DEFAULT)
    };
    

    and if I hover over CONFIG_DATA_DEVICE_MODE_ACTIVE I can see that it is set to "n". So I would think this means that the message would not turn on the active mode. But apparently I'm missing something.

    I have tried changing the configuration in multiple places:

    prj.conf file:
    CONFIG_DATA_DEVICE_MODE_PASSIVE=y
    CONFIG_DATA_DEVICE_MODE_ACTIVE=n

    Kconfig.data_module:
    DATA_DEVICE_MODE changed to DATA_DEVICE_MODE_PASSIVE

    I'm using 2.1.1 for both the SDK and the Toolchain.
    p.s. I also have another issue, not related but it does make debugging a lot harder. Often when I try to add a breakppoint, i and up stuck in "FIH_PANIC" in the debugger. Some breakpoints do work tough, and if I remove the breakpoint that caused me to end up in FIH_PANIC is also works again. Do you know what causes this?
        if (fih_not_eq(fih_rc, FIH_SUCCESS)) {
            BOOT_LOG_ERR("Unable to find bootable image");
    
            mcuboot_status_change(MCUBOOT_STATUS_NO_BOOTABLE_IMAGE_FOUND);
    
            FIH_PANIC;
        }
    
        BOOT_LOG_INF("Bootloader chainload address offset: 0x%x",
                     rsp.br_image_off);
Reply
  • Thank you for the response, but it does seem to initialise in active mode. 


    This is what is encountered when stepping through the initialization:

    Upon booting, in sensor_module.c, this function is called:

    /* Message handler for STATE_INIT. */
    static void on_state_init(struct sensor_msg_data *msg)
    {
    	if (IS_EVENT(msg, data, DATA_EVT_CONFIG_INIT)) {
    		apply_config(msg);
    		state_set(STATE_RUNNING);
    	}
    }

    From there, the apply_config function is called:

    static void apply_config(struct sensor_msg_data *msg)
    {
    #if defined(CONFIG_EXTERNAL_SENSORS)
    	configure_acc(&msg->module.data.data.cfg);
    
    	if (msg->module.data.data.cfg.active_mode) {
    		accelerometer_callback_set(false);
    	} else {
    		accelerometer_callback_set(true);
    	}
    #endif /* CONFIG_EXTERNAL_SENSORS */
    }
    

    Which then sets the accelerometer callback to false (so the msg passed to it has active_mode set to true). 
    As far as I understand, this deactivates any possibility to trigger movement registered by the Zephyr os.

    I believe this innitial configuragtion message is based upon this struct in data_module.c:

    /* Default device configuration. */
    static struct cloud_data_cfg current_cfg = {
    	.gnss_timeout		 = CONFIG_DATA_GNSS_TIMEOUT_SECONDS,
    	.active_mode		 = IS_ENABLED(CONFIG_DATA_DEVICE_MODE_ACTIVE),
    	.active_wait_timeout	 = CONFIG_DATA_ACTIVE_TIMEOUT_SECONDS,
    	.movement_resolution	 = CONFIG_DATA_MOVEMENT_RESOLUTION_SECONDS,
    	.movement_timeout	 = CONFIG_DATA_MOVEMENT_TIMEOUT_SECONDS,
    	.accelerometer_activity_threshold	= CONFIG_DATA_ACCELEROMETER_ACT_THRESHOLD,
    	.accelerometer_inactivity_threshold	= CONFIG_DATA_ACCELEROMETER_INACT_THRESHOLD,
    	.accelerometer_inactivity_timeout	= CONFIG_DATA_ACCELEROMETER_INACT_TIMEOUT_SECONDS,
    	.no_data.gnss		 = !IS_ENABLED(CONFIG_DATA_SAMPLE_GNSS_DEFAULT),
    	.no_data.neighbor_cell	 = !IS_ENABLED(CONFIG_DATA_SAMPLE_NEIGHBOR_CELLS_DEFAULT)
    };
    

    and if I hover over CONFIG_DATA_DEVICE_MODE_ACTIVE I can see that it is set to "n". So I would think this means that the message would not turn on the active mode. But apparently I'm missing something.

    I have tried changing the configuration in multiple places:

    prj.conf file:
    CONFIG_DATA_DEVICE_MODE_PASSIVE=y
    CONFIG_DATA_DEVICE_MODE_ACTIVE=n

    Kconfig.data_module:
    DATA_DEVICE_MODE changed to DATA_DEVICE_MODE_PASSIVE

    I'm using 2.1.1 for both the SDK and the Toolchain.
    p.s. I also have another issue, not related but it does make debugging a lot harder. Often when I try to add a breakppoint, i and up stuck in "FIH_PANIC" in the debugger. Some breakpoints do work tough, and if I remove the breakpoint that caused me to end up in FIH_PANIC is also works again. Do you know what causes this?
        if (fih_not_eq(fih_rc, FIH_SUCCESS)) {
            BOOT_LOG_ERR("Unable to find bootable image");
    
            mcuboot_status_change(MCUBOOT_STATUS_NO_BOOTABLE_IMAGE_FOUND);
    
            FIH_PANIC;
        }
    
        BOOT_LOG_INF("Bootloader chainload address offset: 0x%x",
                     rsp.br_image_off);
Children
  • hubert_11 said:
    I'm using 2.1.1 for both the SDK and the Toolchain.

    Thanks, will see if I can reproduce here. 

    What version of the Thingy:91 are you working on? 

    hubert_11 said:
    p.s. I also have another issue, not related but it does make debugging a lot harder. Often when I try to add a breakppoint, i and up stuck in "FIH_PANIC" in the debugger. Some breakpoints do work tough, and if I remove the breakpoint that caused me to end up in FIH_PANIC is also works again. Do you know what causes this?

    This does not seem related to this case. You should open a new ticket for this issue. Thanks!

  • Thanks! I'm not sure where to find the version number, but on the sticker with the IMEI code it also states:

    1.6.0

    2021.16

  • I've tested building the default project for thingy91_nrf9160_ns, and see that active mode is on by default in NCS v2.1.1, while in 2.2.0 passive is default when building for Thingy:91. See nrf\applications\asset_tracker_v2\src\modules\Kconfig.data_module

    CONFIG_DATA_DEVICE_MODE_ACTIVE=y
    # CONFIG_DATA_DEVICE_MODE_PASSIVE is not set

    Adding the following lines to the prj.conf

    CONFIG_DATA_DEVICE_MODE_ACTIVE=n
    CONFIG_DATA_DEVICE_MODE_PASSIVE=y

    gave the following in build\zephyr\.config

    # CONFIG_DATA_DEVICE_MODE_ACTIVE is not set
    CONFIG_DATA_DEVICE_MODE_PASSIVE=y
    Can you verify that you see the same on your side?
  • I tried using 2.2.0 and setting those lines in the prj.conf but this still evaluates to true:

    msg->module.data.data.cfg.active_mode
    in:
    static void apply_config(struct sensor_msg_data *msg)
    {
    #if defined(CONFIG_EXTERNAL_SENSORS)
    	configure_acc(&msg->module.data.data.cfg);
    
    	if (msg->module.data.data.cfg.active_mode) {
    		accelerometer_callback_set(false);
    	} else {
    		accelerometer_callback_set(true);
    	}
    #endif /* CONFIG_EXTERNAL_SENSORS */
    }
    So the accelerometer callback is still set to false in 2.2.0, while it should be set to true right?
Related