Part Number: LAUNCHXL-CC1352R1
Tool/software: Code Composer Studio
Hi all,
I want to broadcast a payload to all the sensors in my NBCN TI15.4 PAN. I have written the below function for the purpose. I am running the application on an Ubuntu host machine with LAUNCHXL-CC1352R1s.
collector.c on Ubuntu
extern void generateBroadcastPld(void)
{
LOG_printf( LOG_DBG_COLLECTOR, "Generating broadcast payload......");
uint8_t buffer[SMSGS_GENERIC_STATUS_REQUEST_MSG_LEN];
/* Build the message */
buffer[0] = (uint8_t)Smsgs_cmdIds_GenericStatusReq;
sendBroadcastMsg(Smsgs_cmdIds_GenericStatusReq, SMSGS_GENERIC_STATUS_REQUEST_MSG_LEN,
buffer);
LOG_printf( LOG_DBG_COLLECTOR, "\t....Sent broadcast payload\n");
}
I also modified the sendBroadcastMsg(..) API as I am not using FH.
static void sendBroadcastMsg(Smsgs_cmdIds_t type, uint16_t len,
uint8_t *pData)
{
ApiMac_mcpsDataReq_t dataReq;
/* Current example is only implemented for FH mode
if(!fhEnabled)
{
return;
}
*/
/* Fill the data request field */
memset(&dataReq, 0, sizeof(ApiMac_mcpsDataReq_t));
dataReq.dstAddr.addrMode = ApiMac_addrType_none;
dataReq.srcAddrMode = ApiMac_addrType_short;
....
....
/* Send the message */
ApiMac_mcpsDataReq(&dataReq);
LOG_printf(LOG_DBG_COLLECTOR_RAW, "Sent BC Message \tType:%d\tLength:%d\n",type,len);
}
While running, I can see the generateBroadcastPld() being executed fine, and with the Sniffer, I can see the packet over the air too.
But at the receiving end, the sensor application does not detect them at the dataIIndCB().
sensor.c
static void dataIndCB(ApiMac_mcpsDataInd_t *pDataInd)
{
uint8_t cmdBytes[SMSGS_TOGGLE_LED_RESPONSE_MSG_LEN];
if((pDataInd != NULL) && (pDataInd->msdu.p != NULL)
&& (pDataInd->msdu.len > 0))
{
Smsgs_cmdIds_t cmdId = (Smsgs_cmdIds_t)*(pDataInd->msdu.p);
#ifdef FEATURE_MAC_SECURITY
{
if(Jdllc_securityCheck(&(pDataInd->sec)) == false)
{
/* reject the message */
return;
}
}
#endif /* FEATURE_MAC_SECURITY */
switch(cmdId)
{
case Smsgs_cmdIds_configReq:
processConfigRequest(pDataInd);
Sensor_msgStats.configRequests++;
break;
case Smsgs_cmdIds_trackingReq:
/* Make sure the message is the correct size */
if(pDataInd->msdu.len == SMSGS_TRACKING_REQUEST_MSG_LENGTH)
{
/* only send data if sensor is in the network */
if ((Jdllc_getProvState() == Jdllc_states_joined) ||
(Jdllc_getProvState() == Jdllc_states_rejoined))
{
/* Update stats */
Sensor_msgStats.trackingRequests++;
/* Indicate tracking message received */
Ssf_trackingUpdate(&pDataInd->srcAddr);
/* send the response message directly */
cmdBytes[0] = (uint8_t) Smsgs_cmdIds_trackingRsp;
Sensor_sendMsg(Smsgs_cmdIds_trackingRsp,
&pDataInd->srcAddr, true,
1, cmdBytes);
}
}
break;
case Smsgs_cmdIds_toggleLedReq:
/* Make sure the message is the correct size */
if(pDataInd->msdu.len == SMSGS_TOGGLE_LED_REQUEST_MSG_LEN)
{
/* only send data if sensor is in the network */
if ((Jdllc_getProvState() == Jdllc_states_joined) ||
(Jdllc_getProvState() == Jdllc_states_rejoined))
{
/* send the response message directly */
cmdBytes[0] = (uint8_t) Smsgs_cmdIds_toggleLedRsp;
cmdBytes[1] = Ssf_toggleLED();
Sensor_sendMsg(Smsgs_cmdIds_toggleLedRsp,
&pDataInd->srcAddr, true,
SMSGS_TOGGLE_LED_RESPONSE_MSG_LEN,
cmdBytes);
}
}
break;
......
......
//When the generic request is received, Ssf_genericCMD() is run and a response is sent back to the collector.
case Smsgs_cmdIds_GenericStatusReq:
/* Make sure the message is the correct size */
if(pDataInd->msdu.len == SMSGS_GENERIC_STATUS_REQUEST_MSG_LEN)
{
/* Send the response message directly */
cmdBytes[0] = (uint8_t)Smsgs_cmdIds_GenericStatusRsp;
cmdBytes[1] = Ssf_genericCMD();
Sensor_sendMsg(Smsgs_cmdIds_GenericStatusRsp,
&pDataInd->srcAddr, true,
SMSGS_GENERIC_STATUS_RESPONSE_MSG_LEN,
cmdBytes);
}
default:
/* Should not receive other messages */
break;
}
}
}
This works fine for a unicast message, but I can't get it working for the broadcast. What am I missing here?
