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! 

Parents

  • 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

Reply

  • 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

Children
No Data
Related