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

Thermostat cluster enable issue

Hi All,

I am developing product using nRF52840 and SDK nRF5_SDK_for_Thread_and_Zigbee_v3.0.0_d310e71.

This product is basically, using the Thermostat cluster and Zigbee protocol to communicate with the Zigbee gateway.

So, I referred light_bulb example and followed steps to enable "Thermostat cluster and attributes".

I have included the respective files also but I am unable to execute the below callback function case statement,

static zb_void_t zcl_device_cb(zb_uint8_t param)
{
    zb_uint8_t                       cluster_id;
    zb_uint8_t                       attr_id;
    zb_buf_t                       * p_buffer = ZB_BUF_FROM_REF(param);
    zb_zcl_device_callback_param_t * p_device_cb_param =
                     ZB_GET_BUF_PARAM(p_buffer, zb_zcl_device_callback_param_t);

    NRF_LOG_INFO("zcl_device_cb id %hd", p_device_cb_param->device_cb_id);

    /* Set default response value. */
    p_device_cb_param->status = RET_OK;

    switch (p_device_cb_param->device_cb_id)
    {
        case ZB_ZCL_SET_ATTR_VALUE_CB_ID:
            cluster_id = p_device_cb_param->cb_param.set_attr_value_param.cluster_id;
            attr_id    = p_device_cb_param->cb_param.set_attr_value_param.attr_id;

            if (cluster_id == ZB_ZCL_CLUSTER_ID_THERMOSTAT)
            {
                uint16_t value = p_device_cb_param->cb_param.set_attr_value_param.values.data16;

                NRF_LOG_INFO("thermostat local temperature: %d", value);
                if (attr_id == ZB_ZCL_ATTR_THERMOSTAT_LOCAL_TEMPERATURE_ID)
                {
                    local_temperature_value(value);
                }
            }
            else
            {
                /* Other clusters can be processed here */
                NRF_LOG_INFO("Unhandled cluster attribute id: %d", cluster_id);
            }
        break;

        default:
            p_device_cb_param->status = RET_ERROR;
            break;
    }

    NRF_LOG_INFO("zcl_device_cb status: %hd", p_device_cb_param->status);
}

Also, I am attaching code for reference please let me know what else I forgot to enable the functions. It is urgent for me to solve this issue.

Radiator_nRF_v0.9.0.zip

And, with these attributes, for some of the commands, I need to implement custom attributes so if you share how to add custom attributes to this cluster.

Thanks in advance.

Regards,

Rohit R

  • Hi Rohit,

    I have asked our developers about this, about how to further reduce current consumption and what the best way to do it when you want to wake up on received Zigbee commands and GPIO interrupt, in addition to the alarm and timer that is already a part of the sleep routine. 

    Best regards,

    Marte

  • Hi Marte, 

    Thank you I will wait for your response. Please let me know as early as possible.

    what the best way to do it when you want to wake up on received Zigbee commands and GPIO interrupt

    - Yes, more focus on wake up on zigbee commands from gateway ( first priority) and then GPIO as (second priority). 

    - But also, check my comments shared. Am I following correct steps or not? If I am doing anything wrong here then correct me. I will follow the steps and again check for current consumption. 

    Thanks and Regards

    Rohit R

  • Hi Rohit,

    You should not call nrf_pwr_mgmt_run() in the main loop yourself. When you call zboss_main_loop (or zboss_main_loop_iteration if you want to include custom features) in main you simply start the Zigbee stack, and the stack will interact with the application using stack signals (zboss_signal_handler) and ZCL callbacks (zcl_device_cb). So all of this is handled internally by the stack after you start the main loop. This includes the signal that it can go to sleep. The stack decides that it has nothing more to do, as there are no stack tasks or anything in the queue that needs to be handled, so the stack informs the device that it can go to sleep or power down. This will cause zb_osif_go_idle to be called automatically. This function checks if the logger has anything to process and calls the function zb_osif_wait_for_event, which in turn calls the nrf_pwr_mgmt_run API. You can see part of this in the flowchart below, which is from the page about Zigbee stack sleep routines in our documentation. Since your device is not a sleepy end device, the third step will result in no, since "rx_off_when_idle" is not true, and it will go to zb_osif_go_idle.

    While I wait for a response from the developers, you can also take a look at Powering down RAM sections to further reduce current consumption by powering down sections of the RAM memory that are not used by the application.

    Best regards,

    Marte

  • Hi Marte, 

    Thank you for the response. 

    Sorry my mistake, I have made confusion while explaining. 

    You should not call nrf_pwr_mgmt_run() in the main loop yourself.

    - This example is peripheral code. I have made one of example copy and followed some online tutorial steps to run this API. 

    When you call zboss_main_loop (or zboss_main_loop_iteration if you want to include custom features) in main you simply start the Zigbee stack, and the stack will interact with the application using stack signals (zboss_signal_handler) and ZCL callbacks (zcl_device_cb). So all of this is handled internally by the stack after you start the main loop. This includes the signal that it can go to sleep. The stack decides that it has nothing more to do, as there are no stack tasks or anything in the queue that needs to be handled, so the stack informs the device that it can go to sleep or power down. This will cause zb_osif_go_idle to be called automatically.

    - Yes, This is present in my radiator code. Here I have not added anything in while loop(). I kept code same as present in light_bulb code. With this only I have tested the current and it gave me 0.03mA after discovery. Where my Radiators STM base board and nRF52 Dev-kit connected. I want battery to life 2 years so I need almost 1uA current that too only my RF board (nRF should consume 1uA current). 

    While I wait for a response from the developers,

    - ya , sure please let me know i will wait for positive response. 

    you can also take a look at Powering down RAM sections to further reduce current consumption by powering down sections of the RAM memory that are not used by the application.

    - Okay, I will check this part too. 

    Thank you so much.  

    Regards, 

    Rohit R

  • Hi Marte, 

    I went through the Power down RAM section. Here, It is mentioned that use zigbee_power_down_unused_ram() function from  Zigbee application components. If I tried to search API/ function here it says zero result. 

    Similarly, Checked the light_switch example as it was mentioned in link for reference but in example alsp it says zero result. Am I following anything wrong here?

    Hi, I got this. zigbee_power_down_unused_ram() this present in light_switch SDK4.1 example and helper.c file but not present in SDK3.0. 

    Can we use in SDK 3.0 ? If yes the How to handle it in helper.c file or any other file. 

    Thanks and Regards

    Rohit R

Related