This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2340R5: In the ZBOOS stack ,the zb_aps_send_user_payload interface will cause a very long delay when sending data,for example the latency for a single-hop unicast transmission is 900 milliseconds.

Part Number: CC2340R5
Other Parts Discussed in Thread: SYSCONFIG, , ENERGYTRACE

Tool/software:

In the ZBOOS stack ,the zb_aps_send_user_payload interface will cause a very long delay when sending data,for example the latency for a single-hop unicast transmission is 900 milliseconds.

I think the one-hop unicast delay is abnormal,  Please check if the “zb_aps_send_user_payload” API interface is being used correctly. It should be the problem caused by the sending buffer,After the “zb_aps_send_user_payload” API interface was executed, the data transmission was not send out immediately.

typedef struct
{
unsigned char addr_mode;
unsigned char ack_enable;
unsigned char source_endpoint;
unsigned char dest_endpoint;
unsigned short cluster_id;
unsigned short profile_id;
}ws_send_frame_t;

static volatile unsigned char ws_rf_send_status=0;

static void ws_rf_send_cb(zb_uint8_t param)
{
    zb_ret_t status=zb_buf_get_status(param);


    zb_buf_free(param);


    ws_rf_send_status=0;

    ws_printf("ws_rf_send_cb:0x%x\r\n",status);

}

unsigned char ws_rf_send(zb_addr_u dest_addr,unsigned char *data, unsigned char len,ws_send_frame_t *param)
{
if (!ZB_JOINED())
{
return WS_SEND_NO_NET;
}
if(len>82)
{
return WS_SEND_TOO_LONG;
}

if(ws_rf_send_status==1)
{
return WS_SENDING;
}
ws_rf_send_status=1;

zb_bufid_t buf_id;
buf_id = zb_buf_get_out();

if (!buf_id)
{
return WS_SEND_BUF_ERR;
}

zb_aps_set_user_data_tx_cb(ws_rf_send_cb);
ws_send_addr=dest_addr.addr_short;
zb_ret_t ret=zb_aps_send_user_payload(
buf_id,
dest_addr, /* dst_addr */
param->profile_id,// WS_DEFAULT_PROFILEID, /* profile_id */
param->cluster_id,//WS_DEFAULT_CLUSTERID, /* cluster_id */
param->dest_endpoint,//WS_DEFAULT_DEST_ENDPOINT, /* dst_endpoint */
param->source_endpoint,//WS_DEFAULT_SOURE_ENDPOINT, /* src_endpoint */
param->addr_mode,//ZB_APS_ADDR_MODE_16_ENDP_PRESENT, /* addr_mode */
param->ack_enable,/*ZB_FALSE*//*ZB_TRUE*/ /* aps_ack_is_enabled */
data,
len
);
if(ret!=RET_OK)
{
return WS_SEND_BUF_ERR;
}

return 0;
}

unsigned char ws_at_send_rf_data(unsigned char *buf,unsigned short len)
{
unsigned char ret=0;

ws_send_frame_t ws_at_send_frame;
zb_addr_u dest_addr;


ws_at_send_frame.ack_enable=1;

ws_at_send_frame.addr_mode=ZB_APS_ADDR_MODE_16_ENDP_PRESENT;

dest_addr.addr_short = 0;    //The destination address is the coordinator.

ws_at_send_frame.source_endpoint =WS_DEFAULT_SOURE_ENDPOINT;

ws_at_send_frame.dest_endpoint = WS_DEFAULT_DEST_ENDPOINT;
ws_at_send_frame.cluster_id = WS_DEFAULT_CLUSTERID;
ws_at_send_frame.profile_id =WS_DEFAULT_PROFILEID;

ret=ws_rf_send(dest_addr,buf,len,&ws_at_send_frame);
return ret;
}

  • Hi baosong,

    What is the role of the node you are sending this packet to (Coordinator, Router, or End Device)?  What version of the SimpleLink F3 SDK are you using?  You should only call zb_aps_set_user_data_tx_cb(ws_rf_send_cb); once during stack initialization, not each time you are sending the APS packet.  This sequence is discussed in the Zigbee Fundamentals SLA in case you have not already referenced it.  How are you measuring the time between the API being called and the message being transferred over-the-air?

    Regards,
    Ryan

  • 1. What is the role of the node you are sending this packet to (Coordinator, Router, or End Device)?

    The router send data to the coordinator.

    2. What version of the SimpleLink F3 SDK are you using?

    The version is "simplelink_lowpower_f3_sdk_9_12_00_19"

    3. How are you measuring the time between the API being called and the message being transferred over-the-air?

    After executing the API interface, no data packets were captured in the air by Ubiqua tool, Data packets can only be captured in the air after the callback function "ws_rf_send_cb" is called.

    The above screenshot is an example of communication delay.

    The Frame 1:

    The sending time was 10:31:50.949,  The receiving time was 10:31:51.074,  The time when the ws_rf_send_cb function is called is 10:31:51.082 , Packet capture time in the air is 10:31:51.125

    The transmission delay is 125 milliseconds.

    The Frame 2:

    The sending time was 10:31:52.050,  The receiving time was 10:31:52.446,  The time when the ws_rf_send_cb function is called is 10:31:52.454 , Packet capture time in the air is 10:31:52.496

    The transmission delay is 396 milliseconds.

    The Frame 3:

    The sending time was 10:31:53.361,  The receiving time was 10:31:53.449,  The time when the ws_rf_send_cb function is called is 10:31:53.460 , Packet capture time in the air is 10:31:53.501

    The transmission delay is 88 milliseconds.

    The Frame 4:

    The sending time was 10:31:54.124,  The receiving time was 10:31:54.216,  The time when the ws_rf_send_cb function is called is 10:31:54.228 , Packet capture time in the air is 10:31:54.268

    The transmission delay is 92 milliseconds.

    The Frame 5:

    The sending time was 10:31:54.803,  The receiving time was 10:31:54.833,  The time when the ws_rf_send_cb function is called is 10:31:54.837 , Packet capture time in the air is 10:31:54.880

    The transmission delay is 30 milliseconds.

    The Frame 6:

    The sending time was 10:31:55.533,  The receiving time was 10:31:56.433,  The time when the ws_rf_send_cb function is called is 10:31:56.456 , Packet capture time in the air is 10:31:56.484

    The transmission delay is 900 milliseconds.

    The transmission delay ranging from 15ms to 30ms should be considered normal,The delay of the frame 5 should be normal. The delay of the  frame 6 reaches the 900ms.

  • When I tested the SLA I was seeing an average of 30 ms delays (downwards of 20 ms, upwards of 40 ms) between send_aps_payload and send_aps_payload_cb on a clean channel.  Given the wide variance in your observations, I wonder if your 2.4 GHz channel is noisy and causing issues with the CSMA/CA feature.  However, your screenshot does not indicate any other channel activity.  Or could there be some custom code implementation which varies widely in between your sending and callback operations?  Have you validated the SLA instructions against your own solution? Are you using a TI LaunchPad EVM or custom hardware?

    Regards,
    Ryan

  • Could you provide me with your test source code?  For example, the modified file based on on_off_light.c

  • My test was performed with on_off_switch.c which was changed to a Router role in SysConfig.  It uses a GPIO (LED pin on the LP) toggle to measure the time between packet send and callback, with a logic analyzer to record the time delta.  Pressing the left pushbutton on the LP invokes the packet transfer.

    /******************************************************************************
     Group: CMCU LPRF
     Target Device: cc23xx
    
     ******************************************************************************
     
     Copyright (c) 2024-2025, Texas Instruments Incorporated
     All rights reserved.
    
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met:
    
     *  Redistributions of source code must retain the above copyright
        notice, this list of conditions and the following disclaimer.
    
     *  Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.
    
     *  Neither the name of Texas Instruments Incorporated nor the names of
        its contributors may be used to endorse or promote products derived
        from this software without specific prior written permission.
    
     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    
     ******************************************************************************
     
     
     *****************************************************************************/
    
    /***** Trace related defines *****/
    #define ZB_TRACE_FILE_ID 40124
    
    /****** Application defines ******/
    #define ZB_SWITCH_ENDPOINT          10
    
    #include <ti/log/Log.h>
    
    #include "ti_zigbee_config.h"
    #include "zboss_api.h"
    #include "zb_led_button.h"
    
    #include <ti/devices/DeviceFamily.h>
    #include DeviceFamily_constructPath(inc/hw_fcfg.h)
    #include DeviceFamily_constructPath(inc/hw_memmap.h)
    
    /* for button handling */
    #include <ti/drivers/GPIO.h>
    #include "ti_drivers_config.h"
    
    #ifdef ZB_CONFIGURABLE_MEM
    #include "zb_mem_config_lprf3.h"
    #endif
    
    #if !defined ZB_ED_FUNC
    #error define ZB_ED_ROLE to compile the tests
    #endif
    
    /****** Application variables declarations ******/
    /* IEEE address of the device */
    zb_bool_t cmd_in_progress = ZB_FALSE;
    zb_bool_t perform_factory_reset = ZB_FALSE;
    
    /****** Application function declarations ******/
    zb_uint8_t zcl_specific_cluster_cmd_handler(zb_uint8_t param);
    void on_off_read_attr_resp_handler(zb_bufid_t cmd_buf);
    //void send_toggle_req(zb_uint8_t param);
    void send_aps_payload(zb_uint8_t param);
    void send_aps_payload_cb(zb_uint8_t param);
    void button_press_handler(zb_uint8_t param);
    
    /****** Cluster declarations ******/
    /* Switch config cluster attributes */
    zb_uint8_t attr_switch_type =
        ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_TYPE_TOGGLE;
    zb_uint8_t attr_switch_actions =
        ZB_ZCL_ON_OFF_SWITCH_CONFIGURATION_SWITCH_ACTIONS_DEFAULT_VALUE;
    
    ZB_ZCL_DECLARE_ON_OFF_SWITCH_CONFIGURATION_ATTRIB_LIST(switch_cfg_attr_list,
                                                           &attr_switch_type,
                                                           &attr_switch_actions);
    /* Basic cluster attributes */
    zb_uint8_t attr_zcl_version  = ZB_ZCL_BASIC_ZCL_VERSION_DEFAULT_VALUE;
    zb_uint8_t attr_power_source = ZB_ZCL_BASIC_POWER_SOURCE_DEFAULT_VALUE;
    ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST(basic_attr_list, &attr_zcl_version, &attr_power_source);
    /* Identify cluster attributes */
    zb_uint16_t attr_identify_time = 0;
    ZB_ZCL_DECLARE_IDENTIFY_ATTRIB_LIST(identify_attr_list, &attr_identify_time);
    /* Declare cluster list for the device */
    ZB_HA_DECLARE_ON_OFF_SWITCH_CLUSTER_LIST(on_off_switch_clusters,
                                             switch_cfg_attr_list,
                                             basic_attr_list,
                                             identify_attr_list);
    /* Declare endpoint */
    ZB_HA_DECLARE_ON_OFF_SWITCH_EP(on_off_switch_ep, ZB_SWITCH_ENDPOINT, on_off_switch_clusters);
    /* Declare application's device context for single-endpoint device */
    ZB_HA_DECLARE_ON_OFF_SWITCH_CTX(on_off_switch_ctx, on_off_switch_ep);
    
    void my_main_loop()
    {
      while (1)
      {
        /* ... User code ... */
        zboss_main_loop_iteration();
        /* ... User code ... */
      }
    }
    
    void off_network_attention(zb_uint8_t param)
    {
      ZVUNUSED(param);
      Log_printf(LogModule_Zigbee_App, Log_INFO, "off_network_attention");
      zb_osif_led_toggle(1);
    
      ZB_SCHEDULE_APP_ALARM(off_network_attention, 0, 1 * ZB_TIME_ONE_SECOND);
    }
    
    MAIN()
    {
      ARGV_UNUSED;
    
      /* Global ZBOSS initialization */
      ZB_INIT("on_off_switch");
    
      #ifdef ZB_LONG_ADDR
      // use the address that the customer set in the pre-defined symbols tab
      zb_ieee_addr_t g_long_addr = ZB_LONG_ADDR;
      zb_set_long_address(g_long_addr);
      #else
      /* Set the device's long address to the IEEE address pulling from the FCFG of the device */
      zb_ieee_addr_t ieee_mac_addr;
      ZB_MEMCPY(ieee_mac_addr, fcfg->deviceInfo.macAddr, 8);
      zb_set_long_address(ieee_mac_addr);
      #endif // ZB_LONG_ADDR
    
    #ifdef ZB_COORDINATOR_ROLE
      zb_set_network_coordinator_role(DEFAULT_CHANLIST);
    
      /* Set keepalive mode to mac data poll so sleepy zeds consume less power */
      zb_set_keepalive_mode(MAC_DATA_POLL_KEEPALIVE); 
    #ifdef DEFAULT_NWK_KEY
      zb_uint8_t nwk_key[16] = DEFAULT_NWK_KEY;
      zb_secur_setup_nwk_key(nwk_key, 0);
    #endif //DEFAULT_NWK_KEY
    
    #ifdef ZBOSS_REV23
      zb_nwk_set_max_ed_capacity(MAX_ED_CAPACITY);
    #endif //ZBOSS_REV23
    
    #elif defined ZB_ROUTER_ROLE && !defined ZB_COORDINATOR_ROLE
      zb_set_network_router_role(DEFAULT_CHANLIST);
    
    #ifdef ZBOSS_REV23
      zb_nwk_set_max_ed_capacity(MAX_ED_CAPACITY);
    #endif //ZBOSS_REV23
    
      /* Set keepalive mode to mac data poll so sleepy zeds consume less power */
      zb_set_keepalive_mode(MAC_DATA_POLL_KEEPALIVE); 
    
    #elif defined ZB_ED_ROLE
      zb_set_network_ed_role(DEFAULT_CHANLIST);
    
      /* Set end-device configuration parameters */
      zb_set_ed_timeout(ED_TIMEOUT_VALUE);
      zb_set_rx_on_when_idle(ED_RX_ALWAYS_ON);
    #if ( ED_RX_ALWAYS_ON == ZB_FALSE )
      zb_set_keepalive_timeout(ZB_MILLISECONDS_TO_BEACON_INTERVAL(ED_POLL_RATE));
      zb_zdo_pim_set_long_poll_interval(ED_POLL_RATE);
    #ifdef DISABLE_TURBO_POLL
      // Disable turbo poll feature
      zb_zdo_pim_permit_turbo_poll(ZB_FALSE);
    #endif // DISABLE_TURBO_POLL
    #endif // ED_RX_ALWAYS_ON
    #endif //ZB_ED_ROLE
    
      zb_set_nvram_erase_at_start(ZB_FALSE);
    
      /* Register device ZCL context */
      ZB_AF_REGISTER_DEVICE_CTX(&on_off_switch_ctx);
      /* Register cluster commands handler for a specific endpoint */
      ZB_AF_SET_ENDPOINT_HANDLER(ZB_SWITCH_ENDPOINT, zcl_specific_cluster_cmd_handler);
    
      zb_aps_set_user_data_tx_cb(send_aps_payload_cb);
    
      /* Initiate the stack start without starting the commissioning */
      if (zboss_start_no_autostart() != RET_OK)
      {
        Log_printf(LogModule_Zigbee_App, Log_ERROR, "zboss_start failed");
      }
      else
      {
        GPIO_setConfig(CONFIG_GPIO_BTN1, GPIO_CFG_IN_PU);
        GPIO_setConfig(CONFIG_GPIO_BTN2, GPIO_CFG_IN_PU);
        // if either button 1 or button 2 gets pressed
        zb_bool_t sideButtonPressed = ((GPIO_read((zb_uint8_t)CONFIG_GPIO_BTN1) == 0U) || (GPIO_read((zb_uint8_t)CONFIG_GPIO_BTN2) == 0U));
        // then perform a factory reset
        if (sideButtonPressed)
        {
          perform_factory_reset = ZB_TRUE;
          Log_printf(LogModule_Zigbee_App, Log_INFO, "perform factory reset");
        }
    
        zb_osif_led_button_init();
    #ifndef ZB_COORDINATOR_ROLE
        ZB_SCHEDULE_APP_ALARM(off_network_attention, 0, 1 * ZB_TIME_ONE_SECOND);
    #endif /* ZB_COORDINATOR_ROLE */
        
        /* Call the application-specific main loop */
        my_main_loop();
      }
    
      MAIN_RETURN(0);
    }
    
    static zb_bool_t finding_binding_cb(zb_int16_t status,
                                        zb_ieee_addr_t addr,
                                        zb_uint8_t ep,
                                        zb_uint16_t cluster)
    {
      /* Unused without trace. */
      ZVUNUSED(status);
      ZVUNUSED(addr);
      ZVUNUSED(ep);
      ZVUNUSED(cluster);
    
      Log_printf(LogModule_Zigbee_App, Log_INFO, "finding_binding_cb status %d addr %x ep %d cluster %d",
                 status, ((zb_uint32_t *)addr)[0], ep, cluster);
      return ZB_TRUE;
    }
    
    zb_uint8_t zcl_specific_cluster_cmd_handler(zb_uint8_t param)
    {
      zb_zcl_parsed_hdr_t *cmd_info = ZB_BUF_GET_PARAM(param, zb_zcl_parsed_hdr_t);
      zb_bool_t unknown_cmd_received = ZB_TRUE;
    
      Log_printf(LogModule_Zigbee_App, Log_INFO, "> zcl_specific_cluster_cmd_handler %i", param);
      Log_printf(LogModule_Zigbee_App, Log_INFO, "payload size: %i", zb_buf_len(param));
    
      if (cmd_info->cmd_direction == ZB_ZCL_FRAME_DIRECTION_TO_CLI)
      {
        if (cmd_info->cmd_id == ZB_ZCL_CMD_DEFAULT_RESP)
        {
          unknown_cmd_received = ZB_FALSE;
    
          cmd_in_progress = ZB_FALSE;
    
          zb_buf_free(param);
        }
      }
    
      Log_printf(LogModule_Zigbee_App, Log_INFO, "< zcl_specific_cluster_cmd_handler %i", param);
      return ! unknown_cmd_received;
    }
    
    void send_aps_payload_cb(zb_uint8_t param)
    {
      zb_ret_t buf_status;
      zb_uint8_t i;
      zb_uint8_t aps_payload_size = 0U;
      zb_uint8_t *aps_payload_ptr;
    
      Log_printf(LogModule_Zigbee_App, Log_INFO, ">> send_aps_payload_cb, param: %hd",
                 param);
    
      ZB_ASSERT(param != ZB_BUF_INVALID);
    
      buf_status = zb_buf_get_status(param);
      aps_payload_ptr = zb_aps_get_aps_payload(param, &aps_payload_size);
    
      Log_printf(LogModule_Zigbee_App, Log_INFO, "buf_status %d, buf_len: %hd, aps_payload_size: %hd",
                buf_status, zb_buf_len(param), aps_payload_size);
    
      switch ((zb_aps_user_payload_cb_status_t)buf_status)
      {
        case ZB_APS_USER_PAYLOAD_CB_STATUS_SUCCESS:
          Log_printf(LogModule_Zigbee_App, Log_INFO, "Transmission status: SUCCESS");
          break;
    
        case ZB_APS_USER_PAYLOAD_CB_STATUS_NO_APS_ACK:
          Log_printf(LogModule_Zigbee_App, Log_INFO, "Transmission status: NO_APS_ACK");
          break;
    
        default:
          Log_printf(LogModule_Zigbee_App, Log_INFO, "Transmission status: INVALID");
          break;
      }
    
      for (i = 0U; i < aps_payload_size; ++i)
      {
        Log_printf(LogModule_Zigbee_App, Log_INFO, "aps_payload[%hd] == 0x%hx",
                  aps_payload_ptr[i]);
      }
    
      zb_buf_free(param);
    
      zb_osif_led_off(1);
    
      Log_printf(LogModule_Zigbee_App, Log_INFO, "<< send_aps_payload_cb");
    }
    
    void send_aps_payload(zb_uint8_t param)
    {
      zb_addr_u addr = { 0 };
      uint8_t theMessageData[] = {"\0\0\30Hello World"};
    
      zb_osif_led_on(1);
    
      ZB_ASSERT(param);
    
      if (ZB_JOINED()  && !cmd_in_progress)
      {
        cmd_in_progress = ZB_TRUE;
        Log_printf(LogModule_Zigbee_App, Log_INFO, "send_af_data_req %d - send af data req", param);
    
        zb_aps_send_user_payload(
          param,
          addr,                   /* dst_addr */
          0x0104,                 /* profile id */
          0xf00d,                 /* cluster id */
          5,                      /* destination endpoint */
          ZB_SWITCH_ENDPOINT,     /* source endpoint */
          ZB_APS_ADDR_MODE_16_ENDP_PRESENT, /* address mode */
          ZB_TRUE,                /* APS ACK enabled */
          theMessageData,         /* payload pointer */
          sizeof(theMessageData)); /* size of payload */
      }
      else
      {
        Log_printf(LogModule_Zigbee_App, Log_INFO, "send_af_data_req %d - not joined", param);
        zb_buf_free(param);
      }
    }
    
    // void send_toggle_req(zb_uint8_t param)
    // {
    //   zb_uint16_t addr = 0;
    
    //   ZB_ASSERT(param);
    
    //   if (ZB_JOINED()  && !cmd_in_progress)
    //   {
    //     cmd_in_progress = ZB_TRUE;
    //     Log_printf(LogModule_Zigbee_App, Log_INFO, "send_toggle_req %d - send toggle", param);
    
    //     /* Destination address and endpoint are unknown; command will be sent via binding */
    //     ZB_ZCL_ON_OFF_SEND_TOGGLE_REQ(
    //       param,
    //       addr,
    //       ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT,
    //       0,
    //       ZB_SWITCH_ENDPOINT,
    //       ZB_AF_HA_PROFILE_ID,
    //       ZB_FALSE, NULL);
    //   }
    //   else
    //   {
    //     Log_printf(LogModule_Zigbee_App, Log_INFO, "send_toggle_req %d - not joined", param);
    //     zb_buf_free(param);
    //   }
    // }
    
    void restart_commissioning(zb_uint8_t param)
    {
      ZVUNUSED(param);
      bdb_start_top_level_commissioning(ZB_BDB_NETWORK_STEERING);
    }
    
    void button_press_handler(zb_uint8_t param)
    {
      if (!param)
      {
        /* Button is pressed, gets buffer for outgoing command */
        zb_buf_get_out_delayed(button_press_handler);
      }
      else
      {
        Log_printf(LogModule_Zigbee_App, Log_INFO, "button_press_handler %d", param);
        //send_toggle_req(param);
        send_aps_payload(param);
    #ifndef ZB_USE_BUTTONS
        /* Do not have buttons in simulator - just start periodic on/off sending */
        ZB_SCHEDULE_APP_ALARM(button_press_handler, 0, 7 * ZB_TIME_ONE_SECOND);
    #endif
      }
    }
    
    void permit_joining_cb(zb_uint8_t param)
    {
      Log_printf(LogModule_Zigbee_App, Log_INFO, "permit joining done");
      zb_buf_free(param);
    }
    
    void start_finding_binding(zb_uint8_t param)
    {
      ZVUNUSED(param);
    
      Log_printf(LogModule_Zigbee_App, Log_INFO, "Successful steering, start f&b initiator");
      zb_bdb_finding_binding_initiator(ZB_SWITCH_ENDPOINT, finding_binding_cb);
    }
    
    void zboss_signal_handler(zb_uint8_t param)
    {
      zb_zdo_app_signal_hdr_t *sg_p = NULL;
      zb_zdo_app_signal_type_t sig = zb_get_app_signal(param, &sg_p);
      zb_bufid_t buf;
      zb_bufid_t req_buf = 0;
      zb_zdo_mgmt_permit_joining_req_param_t *req_param;
    
      if (ZB_GET_APP_SIGNAL_STATUS(param) == 0)
      {
        switch(sig)
        {
          case ZB_ZDO_SIGNAL_SKIP_STARTUP:
    #ifndef ZB_MACSPLIT_HOST
            Log_printf(LogModule_Zigbee_App, Log_INFO, "ZB_ZDO_SIGNAL_SKIP_STARTUP: boot, not started yet");
            zb_set_tx_power(DEFAULT_TX_PWR);
            zboss_start_continue();
    #endif /* ZB_MACSPLIT_HOST */
            break;
    
    #ifdef ZB_MACSPLIT_HOST
          case ZB_MACSPLIT_DEVICE_BOOT:
            Log_printf(LogModule_Zigbee_App, Log_INFO, "ZB_MACSPLIT_DEVICE_BOOT: boot, not started yet");
            zb_set_tx_power(DEFAULT_TX_PWR);
            zboss_start_continue();
            break;
    #endif /* ZB_MACSPLIT_HOST */
          case ZB_BDB_SIGNAL_DEVICE_FIRST_START:
            Log_printf(LogModule_Zigbee_App, Log_INFO, "FIRST_START: start steering");
            if (perform_factory_reset)
            {
              // passing in 0 as the parameter means that a buffer will be allocated automatically for the reset
              zb_bdb_reset_via_local_action(0);
              perform_factory_reset = ZB_FALSE;
            }
            zb_set_tx_power(DEFAULT_TX_PWR);
            bdb_start_top_level_commissioning(ZB_BDB_NETWORK_STEERING);
    
            buf = zb_buf_get_out();
            if (!buf)
            {
              Log_printf(LogModule_Zigbee_App, Log_WARNING, "no buffer available");
              break;
            }
    
            req_param = ZB_BUF_GET_PARAM(buf, zb_zdo_mgmt_permit_joining_req_param_t);
    
            req_param->dest_addr = 0xfffc;
            req_param->permit_duration = 0;
            req_param->tc_significance = 1;
    
            zb_zdo_mgmt_permit_joining_req(buf, permit_joining_cb);
          
    #ifdef ZB_USE_BUTTONS
            zb_button_register_handler(0, 0, button_press_handler);
    #endif /* ZB_USE_BUTTONS */
            break;
          case ZB_BDB_SIGNAL_DEVICE_REBOOT:
            Log_printf(LogModule_Zigbee_App, Log_INFO, "Device RESTARTED OK");
            if (perform_factory_reset)
            {
              Log_printf(LogModule_Zigbee_App, Log_INFO, "Performing a factory reset.");
              zb_bdb_reset_via_local_action(0);
              perform_factory_reset = ZB_FALSE;
            }
            else
            {
              ZB_SCHEDULE_APP_ALARM_CANCEL(off_network_attention, ZB_ALARM_ANY_PARAM);
              zb_osif_led_off(1);
            }
    #ifdef ZB_USE_BUTTONS
            zb_button_register_handler(0, 0, button_press_handler);
    #endif /* ZB_USE_BUTTONS */
            break;
    #ifdef ZB_COORDINATOR_ROLE
          case ZB_ZDO_SIGNAL_DEVICE_ANNCE:
    #else
          case ZB_BDB_SIGNAL_TC_REJOIN_DONE:
            Log_printf(LogModule_Zigbee_App, Log_INFO, "TC rejoin is completed successfully");
          case ZB_BDB_SIGNAL_STEERING:
    #endif
          {
            zb_nwk_device_type_t device_type = ZB_NWK_DEVICE_TYPE_NONE;
            device_type = zb_get_device_type();
            ZVUNUSED(device_type);
            Log_printf(LogModule_Zigbee_App, Log_INFO, "Device (%d) STARTED OK", device_type);
            ZB_SCHEDULE_APP_ALARM(start_finding_binding, 0, 3 * ZB_TIME_ONE_SECOND);
            ZB_SCHEDULE_APP_ALARM_CANCEL(off_network_attention, ZB_ALARM_ANY_PARAM);
    #ifdef ZB_USE_BUTTONS
            zb_button_register_handler(0, 0, button_press_handler);
    #endif /* ZB_USE_BUTTONS */
            zb_osif_led_off(1);
            break;
          }
    
          case ZB_BDB_SIGNAL_FINDING_AND_BINDING_INITIATOR_FINISHED:
          {
            Log_printf(LogModule_Zigbee_App, Log_INFO, "Finding&binding done");
    #ifndef ZB_USE_BUTTONS
            /* Do not have buttons in simulator - just start periodic on/off sending */
            cmd_in_progress = ZB_FALSE;
            ZB_SCHEDULE_APP_ALARM_CANCEL(button_press_handler, ZB_ALARM_ANY_PARAM);
            ZB_SCHEDULE_APP_ALARM(button_press_handler, 0, 7 * ZB_TIME_ONE_SECOND);
    #endif
          }
          break;
    
          case ZB_ZDO_SIGNAL_LEAVE:
          break;
          case ZB_COMMON_SIGNAL_CAN_SLEEP:
          {
    #ifdef ZB_USE_SLEEP
            zb_sleep_now();
    #endif
            break;
          }
          case ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY:
          {
            Log_printf(LogModule_Zigbee_App, Log_INFO, "Production config is ready");
            break;
          }
    
          default:
            Log_printf(LogModule_Zigbee_App, Log_WARNING, "Unknown signal %d, do nothing", sig);
        }
      }
      else
      {
        switch (sig)
        {
          case ZB_BDB_SIGNAL_DEVICE_FIRST_START:
            Log_printf(LogModule_Zigbee_App, Log_WARNING, "Device can not find any network on start, so try to perform network steering");
            ZB_SCHEDULE_APP_ALARM(restart_commissioning, 0, 10 * ZB_TIME_ONE_SECOND);
            break; /* ZB_BDB_SIGNAL_DEVICE_FIRST_START */
    
          case ZB_BDB_SIGNAL_DEVICE_REBOOT:
            Log_printf(LogModule_Zigbee_App, Log_WARNING, "Device can not find any network on restart");
    
            if (zb_bdb_is_factory_new())
            {
              /* Device tried to perform TC rejoin after reboot and lost its authentication flag.
               * Do nothing here and wait for ZB_BDB_SIGNAL_TC_REJOIN_DONE to handle TC rejoin error */
              Log_printf(LogModule_Zigbee_App, Log_WARNING, "Device lost authentication flag");
            }
            else
            {
              /* Device tried to perform secure rejoin, but didn't found any networks or can't decrypt Rejoin Response
               * (it is possible when Trust Center changes network key when ZED is powered off) */
              Log_printf(LogModule_Zigbee_App, Log_WARNING, "Device is still authenticated, try to perform TC rejoin");
              ZB_SCHEDULE_APP_ALARM(zb_bdb_initiate_tc_rejoin, 0, ZB_TIME_ONE_SECOND);
            }
            break; /* ZB_BDB_SIGNAL_DEVICE_REBOOT */
    
          case ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY:
            Log_printf(LogModule_Zigbee_App, Log_INFO, "Production config is not present or invalid");
            break; /* ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY */
    
          case ZB_BDB_SIGNAL_TC_REJOIN_DONE:
            Log_printf(LogModule_Zigbee_App, Log_WARNING, "TC rejoin failed, so try it again with interval");
    
            ZB_SCHEDULE_APP_ALARM(zb_bdb_initiate_tc_rejoin, 0, 3 * ZB_TIME_ONE_SECOND);
            break; /* ZB_BDB_SIGNAL_TC_REJOIN_DONE */
    
          case ZB_BDB_SIGNAL_STEERING:
            Log_printf(LogModule_Zigbee_App, Log_WARNING, "Steering failed, retrying again in 10 seconds");
            ZB_SCHEDULE_APP_ALARM(restart_commissioning, 0, 10 * ZB_TIME_ONE_SECOND);
            break; /* ZB_BDB_SIGNAL_STEERING */
    
          default:
            Log_printf(LogModule_Zigbee_App, Log_WARNING, "Unknown signal %hd with error status, do nothing", sig);
            break;
        }
      }
    
      if (param)
      {
        zb_buf_free(param);
      }
    }
    

    Regards,
    Ryan

  • At the same time, I am also facing another problem.

    The onoff_switch example shows that after entering the periodic sleep mode in version 8_40_02_01, the sleep current can be below 2uA. But in the 9_12_00_19 version entered the periodic sleep mode, the sleep current was 2mA,it not enter the low-power mode.Have there been any changes to the sleep mode in these two SDK versions?

  • Hi baosong,

    There are tests performed at each major SDK release to verify that standby power consumption is as expected.  Are you using a default onoff_switch example imported directly from F3 SDK v9.12 with all the correct dependencies from the SDK Release Notes?  Have you tried F3 SDK v9.10 as well as a reference point?

    Regards,
    Ryan

  • I just ran the default onoff_light and onoff_switch examples for SimpleLink F3 SDK v9.12, and when measuring the onoff_switch CC2340R5 LP current consumption in EnergyTrace there is no indication that low-power standby mode is not being utilized properly.

    Regards,
    Ryan