static void cmd_zb_match_desc(nrf_cli_t const * p_cli)
{
NRF_LOG_INFO("WELCOME");
zb_zdo_match_desc_param_t * p_req;
zdo_tsn_ctx_t * p_tsn_cli;
zb_buf_t * p_buf;
uint16_t * p_cluster_list = NULL;
uint8_t len = sizeof(p_req->cluster_list);
zb_ret_t zb_err_code;
zb_bool_t use_timeout = ZB_FALSE;
zb_uint16_t timeout = ZIGBEE_CLI_MATCH_DESC_RESP_TIMEOUT;
int timeout_offset;
zb_uint16_t temp;
int count=6;
char int_array[]={"0xfffd","0xfffd","0xc05","1","0","0"};
// We use p_cluster_list for calls to ZBOSS API but we're not using
// p_cluster_list value in any way.
UNUSED_VARIABLE(p_cluster_list);
/*if ((count == 1) || (nrf_cli_help_requested(p_cli)))
{
print_usage(p_cli, int_array[0],
"<h:16-bit destination address>\r\n"
"<h:requested address/type> <h:profile ID>\r\n"
"<d:number of input clusters> [<h:input cluster IDs> ...]\r\n"
"<d:number of output clusters> [<h:output cluster IDs> ...]\r\n"
"[--timeout d:number of seconds to wait for answers]\r\n");
return;
}*/
if (!strcmp(int_array[1], "-t") || !strcmp(int_array[1], "--timeout"))
{
print_error(p_cli, "Place option 'timeout' at the end of input parameters");
return;
}
if (count < 6)
{
print_error(p_cli, "Incorrect number of arguments");
return;
}
p_buf = ZB_GET_OUT_BUF();
if (!p_buf)
{
print_error(p_cli, "Failed to execute command (buf alloc failed)");
return;
}
ZB_BUF_INITIAL_ALLOC(p_buf, sizeof(*p_req), p_req);
if (!parse_hex_u16(0xfd, &temp))
{
print_error(p_cli, "Incorrect network address");
goto error;
}
if (!parse_hex_u16(int_array[1], &temp))
{
print_error(p_cli, "Incorrect address of interest");
goto error;
}
//zb_uint16_t value=0xfffd;
// p_req->value = temp;
p_req->addr_of_interest = temp;
if (!parse_hex_u16(int_array[3], &temp))
{
print_error(p_cli, "Incorrect profile id");
goto error;
}
p_req->profile_id = temp;
if (!parse_hex_u16(int_array[4], &temp))
{
print_error(p_cli, "Incorrect num_in_clusters");
goto error;
}
p_req->num_in_clusters = temp;
if (!parse_hex_u16(int_array[5], &temp))
{
print_error(p_cli, "Incorrect num_out_clusters");
goto error;
}
p_req->num_out_clusters = temp;
error:
if (p_tsn_cli != NULL)
{
invalidate_ctx(p_tsn_cli);
}
p_tsn_cli->p_cli = p_cli;
p_tsn_cli->is_broadcast = ZB_NWK_IS_ADDRESS_BROADCAST(p_req->nwk_addr);
nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, "Sending %s request.\r\n", p_tsn_cli->is_broadcast ? "broadcast" : "unicast");
p_tsn_cli->tsn = zb_zdo_match_desc_req(ZB_REF_FROM_BUF(p_buf),
cmd_zb_match_desc_cb);
if (p_tsn_cli->tsn == ZB_ZDO_INVALID_TSN)
{
print_error(p_cli, "Failed to send match descriptor request");
goto error;
}
}
static void buttons_handler(bsp_event_t evt)
{
zb_ret_t zb_err_code;
zb_int32_t button;
nrf_cli_t * p_cli;
switch(evt)
{
case BSP_EVENT_KEY_0:
button = LIGHT_SWITCH_BUTTON_ON;
break;
case BSP_EVENT_KEY_1:
button = LIGHT_SWITCH_BUTTON_OFF;
break;
case BSP_EVENT_KEY_2:
// cmd_zb_match_desc(p_cli);
cycle_endpoint(ZB_TRUE);
return;
case BSP_EVENT_KEY_3:
cmd_zb_match_desc(p_cli);
// toggle_find_n_bind();
return;
#ifdef ARDUINO_JOYSTICK_SHIELD_V1A
case BSP_EVENT_KEY_4:
cycle_endpoint(ZB_FALSE);
return;
#endif
default:
NRF_LOG_INFO("Unhandled BSP Event received: %d", evt);
return;
}
if (!m_device_ctx.button.in_progress)
{
m_device_ctx.button.in_progress = ZB_TRUE;
m_device_ctx.button.timestamp = ZB_TIMER_GET();
zb_err_code = ZB_SCHEDULE_ALARM(light_switch_button_handler, button, LIGHT_SWITCH_BUTTON_SHORT_POLL_TMO);
ZB_ERROR_CHECK(zb_err_code);
}
}
Sir in the above code i have a cmd_zb_match_desc() but i am calling inside the switch case but after calling i didn't able going inside the finction
please give the Suggestion how to call this function?????
case BSP_EVENT_KEY_3:
cmd_zb_match_desc(p_cli);
return;