Code: Select all
//get number of groups the node belongs to
size_t group_id_num = 3;
const uint8_t group_id_list[3][6] = {
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
{0x01, 0x00, 0x5e, 0xaa, 0xaa, 0xaa},
{0x01, 0x00, 0x5e, 0xac, 0xac, 0xac},
};
//format data to multicast {"request":"set_status","characteristics":[{"cid":0,"value":1}]}
int nRes = asprintf(&data_on, "{\"request\":\"set_status\",\"characteristics\":[{\"cid\":0,\"value\":1}]}");
ret = nRes <= 0 ? MDF_ERR_INVALID_ARG : MDF_OK;
MDF_ERROR_CONTINUE(ret != MDF_OK, "asprintf() failed to format data -> no message sent, continue");
size = (size_t)nRes;
//multicasting (unicast transfer to each group id)
for (int i = 0; i < group_id_num; ++i)
{
ret = mwifi_write(group_id_list[i], &data_type, data_on, size, true);
MDF_ERROR_CONTINUE(ret != MDF_OK, "mwifi_write() failed to send data to group id " MACSTR ", error (%s)", MAC2STR(group_id_list[i]), mdf_err_to_name(ret));
MDF_LOGW("\tsent to group_id: " MACSTR, MAC2STR(group_id_list[i]));
}
MDF_FREE(data_on);
Is the message {"request":"set_status","characteristics":[{"cid":0,"value":1}]} miss some parameter or header?