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

Zigbee Find, Bind, Subscribe.

Hello.

I am trying to implement a Zigbee Network were sensors will be posting data periodically to a Coordinator. 

I was looking into the examples provided with the SDK and realized that the Zigbee MultiSensor example is similiar to what i want to implement. The End Device set the attributes and the Coordinator susbcribe to it.

I wanted to know if there is some documentation that describes how i can implement in code the configuration required for the Zigbee CLI Coordinator. I want to perform the find, bind and subscribe using the stack functions. I would really appreciate if you can help me with some example code for that.

Thanks! 

  • Hi,

    You can find the Zigbee functions that are called in the CLI example if you open the project. In components/zigbee/cli/zigbee_cli_cmd_zdo.c you can find the zdo functins, such as "zdo bind on".

    On line 1816-1831 is a list of the different commands, and the last parameter in the NRF_CLI_CMD() call is the function that is called. So the "zdo bind on" calls m_sub_bind (this is not the last entry, but it is used to differentiate between bind on and bind off). Which again calls cmd_zb_bind on line 1811 in the same file.

    The zcl commands are listed in zigbee_cli_cmd_zcl.c. As you can see, the zcl_subscribe on calls m_sub_subscribe() -> cmd_zb_subscribe(), which is found in components/zigbee/cli/zigbee_cli_cmd_attr_report.c.

    Reports are received by a function cli_agent_ep_handler_report , which gets called from cli_agent_ep_handler which is registered in main function of cli_agent_router example with ZB_AF_SET_ENDPOINT_HANDLER macro.

    I hope this can be of help. Let me know how it goes!

    Best Regards,

    Marjeris

  • no no 。。。Nobody does that. It's a bad example. It doesn't help.I have been in contact with zigbee and ble mesh for a month, but there is no help. Many developers of NXP chips have completed the project, and I am still walking in the same place.


  • case ZB_BDB_SIGNAL_DEVICE_REBOOT:
    if (status == RET_OK)
    {




    //ZB_NWK_DEVICE_TYPE_COORDINATOR

    NRF_LOG_INFO("Device started OK. Start network steering. Reason: %d", sig);
    bsp_board_led_on(ZIGBEE_NETWORK_STATE_LED);
    UNUSED_RETURN_VALUE(bdb_start_top_level_commissioning(ZB_BDB_NETWORK_STEERING));

    zb_err_code = ZB_SCHEDULE_ALARM(bdb_restart_top_level_commissioning, 0, ZB_TIME_ONE_SECOND);
    ZB_ERROR_CHECK(zb_err_code);


    if (m_device_ctx.sensor_params.short_addr == 0x0000)
    {
    NRF_LOG_INFO("go to find sensor ");
    zb_err_code = ZB_SCHEDULE_ALARM(find_sensor, param, MATCH_DESC_REQ_START_DELAY);
    ZB_ERROR_CHECK(zb_err_code);
    zb_err_code = ZB_SCHEDULE_ALARM(find_timeout, 0, MATCH_DESC_REQ_TIMEOUT);
    ZB_ERROR_CHECK(zb_err_code);

    param=0;
    } //bind_sensor

    static zb_void_t find_sensor(zb_uint8_t param)
    {


    zb_buf_t * p_buf = ZB_BUF_FROM_REF(param); // Resolve buffer number to buffer address
    zb_zdo_match_desc_param_t * p_req;

    /* Initialize pointers inside buffer and reserve space for zb_zdo_match_desc_param_t request */
    UNUSED_RETURN_VALUE(ZB_BUF_INITIAL_ALLOC(p_buf, sizeof(zb_zdo_match_desc_param_t) + (1) * sizeof(zb_uint16_t), p_req));

    p_req->nwk_addr = MATCH_DESC_REQ_ROLE; // Send to devices specified by MATCH_DESC_REQ_ROLE
    p_req->addr_of_interest = MATCH_DESC_REQ_ROLE; // Get responses from devices specified by MATCH_DESC_REQ_ROLE
    p_req->profile_id = ZB_AF_HA_PROFILE_ID; // Look for Home Automation profile clusters
    // 要点
    /* We are searching for 2 clusters: On/Off and Level Control Server */
    p_req->num_in_clusters = 1;
    p_req->num_out_clusters = 0;
    /*lint -save -e415 // Suppress warning 415 "likely access of out-of-bounds pointer" */
    // p_req->cluster_list[0] = ZB_ZCL_CLUSTER_ID_DOOR_LOCK;
    p_req->cluster_list[1] = ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT;
    /*lint -restore */

    NRF_LOG_INFO(" sensor short addr %04x",m_device_ctx.sensor_params.short_addr);
    //NRF_LOG_INFO(" sensor nwk_addr %s",p_req->nwk_addr);

    // m_device_ctx.sensor_params.short_addr = 0x00; // Reset short address in order to parse only one response.
    UNUSED_RETURN_VALUE(zb_zdo_match_desc_req(param, find_sensor_cb));


    }


    if(m_device_ctx.sensor_params.short_addr != 0x0000)
    {

    NRF_LOG_INFO("bind .........");

    zb_err_code = ZB_SCHEDULE_ALARM(bind_sensor, param, MATCH_DESC_REQ_START_DELAY);
    ZB_ERROR_CHECK(zb_err_code);
    zb_err_code = ZB_SCHEDULE_ALARM(bint_sensor_timeout, 0, MATCH_DESC_REQ_TIMEOUT);
    ZB_ERROR_CHECK(zb_err_code);

    }

    It's not easy to do in cli mode. There are many requests and responses. This chip manufacturer really feels bad

  • Hi ,

    If you have any questions regarding Zigbee or BLE mesh protocol please open a new ticket and we will happily help you. To open a new ticket please go to https://devzone.nordicsemi.com/support/add

Related