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

How to progress leave and rejoin to zigbee network manually without factory resert

Hi, 

Some of purpose we want to terminate current  connection and rejoin to exit PAN.

I use zdo_mgmt_leave_req to request for leave. However , at callback , the status is "132"  which is meant NO SUPPORt.

From other discussion tread, zb_bdb_reset_via_local_action is use to progress factory reset and rejoin.

Look at the sniffer and i fund end device would send an broadcast which is the NLME Leave command.

Is there any API  we can use to send the NLME Leave indication and with that the rejoin flag is set?

We want to clean the connection but do not progress the pairing again,

 

BR

Brian Chang 

Parents
  • Hello Brian,

    what callback has the value 132?

     

    Is there any API  we can use to send the NLME Leave indication and with that the rejoin flag is set?

     At this point I am not sure about a command that does this, but why do you need to do it? I don't think I understood. Reset the PAN? What does that mean?

  • Hi Edvin,

    132 is the status feedback at call back and it show that is " NOT SUPPORT" from the CLI agent example.

    However , why we do this is because we met a error code -1191 during the data transmit and the error code would be terminated until reset the ZigBee network. It is meant we would see that zboss progress rejoin sometimes when this error code keep happening.  

    Reset the PAN is meant that the device is commissioning for joining new network but not rejoin the original PAN. Customer do not want to reset the device and looking the way to force the device terminate the current connection and rejoin network.

    BR

    Brian Chang  

  • Brian Chang said:
    Reset the PAN is meant that the device is commissioning for joining new network but not rejoin the original PAN.

     PAN is short for "Personal Area Network". The zigbee network that you will disconnect from and connect to will have the same PAN. All the devices in this network has the same PAN. 

    Again, I am not sure about what function to use in your inital request, but I suspect that that would be solving an XY problem, and not the actual issue itself. 

    What function/callback triggered the error code -1191? Are you using the nRF5 SDK or NCS?

  • Hi ,

    The code is build at NCS v1.4.0

    •  zdo_mgmt_leave_req(param, leave_callback): we use this mgmt  function to progress the leave&rejoin  and at callback function get the response "NOT_SUPPORTED" from coordinator.
      void leave_callback(zb_uint8_t param)
      {
        zb_zdo_mgmt_leave_res_t *resp = (zb_zdo_mgmt_leave_res_t *)zb_buf_begin(param);
        LOG_INF("LEAVE CALLBACK status %hd", resp->status);
      
        k_timer_stop(&leave_timeout);
        //zb_bdb_reset_via_local_action(0);   // reset from local 
      
      }
      
      
      void m_zdo_mgmt_level(zb_bufid_t param)
      {
        zb_bufid_t buf = param;
        zb_zdo_mgmt_leave_param_t *req = NULL;
        zb_ret_t ret = RET_OK;
        zb_uint8_t tsn;
      
        LOG_INF("zb_leave_req");
        req = ZB_BUF_GET_PARAM(buf, zb_zdo_mgmt_leave_param_t);
      
        ZB_MEMSET(req->device_address, 0, sizeof(zb_ieee_addr_t));
        req->remove_children = ZB_FALSE; // not kill this device 
        req->rejoin = ZB_TRUE;           // do  rejoin 
        req->dst_addr = 0;               // target zc
        tsn = zdo_mgmt_leave_req(param, leave_callback);
        
        //sys_reboot(0);
        k_timer_start(&leave_timeout, K_MSEC(500),
      			      K_NO_WAIT);
      }
    • We use manufacture cluster to exchange data  by sending command and setup the APS callback to control data retransmission manually. The -1191 is got from this aps callback, 
      */
      /*! @brief Client send command command 0 to server with character string payload
          @param buffer to put data to
          @param addr - address of the device to send command to
          @param dst_addr_mode - addressing mode
          @param dst_ep destination endpoint
          @param src_ep - current endpoint
          @param prof_id - profile identifier
          @param dis_default_resp - "Disable default response" flag
          @param manuf_code - manufacturer code value
          @param cb - callback to call to report send status
      */
      #define ZB_ZCL_MANUF_SEND_CMD0_REQ(                                                                      \
          buffer, addr, dst_addr_mode, dst_ep, src_ep, prof_id, dis_default_resp, manuf_code, cb, zcl_str_ptr) \
      {                                                                                                        \
          zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer)                                                    \
          ZB_ZCL_CONSTRUCT_FRAME_CONTROL(ZB_ZCL_FRAME_TYPE_CLUSTER_SPECIFIC,                                   \
                                       ZB_ZCL_MANUFACTURER_SPECIFIC,                                           \
                                       ZB_ZCL_FRAME_DIRECTION_TO_SRV, (dis_default_resp)),                     \
          manuf_code,                                                                                          \
          ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(),                                       \
          ZB_ZCL_CMD_MANUF_SPEC_CMD0_ID);                                                                      \
          ZB_ZCL_PACKET_PUT_STRING(ptr, (zcl_str_ptr));                                                        \
          ZB_ZCL_FINISH_PACKET(buffer, ptr)                                                                    \
          ZB_ZCL_SEND_COMMAND_SHORT(                                                                           \
              buffer, addr, dst_addr_mode, dst_ep, src_ep, prof_id, ZB_ZCL_CLUSTER_ID_MANUF_SPEC, cb);         \
      }
      
      void zb_send_manuf_cmd0(zb_bufid_t bufid)
      {
      
          zb_char_t zcl_str[ZB_ZCL_CUSTOM_CLUSTER_ATTR_CHAR_STRING_MAX_SIZE];
      
          zcl_str[0] = sizeof(m_zcl_custom_cluster_cmd0_str)+1;
          // my test 
          zcl_str[1] = pkt_cnt++;
          if((zcl_str[0] + 2) < ZB_ZCL_CUSTOM_CLUSTER_ATTR_CHAR_STRING_MAX_SIZE)
          {
              memcpy(zcl_str + 2, m_zcl_custom_cluster_cmd0_str, zcl_str[0]);
          }
          else
          {
              LOG_INF("str size error");
              return;
          }
      
          ZB_ZCL_MANUF_SEND_CMD0_REQ(bufid,
                                 bulb_ctx.short_addr,
                                 ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
                                 bulb_ctx.endpoint,
                                 LIGHT_SWITCH_ENDPOINT,
                                 ZB_AF_HA_PROFILE_ID,
                                 ZB_ZCL_DISABLE_DEFAULT_RESPONSE,
                                 ZB_DEVICE_MANUFACTURER_CODE,
                                 test_aps_callback,
                                 zcl_str);
      }
      
      
      void test_aps_callback(zb_bufid_t bufid)
      {
          zb_zcl_command_send_status_t * p_cmd_status;
          zb_ret_t                       zb_err_code = RET_OK;
          if (bufid == 0)
          {
              return;
          }
      
          p_cmd_status= ZB_BUF_GET_PARAM(bufid, zb_zcl_command_send_status_t);
          zb_err_code = p_cmd_status->status;
          zb_err_code1 = zb_err_code;
          if(zb_err_code == RET_OK)
          {
      
              if(pkt_cnt <1000)
              {
              
              zb_err_code = zb_buf_get_out_delayed(zb_send_manuf_cmd0);
              ZB_ERROR_CHECK(zb_err_code);
              
              }
              else
              {
                LOG_INF("APS call back FINISH");
                pkt_cnt = 0;
                zb_err_code = zb_buf_get_out_delayed(zb_send_write_manuf_attr0_req);
                ZB_ERROR_CHECK(zb_err_code);
              }
          }
          else
          {   
               LOG_INF(" APS Fail error code %hd",zb_err_code);
               zigbee_get_in_buf_delayed(zb_send_manuf_cmd0);
            
      
          }
      
          zb_buf_free(bufid);
      
      }

    What the function we look at is like disable zboss , restart it again with the existing PAN ID but not doing hardware reset. Probably that is not an common operation.

    BR

    Brian 

Reply
  • Hi ,

    The code is build at NCS v1.4.0

    •  zdo_mgmt_leave_req(param, leave_callback): we use this mgmt  function to progress the leave&rejoin  and at callback function get the response "NOT_SUPPORTED" from coordinator.
      void leave_callback(zb_uint8_t param)
      {
        zb_zdo_mgmt_leave_res_t *resp = (zb_zdo_mgmt_leave_res_t *)zb_buf_begin(param);
        LOG_INF("LEAVE CALLBACK status %hd", resp->status);
      
        k_timer_stop(&leave_timeout);
        //zb_bdb_reset_via_local_action(0);   // reset from local 
      
      }
      
      
      void m_zdo_mgmt_level(zb_bufid_t param)
      {
        zb_bufid_t buf = param;
        zb_zdo_mgmt_leave_param_t *req = NULL;
        zb_ret_t ret = RET_OK;
        zb_uint8_t tsn;
      
        LOG_INF("zb_leave_req");
        req = ZB_BUF_GET_PARAM(buf, zb_zdo_mgmt_leave_param_t);
      
        ZB_MEMSET(req->device_address, 0, sizeof(zb_ieee_addr_t));
        req->remove_children = ZB_FALSE; // not kill this device 
        req->rejoin = ZB_TRUE;           // do  rejoin 
        req->dst_addr = 0;               // target zc
        tsn = zdo_mgmt_leave_req(param, leave_callback);
        
        //sys_reboot(0);
        k_timer_start(&leave_timeout, K_MSEC(500),
      			      K_NO_WAIT);
      }
    • We use manufacture cluster to exchange data  by sending command and setup the APS callback to control data retransmission manually. The -1191 is got from this aps callback, 
      */
      /*! @brief Client send command command 0 to server with character string payload
          @param buffer to put data to
          @param addr - address of the device to send command to
          @param dst_addr_mode - addressing mode
          @param dst_ep destination endpoint
          @param src_ep - current endpoint
          @param prof_id - profile identifier
          @param dis_default_resp - "Disable default response" flag
          @param manuf_code - manufacturer code value
          @param cb - callback to call to report send status
      */
      #define ZB_ZCL_MANUF_SEND_CMD0_REQ(                                                                      \
          buffer, addr, dst_addr_mode, dst_ep, src_ep, prof_id, dis_default_resp, manuf_code, cb, zcl_str_ptr) \
      {                                                                                                        \
          zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer)                                                    \
          ZB_ZCL_CONSTRUCT_FRAME_CONTROL(ZB_ZCL_FRAME_TYPE_CLUSTER_SPECIFIC,                                   \
                                       ZB_ZCL_MANUFACTURER_SPECIFIC,                                           \
                                       ZB_ZCL_FRAME_DIRECTION_TO_SRV, (dis_default_resp)),                     \
          manuf_code,                                                                                          \
          ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(),                                       \
          ZB_ZCL_CMD_MANUF_SPEC_CMD0_ID);                                                                      \
          ZB_ZCL_PACKET_PUT_STRING(ptr, (zcl_str_ptr));                                                        \
          ZB_ZCL_FINISH_PACKET(buffer, ptr)                                                                    \
          ZB_ZCL_SEND_COMMAND_SHORT(                                                                           \
              buffer, addr, dst_addr_mode, dst_ep, src_ep, prof_id, ZB_ZCL_CLUSTER_ID_MANUF_SPEC, cb);         \
      }
      
      void zb_send_manuf_cmd0(zb_bufid_t bufid)
      {
      
          zb_char_t zcl_str[ZB_ZCL_CUSTOM_CLUSTER_ATTR_CHAR_STRING_MAX_SIZE];
      
          zcl_str[0] = sizeof(m_zcl_custom_cluster_cmd0_str)+1;
          // my test 
          zcl_str[1] = pkt_cnt++;
          if((zcl_str[0] + 2) < ZB_ZCL_CUSTOM_CLUSTER_ATTR_CHAR_STRING_MAX_SIZE)
          {
              memcpy(zcl_str + 2, m_zcl_custom_cluster_cmd0_str, zcl_str[0]);
          }
          else
          {
              LOG_INF("str size error");
              return;
          }
      
          ZB_ZCL_MANUF_SEND_CMD0_REQ(bufid,
                                 bulb_ctx.short_addr,
                                 ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
                                 bulb_ctx.endpoint,
                                 LIGHT_SWITCH_ENDPOINT,
                                 ZB_AF_HA_PROFILE_ID,
                                 ZB_ZCL_DISABLE_DEFAULT_RESPONSE,
                                 ZB_DEVICE_MANUFACTURER_CODE,
                                 test_aps_callback,
                                 zcl_str);
      }
      
      
      void test_aps_callback(zb_bufid_t bufid)
      {
          zb_zcl_command_send_status_t * p_cmd_status;
          zb_ret_t                       zb_err_code = RET_OK;
          if (bufid == 0)
          {
              return;
          }
      
          p_cmd_status= ZB_BUF_GET_PARAM(bufid, zb_zcl_command_send_status_t);
          zb_err_code = p_cmd_status->status;
          zb_err_code1 = zb_err_code;
          if(zb_err_code == RET_OK)
          {
      
              if(pkt_cnt <1000)
              {
              
              zb_err_code = zb_buf_get_out_delayed(zb_send_manuf_cmd0);
              ZB_ERROR_CHECK(zb_err_code);
              
              }
              else
              {
                LOG_INF("APS call back FINISH");
                pkt_cnt = 0;
                zb_err_code = zb_buf_get_out_delayed(zb_send_write_manuf_attr0_req);
                ZB_ERROR_CHECK(zb_err_code);
              }
          }
          else
          {   
               LOG_INF(" APS Fail error code %hd",zb_err_code);
               zigbee_get_in_buf_delayed(zb_send_manuf_cmd0);
            
      
          }
      
          zb_buf_free(bufid);
      
      }

    What the function we look at is like disable zboss , restart it again with the existing PAN ID but not doing hardware reset. Probably that is not an common operation.

    BR

    Brian 

Children
  • Hello Brian, 

    Sorry for the late reply, but I have been out during easter vacation here in Norway.

    I still think that restarting the zboss library is not necessarily going to work, Do you have any indication that it will?

    1191 means "ZB_APS_STATUS_NO_ACK". Pretend I don't know anything about your zb_send_manuf_cmd0(). What sort of command are you trying to send? How often is it used? Is it the LOG_INF(" APS Fail error code %hd",zb_err_code); that prints -1191? Do you see the packet in a sniffer trace? Does it receive an ACK? I guess what I am really asking is whether or not the packet is being received by the other nodes, or if the network is drowning in these packets, and from time to time, a packet is lost.

    I'll be away for one week from tomorrow. In case someone else from the team will have time to look into this, please be very specific, so that the person handling this can pass it on to the Zigbee team.

Related