SWRU455M February 2017 – October 2020 CC3120 , CC3120MOD , CC3130 , CC3135 , CC3135MOD , CC3220MOD , CC3220MODA , CC3220R , CC3220S , CC3220SF , CC3230S , CC3230SF , CC3235MODAS , CC3235MODASF , CC3235MODS , CC3235MODSF , CC3235S , CC3235SF
Transmitting raw socket data is done by calling sl_Send after successfully opening the transceiver socket. The API return value is the number of bytes sent, or a negative value in the case of an error.
The SimpleLink Wi-Fi device provides the option to set the following parameters as part of the send operation as part of the flags parameter:
The flags parameter given as part of the sl_Send API are valid only for the specific send operation, and are not kept for any further operation. If the flags parameter is set to 0, the default values remain. These parameters can also be set through the sl_SetSockOpt API, as specified in the example that follows.
These parameters have no default values, and therefore must be set through the sl_Send API or sl_SetSockOpt, as specified below.
Tx Power can only be set on 2.4-GHz channels.
Example: transmit a frame on channel 1, with 1-MBps data rate, maximum TX power and long preamble:
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 sock=0;
/* 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));
}