
Configurations and Setting
197
SWRU455A – February 2017 – Revised March 2017
Copyright © 2017, Texas Instruments Incorporated
Transceiver
/* 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));
memcpy (buff +
sizeof
(FrameBaseData), data,
sizeof
(buff ) -
sizeof
(FrameBaseData));
/* Example data */
sock = sl_Socket(SL_AF_RF, SL_SOCK_RAW, 1);
NumOfBytes = sl_Send(sock,buff,
sizeof
(buff),SL_WLAN_RAW_RF_TX_PARAMS(CHANNEL_1,
SL_WLAN_RATE_1M,0,SL_WLAN_LONG_PREAMBLE));
}
13.3.4 Receive Data
Receiving raw socket data is done by calling sl_Recv after successfully opening the transceiver socket.
The API return value is the number of bytes received, or a negative value in case of an error. Each
receive packet has an 8-byte proprietary header which includes the following parameters:
•
Rate – packet received rate
•
Channel – packet received channel
•
RSSI – computed RSSI value in dBm of current frame
•
Time Stamp – frame timestamp in µs
If the packet is longer than the receive buffer, the remainder of the packet is discarded. The maximum
packet size which can be received is 1544 (1536 bytes of data and 8 bytes of proprietary header).
Example:
_i16 NumOfByets;
signed char
buf [1000];
_i16 Soc;
_i16 channel = 6;
_i16 len = 1000;
Soc = sl_Socket(SL_AF_RF ,SL_SOCK_RAW, channel);
NumOfByets = sl_Recv(Soc, buf,500,0);
13.4 Internal Packet Generator
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). Receiving packets operation is available 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