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

Erase Zigbee Connection Params

Hi, what is the correct way to erase all the connection params of a zigbee router device (not coordinator), and restart to search for a network automatically in production?, Ive noticed that when I erase the device from the coordinator and the router is offline, when I power it up again it goes into Joined Network as if it was still part of the network so it wont go into bdb_start_top_level_commissioning, Ive used zb_nvram_clear, but dont know if its correct to use it on production.

Best regards!

  • Hi.

    You could use the procedure in the light_control example (examples\zigbee\light_control\light_switch\main.c):

    Leave the network and erase connection params:

    /**@brief Perform local operation - leave network.
     *
     * @param[in]   param   Reference to ZigBee stack buffer that will be used to construct leave request.
     */
    static void light_switch_leave_nwk(zb_uint8_t param)
    {
        zb_ret_t zb_err_code;
    
        /* We are going to leave */
        if (param)
        {
            zb_buf_t                  * p_buf = ZB_BUF_FROM_REF(param);
            zb_zdo_mgmt_leave_param_t * p_req_param;
    
            p_req_param = ZB_GET_BUF_PARAM(p_buf, zb_zdo_mgmt_leave_param_t);
            UNUSED_RETURN_VALUE(ZB_BZERO(p_req_param, sizeof(zb_zdo_mgmt_leave_param_t)));
    
            /* Set dst_addr == local address for local leave */
            p_req_param->dst_addr = ZB_PIBCACHE_NETWORK_ADDRESS();
            p_req_param->rejoin   = ZB_FALSE;
            UNUSED_RETURN_VALUE(zdo_mgmt_leave_req(param, NULL));
        }
        else
        {
            zb_err_code = ZB_GET_OUT_BUF_DELAYED(light_switch_leave_nwk);
            ZB_ERROR_CHECK(zb_err_code);
        }
    }

    To join the network:

    /**@brief Function for starting join/rejoin procedure.
     *
     * param[in]   leave_type   Type of leave request (with or without rejoin).
     */
    static zb_void_t light_switch_retry_join(zb_uint8_t leave_type)
    {
        zb_bool_t comm_status;
    
        if (leave_type == ZB_NWK_LEAVE_TYPE_RESET)
        {
            comm_status = bdb_start_top_level_commissioning(ZB_BDB_NETWORK_STEERING);
            ZB_COMM_STATUS_CHECK(comm_status);
        }
    }

    Best regards,

    Andreas

Related