Configurations and Setting
196
SWRU455A – February 2017 – Revised March 2017
Copyright © 2017, Texas Instruments Incorporated
Transceiver
•
Channel – Used for configuring the operational channel from which the device should start receiving or
transmitting traffic. If the channel is set to 0, the channel is set as the last transceiver channel used. If
this is the first time the transceiver socket is open, a channel should be applied by the sl_SetSockOpt
operation, or by the flags parameter in the sl_Send operation.
This command must be called only when the device is in STA role and disconnected. The command
returns the socket ID, which is used from now on to reference the socket. If there is a problem with the
socket, the command returns a negative error code.
Example:
_i16 sd;
_i16 channel = 6;
sd = sl_Socket(SL_AF_RF ,SL_SOCK_RAW/SL_SOCK_DGRAM, channel);
13.3.2 Close Transceiver Socket
The sl_Close API is used to close the transceiver mode.
Example:
_i16 Status, sd;
Status =
sl_Close(sd);
if
( Status )
{
/* error */
}
13.3.3 Send Data
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 negative value in case of an error.
The SimpleLink Wi-Fi device allows the option to set the following parameters as part of the send
operation as part of the flags parameter:
•
Channel
•
Rate
•
Tx Power
•
802.11b preamble
The flags parameters given as part of the sl_Send API are valid only for this specific send operation, and
are not kept for any further operation. If the flag 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.
NOTE:
These parameters have no default values, and therefore must be set through the sl_Send
API or sl_SetSockOpt, as specified below.
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;