It appears to me that the zb_zdo_ep_resp_t struct is missing a variable value attribute since the actual list of end points is missing. Should it not be similar to zb_zdo_match_desc_param_t which has a variable length cluster_list[1].
It appears to me that the zb_zdo_ep_resp_t struct is missing a variable value attribute since the actual list of end points is missing. Should it not be similar to zb_zdo_match_desc_param_t which has a variable length cluster_list[1].
Hello Darren,
So you are talking about the active_ep CLI command, is that correct?
When I tested this command on the multisensor example, it gave:
> zdo active_ep 0xC639 > src_addr=C639 ep=10 Done
Is there something missing? I didn't understand what exactly you refer to.
BR,
Edvin
Hello Darren,
So you are talking about the active_ep CLI command, is that correct?
When I tested this command on the multisensor example, it gave:
> zdo active_ep 0xC639 > src_addr=C639 ep=10 Done
Is there something missing? I didn't understand what exactly you refer to.
BR,
Edvin
The zb_zdo_ep_resp_t includes a variable list of endpoints. The actual number of endpoints returned is stored in ep_count but there is no actual entry in the structure for the start of the end point list. Shouldn't the structure look like the following:
/** @brief Active EP response */
typedef ZB_PACKED_PRE struct zb_zdo_ep_resp_s
{
zb_uint8_t tsn; /*!< ZDP transaction sequence number */
zb_uint8_t status; /*!< The status of the Active_EP_req command. */
zb_uint16_t nwk_addr; /*!< NWK address for the request. */
zb_uint8_t ep_count; /*!< The count of active endpoints on the Remote Device. */
zb_uint8_t ep_list[1]; /!< variable size: [ep_count] */
}
ZB_PACKED_STRUCT
zb_zdo_ep_resp_t;
Thanks,
Darren
The list of EPs is in the p_buf, which you can get from the zb_uint8_t param in the callback:
If you look in zmd_zb_active_ep_cb():
static zb_void_t cmd_zb_active_ep_cb(zb_uint8_t param)
{
zb_buf_t * p_buf = ZB_BUF_FROM_REF(param);
zb_zdo_ep_resp_t * p_resp = (zb_zdo_ep_resp_t *)ZB_BUF_BEGIN(p_buf);
zdo_tsn_ctx_t * p_tsn_ctx;
p_tsn_ctx = get_ctx_by_tsn(p_resp->tsn);
if (!p_tsn_ctx)
{
ZB_FREE_BUF_BY_REF(param);
return;
}
if (p_resp->status == ZB_ZDP_STATUS_SUCCESS)
{
nrf_cli_fprintf(p_tsn_ctx->p_cli,
NRF_CLI_NORMAL,
"src_addr=%0hx ",
p_resp->nwk_addr);
PRINT_LIST(p_tsn_ctx->p_cli, "ep=", "%d", zb_uint8_t,
(zb_uint8_t *)p_resp + sizeof(zb_zdo_ep_resp_t),
p_resp->ep_count);
print_done(p_tsn_ctx->p_cli, ZB_TRUE);
}
else
{
print_error(p_tsn_ctx->p_cli,
"active ep request failed");
}
invalidate_ctx(p_tsn_ctx);
ZB_FREE_BUF_BY_REF(param);
}
the function PRINT_LIST() will print all of the EPs.
If you look at the definition of PRINT_LIST:
/**@breif Print a list of items.
*
* Individual items in the list are delimited by comma.
*
* @param p_cli a pointer to CLI instance
* @param hdr the list header string
* @param fmt a printf like format of an individual list item
* @param type type of the list item
* @param size the list size (in items)
*/
#define PRINT_LIST(p_cli, hdr, fmt, type, ptr, size) \
{ \
/*lint -e662 */ \
nrf_cli_fprintf(p_cli, NRF_CLI_NORMAL, hdr); \
for (type * p_item = (ptr); p_item < (ptr) + size - 1; p_item++) \
{ \
nrf_cli_fprintf(p_cli, \
NRF_CLI_NORMAL, \
fmt ",", \
*p_item); \
} \
\
if (size > 0) \
{ \
nrf_cli_fprintf(p_cli, \
NRF_CLI_NORMAL, \
fmt " ", \
*((ptr) + size - 1)); \
} \
/*lint -restore */ \
}
You can see that it takes 6 parameters, where the 5th is a pointer, which is fetched from p_resp, which is fetched from p_buf, which again is fetched from zb_uint8_t param in the callback.
BR,
Edvin