Hi,
I´ve modified the rfUARTBridge example to have a sensor node and a collector (PAN coordinator).
So, the Collector is always waiting for packets sent by sensor nodes.
The structure is almost the same for both sides, except the order of Transmission/Reception.
The Sensor Node sends a packet, the Collector receives it, analyses some bytes, and after 1 second (a long time for tests) and sends a packet back to the sensor.
The collector does not stop but the sensor does not set the RF_EventRxEntryDone bit when receiving the packet from the collector.
As the structures are almost the same I´m not finding where I´m making mistakes.
The order I´m doing things at the sensor is:
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
rfPostHandle = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &ReceivedOnRFcallback, RF_EventRxEntryDone);
while(1) {
retrieves = 3;
while(retrieves) {
recRF = 0;
/*Cancel the ongoing command = RX command antes do while ou depois de transmitido */
rfStatus = RF_cancelCmd(rfHandle, rfPostHandle, 1);
/* Send packet */
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityHigh, NULL, 0);
/* Resume RF RX */
rfPostHandle = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx,
RF_PriorityNormal,
&ReceivedOnRFcallback,
RF_EventRxEntryDone);
wait for a semaphore....
if semaphore timeout, retrieves--
else {
retrieves = 0;
go to sleep....
}
void ReceivedOnRFcallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
If (e & RF_EventRxEntryDone)
{
/* Get current unhandled data entry */
currentDataEntry = RFQueue_getDataEntry(); //loads data from entry
/* Handle the packet data, located at ¤tDataEntry->data:
* - Length is the first byte with the current configuration
* - Data starts from the second byte */
packetLength = *(uint8_t*)(¤tDataEntry->data); //gets the packet length (send over with packet)
packetDataPointer = (uint8_t*)(¤tDataEntry->data + 1); //data starts from 2nd byte
recRF = 1;
if(*(uint8_t*)(¤tDataEntry->data + 1) == (uint8_t) ((NODE_ADDRESS & 0xFF00) >> 8))
{
if(*(uint8_t*)(¤tDataEntry->data + 2) == (uint8_t) (NODE_ADDRESS & 0x00FF))
{
/* Copy the payload + the status byte to the packet variable */
memcpy(packet, packetDataPointer, (packetLength + 1));
//set Semaphore
SemaphoreP_post(semPcktIn);
}
}
/* Move read entry pointer to next entry */
RFQueue_nextEntry();
}
}
The "e" value is always 2 and never RF_EventRxEntryDone
Could someone help me?
Thank you
André