Tool/software: Code Composer Studio
Hello, I've modified the sample code for rfWakeOnRadioRx in sdk 2 30 00 20, to accommodate a 8 bytes address filter.
rxTaskFunction:
static void rxTaskFunction(UArg arg0, UArg arg1) { RF_Params rfParams; RF_Params_init(&rfParams); /* Route out LNA active pin to LED1 */ PINCC26XX_setMux(ledPinHandle, Board_PIN_LED0, PINCC26XX_MUX_RFC_GPO0); /* Create queue and data entries */ if (RFQueue_defineQueue(&dataQueue, rxDataEntryBuffer, sizeof(rxDataEntryBuffer), NUM_DATA_ENTRIES, MAX_LENGTH + NUM_APPENDED_BYTES)) { /* Failed to allocate space for all data entries */ while(1); } /* Copy all RX options from the SmartRF Studio exported RX command to the RX Sniff command */ initializeSniffCmdFromRxCmd(&RF_cmdPropRxSniff, &RF_cmdPropRxAdv_preDef); /* Configure RX part of RX_SNIFF command */ RF_cmdPropRxSniff.pQueue = &dataQueue; RF_cmdPropRxSniff.pOutput = (uint8_t*)&rxStatistics; RF_cmdPropRxSniff.maxPktLen = MAX_LENGTH; /* Discard ignored packets and CRC errors from Rx queue */ RF_cmdPropRxSniff.rxConf.bAutoFlushIgnored = 1; RF_cmdPropRxSniff.rxConf.bAutoFlushCrcErr = 1; /* Calculate datarate from prescaler and rate word */ uint32_t datarate = calculateSymbolRate(RF_cmdPropRadioDivSetup.symbolRate.preScale, RF_cmdPropRadioDivSetup.symbolRate.rateWord); /* Configure Sniff-mode part of the RX_SNIFF command */ configureSniffCmd(&RF_cmdPropRxSniff, WOR_MODE, datarate, WOR_WAKEUPS_PER_SECOND); /* Request access to the radio */ rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams); /* Set frequency */ RF_runCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, &callback, 0); /* Save the current radio time */ RF_cmdPropRxSniff.startTime = RF_getCurrentTime(); /* Enter main loop */ while(1) { /* Set next wakeup time in the future */ RF_cmdPropRxSniff.startTime += WOR_WAKE_UP_INTERVAL_RAT_TICKS(WOR_WAKEUPS_PER_SECOND); /* Schedule RX */ RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRxSniff, RF_PriorityNormal, &callback, RF_EventRxEntryDone); /* Log RX_SNIFF status */ switch(RF_cmdPropRxSniff.status) { case PROP_DONE_IDLE: /* Idle based on RSSI */ worStatistics.doneIdle++; break; case PROP_DONE_IDLETIMEOUT: /* Idle based on PQT */ worStatistics.doneIdleTimeout++; break; case PROP_DONE_RXTIMEOUT: /* Got valid preamble on the air, but did not find sync word */ worStatistics.doneRxTimeout++; break; case PROP_DONE_OK: /* Received packet */ worStatistics.doneOk++; break; default: /* Unhandled status */ break; }; } }
I set the relevant address values as follows:
static uint8_t addTable[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}; ... rxSniffCmd->pAddr = addTable; rxSniffCmd->addrConf.addrType = 0; rxSniffCmd->addrConf.addrSize = 8; rxSniffCmd->addrConf.numAddr = 1; rxSniffCmd->pktConf.filterOp = 1;
Callback function:
void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e) { /* If we've received a new packet and it's available to read out */ if (e & RF_EventRxEntryDone) { do { /* Toggle LED on RX */ //PIN_setOutputValue(ledPinHandle, Board_PIN_LED1, !PIN_getOutputValue(Board_PIN_LED1)); /* Get current unhandled data entry */ currentDataEntry = RFQueue_getDataEntry(); /* 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); packetDataPointer = (uint8_t*)(¤tDataEntry->data); /* This code block is added to avoid a compiler warning. * Normally, an application will reference these variables for * useful data. */ dummy = packetLength + packetDataPointer[0]; int i; for(i = 0; i < packetLength; i++){ printf("%02X ", packetDataPointer[i]); } printf("\n"); } while(RFQueue_nextEntry() == DATA_ENTRY_FINISHED); } }
In the callback function, the packet received get printed out if the addresses match.
However, when i probe the device with a multimeter, this is the result:
The first ~7.5mA spike was when a packet with matching address received. The second ~7.5mA spike was a packet with another address.
Is this a normal behavior?
I am expecting the device to just ignore whatever packets not meant for them.