Good day.
I am currently developing with two NRF52840 DK boards, and I also have two NRF Dongles. On a dongle a sniffer for ZigBee. I am working with SDK 3.2. This is my first project with ZigBee, so I don't have much know-how yet.
My goal is to implement the coordinator as like CLI agent. So that it subscribes to the multi-sensor and receives data. Is so to speak an A to B communication.
With "zb_zdo_match_desc_req()" I get the short address and the endpoint of the sensor. Then with "zb_zdo_ieee_addr_req()" I get the long address (EUI64) of the sensor. After that the "zb_zdo_bind_req()" request starts (Between coordinator and sensor) and in the callback function ("p_resp->status") this is confirmed successfully with ZB_ZDP_STATUS_SUCCESS. However, I only connect to the ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT cluster.
My questions:
1) Is it necessary to connect both clusters (temperature/pressure) to subscribe to the multisensor? If so, is the bind request simply done again with the ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT?
2) Is subscribing the sensor in the first step as below, correct?
// Step 8: // Subscribe on Sensor static void subscribe_device(zb_uint8_t param) { zb_buf_t * p_buf = ZB_BUF_FROM_REF(param); configure_reporting_req_t req; tsn_ctx_t * p_tsn_cli; zb_uint8_t * p_cmd_ptr; zb_ret_t zb_err_code; //zb_bool_t subscribe; zb_ieee_addr_t sensor_ieee_adr; NRF_LOG_INFO("----------------------------------------"); NRF_LOG_INFO("Step 8: subscribe_device"); req.profile_id = ZB_AF_HA_PROFILE_ID; req.cluster_id = ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT; //ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT; // req.attr_id = ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID; req.attr_type = ZB_ZCL_ATTR_TYPE_S16; //ZB_ZCL_ATTR_TYPE_16BIT; req.interval_min = ZIGBEE_CONFIGURE_REPORT_DEFAULT_MIN_INTERVAL; req.interval_max = ZIGBEE_CONFIGURE_REPORT_DEFAULT_MAX_INTERVAL; req.remote_node.addr_short = m_device_ctx.bulb_params.short_address; req.remote_addr_mode = ZB_APS_ADDR_MODE_16_ENDP_PRESENT; //= parse_address(addr_buf, &req.remote_node, ADDR_ANY); req.remote_ep = m_device_ctx.bulb_params.endpoint; p_buf = ZB_GET_OUT_BUF(); NRF_LOG_INFO("Configure Reporting"); p_tsn_cli = get_free_tsn_ctx(); if (!p_tsn_cli) { NRF_LOG_ERROR("Too many configure reporting requests"); ZB_FREE_BUF(p_buf); return; } // Configure new tsn context. p_tsn_cli->taken = true; //p_tsn_cli->p_cli = p_cli; p_tsn_cli->tsn = ZCL_CTX().seq_number; ZB_ZCL_GENERAL_INIT_CONFIGURE_REPORTING_SRV_REQ(p_buf, p_cmd_ptr, ZB_ZCL_ENABLE_DEFAULT_RESPONSE); ZB_ZCL_GENERAL_ADD_SEND_REPORT_CONFIGURE_REPORTING_REQ(p_cmd_ptr, req.attr_id, req.attr_type, req.interval_min, req.interval_max, ZIGBEE_CONFIGURE_REPORT_DEFAULT_VALUE_CHANGE); ZB_ZCL_GENERAL_SEND_CONFIGURE_REPORTING_REQ(p_buf, p_cmd_ptr, req.remote_node, req.remote_addr_mode, req.remote_ep, m_device_ctx.co_params.endpoint, //CONTROLL_ENDPOINT req.profile_id, req.cluster_id, NULL); NRF_LOG_INFO("Report sended Waiting for Values"); //zb_err_code = ZB_SCHEDULE_ALARM(zb_subscribe_timeout, p_tsn_cli->tsn, ZIGBEE_CLI_CONFIGURE_REPORT_RESP_TIMEOUT * ZB_TIME_ONE_SECOND); if (zb_err_code != RET_OK) { NRF_LOG_ERROR("Unable to schedule timeout timer"); invalidate_ctx(p_tsn_cli); } NRF_LOG_INFO("End"); }
3) Does it even need "cmd_zb_subscribe_unsubscribe_cb" and what is that unsubscribe for?
My problems:
1) The "ep_handler_report" is not called, but I see in Wireshark that a Report Attributes has been sent?
Is there still something to change at the sensor, because there I have left everything as is.
My ep_handler_report Handler:
static zb_uint8_t ep_handler_report(zb_uint8_t param) { NRF_LOG_INFO("Ep Handler Report"); zb_buf_t * p_zcl_cmd_buf = (zb_buf_t *)ZB_BUF_FROM_REF(param); zb_zcl_parsed_hdr_t * p_cmd_info = ZB_GET_BUF_PARAM(p_zcl_cmd_buf, zb_zcl_parsed_hdr_t); tsn_ctx_t * p_tsn_ctx; if (p_cmd_info->cmd_id == ZB_ZCL_CMD_REPORT_ATTRIB) { NRF_LOG_INFO("print_attr"); print_attr(p_cmd_info, param); ZB_FREE_BUF_BY_REF(param); return ZB_TRUE; } else if (p_cmd_info->cmd_id == ZB_ZCL_CMD_CONFIG_REPORT_RESP) { // Find command context by ZCL sequence number. p_tsn_ctx = get_ctx_by_tsn(p_cmd_info->seq_number); if (p_tsn_ctx != NULL) { NRF_LOG_WARNING("Unsubscribe cb"); cmd_zb_subscribe_unsubscribe_cb(p_tsn_ctx, param); return ZB_TRUE; } } NRF_LOG_INFO("False Handler report"); ZB_FREE_BUF_BY_REF(param); return ZB_FALSE; } /* Register callback for handling ZCL commands. */ ZB_AF_SET_ENDPOINT_HANDLER(m_device_ctx.bulb_params.endpoint, ep_handler_report);
The other functions as well as the output of the data I took from the CLI as well as from other discussions.
With the function "print_attr()" the data is output (Same function as with CLI), what am I doing wrong here with subscribe?
2) After a while the network crashes, any idea what this is? The Connected LED on the sensor goes out.
I would also be glad if you could give me a quick rundown on the process for subscribing to devices. If you want the whole code, I can share it with pleasure.
Thanks in advance.
With kind regards
Jonas T