I am going to make firmware that can both transmit and receive RF signal.
This program transmit packet received from uart to other module and send packet received from another to uart.
I changed rfWsnNode_CC1310_LAUNCHXL_tirtos_ccs example as follows.
I flashed example into two modules.
At first time, one module sends packets to another, and another receive packet successfully.
But, in the contrast, when another module sends uart packets, first module receive packet only once or no receive, and then, program doesn't work.
Module doesn't receive any packets after transmit packet.
How to change exactly from receive state to transmit state and vice versa?
I used EasyLink_abort() function for that. But It seemed to be very bad.
static void nodeRadioTaskFunction(UArg arg0, UArg arg1) { /* Initialize EasyLink */ if(EasyLink_init(RADIO_EASYLINK_MODULATION) != EasyLink_Status_Success) { System_abort("EasyLink_init failed"); } /* If you wich to use a frequency other than the default use * the below API * EasyLink_setFrequency(868000000); */ /* Enter main task loop */ if (EasyLink_receiveAsync(rxDoneCallback, 0) != EasyLink_Status_Success) { System_abort("EasyLink_receiveAsync failed"); } while (1) { /* Wait for an event */ uint32_t events = Event_pend(radioOperationEventHandle, 0, RADIO_EVENT_ALL, BIOS_WAIT_FOREVER); EasyLink_abort(); // if ( EasyLink_abort() != EasyLink_Status_Success ) { // UART_write(uart, "EasyLink_abort failed\n", sizeof("EasyLink_abort failed\n")); // System_abort("EasyLink_abort failed"); // } if ( events & RADIO_EVENT_SEND_UART_DATA ) { // EasyLink_setCtrl(Ctrl, ui32Value); sendUartPacket(uartData, uartLength, NODERADIO_MAX_RETRIES, NORERADIO_ACK_TIMEOUT_TIME_MS); } if ( events & RADIO_EVENT_UART_PACKET_RECEIVED ) { if (EasyLink_receiveAsync(rxDoneCallback, 0) != EasyLink_Status_Success) { System_abort("EasyLink_receiveAsync failed"); } } } }
static void sendUartPacket(uint8_t *data, uint8_t len, uint8_t maxNumberOfRetries, uint32_t ackTimeoutMs) { currentRadioOperation.easyLinkTxPacket.dstAddr[0] = RADIO_CONCENTRATOR_ADDRESS; currentRadioOperation.easyLinkTxPacket.payload[0] = nodeAddress; currentRadioOperation.easyLinkTxPacket.payload[1] = RADIO_PACKET_TYPE_UART_PACKET; memcpy(currentRadioOperation.easyLinkTxPacket.payload+2, data, len); currentRadioOperation.easyLinkTxPacket.len = len + 2; /* Setup retries */ currentRadioOperation.maxNumberOfRetries = 0; currentRadioOperation.ackTimeoutMs = 0; currentRadioOperation.retriesDone = 0; // EasyLink_setCtrl(EasyLink_Ctrl_AsyncRx_TimeOut, EasyLink_ms_To_RadioTime(ackTimeoutMs)); /* Send packet */ if (EasyLink_transmit(¤tRadioOperation.easyLinkTxPacket) != EasyLink_Status_Success) { System_abort("EasyLink_transmit failed"); } if (EasyLink_receiveAsync(rxDoneCallback, 0) != EasyLink_Status_Success) { System_abort("EasyLink_receiveAsync failed"); } }
static void rxDoneCallback(EasyLink_RxPacket * rxPacket, EasyLink_Status status) { struct PacketHeader* packetHeader; /* If this callback is called because of a packet received */ if (status == EasyLink_Status_Success) { /* Check the payload header */ packetHeader = (struct PacketHeader*)rxPacket->payload; UART_write(uart, "Packet received\n", sizeof("Packet received\n")); /* Check if this is an ACK packet */ if ( packetHeader->packetType == RADIO_PACKET_TYPE_UART_PACKET ) { UART_write(uart, rxPacket->payload + 2, rxPacket->len - 2); Event_post(radioOperationEventHandle, RADIO_EVENT_UART_PACKET_RECEIVED); } } }