Tool/software:
Hello,
I am trying to transmit and receive more than 255 bytes with LP-EM-CC1354P10 using CMD_PROP_TX_ADV and CMD_PROP_RX_ADV in Advanced Packet Mode.
I am using wakeonradioTX,wakeonradioTX example.
I referred to this TI E2E thread about larger packets,but nothing receive .
https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/993297/cc1312r-transmission-of-data-which-is-1000-byte-length-stops-after-4-minute/3669128?tisearch=e2e-sitesearch&keymatch=big%252525252525252520payloads#3669128
I attach my transmitter and receiver code snippets.
Can you please check and tell me what I am doing wrong?
Transmitter:
/***** Includes *****/
#include <stdlib.h>
/* POSIX Header files */
#include <pthread.h>
#include <semaphore.h>
/* TI-RTOS Header files */
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/GPIO.h>
#include <ti/display/Display.h>
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(driverlib/cpu.h)
/* Board Header files */
#include "ti_drivers_config.h"
/* RF settings */
#include <ti_radio_config.h>
/***** Defines *****/
/* Wake-on-Radio configuration */
#define WOR_WAKEUPS_PER_SECOND 2
/* TX number of random payload bytes */
#define PAYLOAD_LENGTH 300
/* WOR Example configuration defines */
#define WOR_PREAMBLE_TIME_RAT_TICKS(x) \
((uint32_t)(4000000*(1.0f/(x))))
/* TX task stack size and priority */
#define TX_TASK_STACK_SIZE 1024
#define TX_TASK_PRIORITY 2
/* TX packet payload (length +1 to fit length byte) and sequence number */
static uint8_t packet[PAYLOAD_LENGTH +2];
/* RF driver objects and handles */
static RF_Object rfObject;
static RF_Handle rfHandle;
/* TX Semaphore */
static sem_t txSemaphore;
/***** Function definitions *****/
/* GPIO interrupt Callback function for CONFIG_GPIO_BTN1. */
void buttonCallbackFunction(uint_least8_t index) {
CPUdelay((uint32_t)((48000000/3)*0.050f));
if (!GPIO_read(index)) {
sem_post(&txSemaphore);
}
}
void *mainThread(void *arg0)
{
int retc;
Display_init();
GPIO_setConfig(CONFIG_GPIO_GLED, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
GPIO_setConfig(CONFIG_GPIO_BTN1, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING);
GPIO_setCallback(CONFIG_GPIO_BTN1, buttonCallbackFunction);
GPIO_enableInt(CONFIG_GPIO_BTN1);
retc = sem_init(&txSemaphore, 0, 0);
if (retc != 0) {
while (1);
}
RF_Params rfParams;
RF_Params_init(&rfParams);
RF_cmdPropTxAdv.pktLen = PAYLOAD_LENGTH + 2; /* +2 for length byte */
RF_cmdPropTxAdv.pPkt = packet;
RF_cmdPropTxAdv.preTime = WOR_PREAMBLE_TIME_RAT_TICKS(WOR_WAKEUPS_PER_SECOND);
RF_cmdPropTxAdv.startTrigger.triggerType = TRIG_NOW;
RF_cmdPropTxAdv.startTrigger.pastTrig = 0x1;
RF_cmdPropTxAdv.condition.rule = 1;
RF_cmdPropTxAdv.pktConf.bUseCrc = 1;
RF_cmdPropTxAdv.pktConf.bCrcIncSw = 0;
RF_cmdPropTxAdv.pktConf.bCrcIncHdr = 0;
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
while(1)
{
int retc;
retc = sem_wait(&txSemaphore);
if (retc == -1) {
while (1);
}
packet[0] = (uint8_t)(PAYLOAD_LENGTH);
packet[1] = (uint8_t)(PAYLOAD_LENGTH >> 8);
uint16_t i;
for (i = 2; i < PAYLOAD_LENGTH + 2; i++)
{
packet[i] = i;
}
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv, RF_PriorityNormal, NULL, 0);
GPIO_toggle(CONFIG_GPIO_GLED);
}
}
Receiver:
/***** Includes *****/
/* Standard C Libraries */
#include <stdlib.h>
/* TI Drivers */
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/GPIO.h>
/* Driverlib Header files */
#include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)
/* Board Header files */
#include "ti_drivers_config.h"
/* Application Header files */
#include "RFQueue.h"
#include <ti_radio_config.h>
/***** Defines *****/
#define DATA_ENTRY_HEADER_SIZE 8 /* Constant header size of a Generic Data Entry */
#define MAX_LENGTH 300 /* Max length byte the radio will accept */
/* Must be less than 256 if SIZE_OF_LENGHT_FIELD = 1 */
#define NUM_DATA_ENTRIES 2 /* NOTE: Only two data entries supported at the moment */
#define SIZE_OF_LENGHT_FIELD 2
#define NUM_APPENDED_BYTES 1 + SIZE_OF_LENGHT_FIELD /* The Data Entries data field will contain:
* 1 or 2 header byte(s) (containing the length)
* A maximum of MAX_LENGTH payload bytes
* 1 status byte (RF_cmdPropRxAdv.rxConf.bAppendStatus = 0x1) */
/***** Prototypes *****/
static void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
/***** Variable declarations *****/
static RF_Object rfObject;
static RF_Handle rfHandle;
#elif defined(__GNUC__)
static uint8_t
rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
MAX_LENGTH,
NUM_APPENDED_BYTES)]
__attribute__((aligned(4)));
/* Receive dataQueue for RF Core to fill in data */
static dataQueue_t dataQueue;
static rfc_dataEntryGeneral_t* currentDataEntry;
static uint16_t packetLength;
static uint8_t* packetDataPointer;
static rfc_propRxOutput_t rxStatistics;
static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES];
/***** Function definitions *****/
void *mainThread(void *arg0)
{
RF_Params rfParams;
RF_Params_init(&rfParams);
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);
}
/* Modify CMD_PROP_RX command for application needs */
/* Set the Data Entity queue for received data */
RF_cmdPropRxAdv.pQueue = &dataQueue;
/* Discard ignored packets from Rx queue */
RF_cmdPropRxAdv.rxConf.bAutoFlushIgnored = 1;
/* Discard packets with CRC error from Rx queue */
RF_cmdPropRxAdv.rxConf.bAutoFlushCrcErr = 1;
/* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
RF_cmdPropRxAdv.maxPktLen = MAX_LENGTH;
RF_cmdPropRxAdv.pktConf.bRepeatOk = 1;
RF_cmdPropRxAdv.pktConf.bRepeatNok = 1;
RF_cmdPropRxAdv.pOutput = (uint8_t*)&rxStatistics;
RF_cmdPropRxAdv.condition.rule = 1;
RF_cmdPropRxAdv.pktConf.bUseCrc = 0x1;
RF_cmdPropRxAdv.rxConf.bIncludeHdr = 0x1;
RF_cmdPropRxAdv.rxConf.bAppendStatus = 0x1;
RF_cmdPropRxAdv.endTrigger.triggerType = 0x1;
RF_cmdPropRxAdv.pktConf.bCrcIncHdr = 0x1;
RF_cmdPropRxAdv.hdrConf.numHdrBits = 16;
RF_cmdPropRxAdv.hdrConf.numLenBits = 16;
/* Request access to the radio */
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
/* Set the frequency */
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
/* Enter RX mode and stay forever in RX */
RF_EventMask terminationReason = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRxAdv, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
while(1);
}
void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
if (e & RF_EventRxEntryDone)
{
/* Toggle pin to indicate RX */
GPIO_toggle(CONFIG_GPIO_RLED);
/* Get current unhandled data entry */
currentDataEntry = RFQueue_getDataEntry();
packetLength = ((uint16_t)((*(uint8_t*)(¤tDataEntry->data+1)) << 8) |
(uint16_t)(*(uint8_t*)(¤tDataEntry->data)));
packetDataPointer = (uint8_t*)(¤tDataEntry->data + SIZE_OF_LENGHT_FIELD);
/* Copy the payload and the status bytes to the packet variable */
memcpy(packet, packetDataPointer, (packetLength + NUM_APPENDED_BYTES - SIZE_OF_LENGHT_FIELD));
}
RFQueue_nextEntry();
}