SWRU455M February 2017 – October 2020 CC3120 , CC3120MOD , CC3130 , CC3135 , CC3135MOD , CC3220MOD , CC3220MODA , CC3220R , CC3220S , CC3220SF , CC3230S , CC3230SF , CC3235MODAS , CC3235MODASF , CC3235MODS , CC3235MODSF , CC3235S , CC3235SF
The SimpleLink Wi-Fi device can internally generate packets in transceiver mode. The device is capable of repeating a user-predefined pattern of data.
Before calling sl_Send, you must set the number of frames using the sl_SetSockOpt API to the number of frames desired to be transmitted (0 means infinite number of frames).
A single call to the sl_Send API triggers the frames transmission. The SimpleLink Wi-Fi device keeps transmitting until it has sent all the requested frames, or until the socket is closed or another socket property changes (through sl_SetSockOpt). It is still possible to receive packets during the send operation. Setting the number of frames to transmit to 1 returns the socket to the regular transceiver socket state.
Example of transmitting multiple data packets:
void sendPacket(char * data)
{
/* Base frame: */#define FRAME_TYPE 0x88
#define FRAME_CONTROL 0x00
#define DURATION 0xc0,0x00
#define RECEIVE_ADDR 0x08, 0x00, 0x28, 0x5A, 0x72, 0x3C
#define TRANSMITTER_ADDR 0x08, 0x00, 0x28, 0x5a, 0x78, 0x1e
#define BSSID_ADDR 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
#define FRAME_NUMBER 0x00, 0x00
#define QOS_CTRL 0x00, 0x00
_i32 NumOfBytes =0;
_i32 Soc=0;
_i16 Status =0;
_u32 numFrames=20;
/* Mac header */char buff[1536];
char FrameBaseData[] = {
FRAME_TYPE, /* version, type sub type */
FRAME_CONTROL, /* Frame control flag */
DURATION, /* duration */
RECEIVE_ADDR, /* Receiver ADDr */
TRANSMITTER_ADDR, /* Transmitter Address */
BSSID_ADDR, /* destination */
FRAME_NUMBER, /* Frame number */
QOS_CTRL}; /* Transmitter */
memcpy(buff,FrameBaseData,sizeof(FrameBaseData));
/* Example data */
memcpy (buff + sizeof(FrameBaseData), data, sizeof(buff ) - sizeof(FrameBaseData));
Soc = sl_Socket(SL_AF_RF, SL_SOCK_RAW, 1);
/* Set 20 frames to transmit */
Status = sl_SetSockOpt(Soc, SL_SOL_PHY_OPT,SL_SO_PHY_NUM_FRAMES_TO_TX, &numFrames,sizeof(numFrames));
if (Status)
{
/* Error */
}
/* Send 20 packet with the same buffer */
NumOfBytes = sl_Send(Soc,buff,sizeof(buff),SL_WLAN_RAW_RF_TX_PARAMS(CHANNEL_1, SL_WLAN_RATE_1M,1, SL_WLAN_LONG_PREAMBLE));
}