Hi!
I am implementing the transmission from a CC3200 board configured as STA, to another C3200 configured as AP, using the stack bypass mode.
Initially the AP waits for the connection from a STA. The output until this point is:
************************************************
CC3200 WLAN AP Rx Stack bypass mode Application
************************************************
Host Driver Version: 1.0.0.1
Build Version 2.0.7.0.31.0.0.4.2.1.5.3.3
Device is configured in default state
Device started as STATION
WLAN name: mysimplelink-1130F7
Device is configured in AP mode
Connect a client to Device
At this point, I run the program in the STA, which is configured properly and successfully establishes a connection to the AP. The STA acquires an IP. The output of the STA is:
********************************************************
CC3200 WLAN STATION and Tx traffic generator Application
********************************************************
Transmission Parameters:
Channel [1:13]: 6.
Number of packets to transmitt (1,65535): 60000.
Transmit power [0:15]: 15.
Rate (1,2,3,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21): 1.
Host Driver Version: 0.0.5.1
Build Version 2.0.7.0.31.0.0.4.2.1.5.3.3
Device is configured in default state
Device started as STATION
[WLAN EVENT] STA Connected to the AP: mysimplelink-1130F7 ,BSSID: 78:a5:4:11:30:f7
[NETAPP EVENT] IP Acquired: IP=192.168.1.2 , Gateway=192.168.1.1
Connection established w/ AP and IP is aquired
Stack Bypass Socket created!. Socket Descriptor: 160
Socket_Handle = 0.
Transmitting data...
Data sent: À. Data sent: À. Data sent: À. Data sent: À. Data sent: À. Data sent: À.
As you can see after the IP is acquired, I create a bypass socket, and the socket descriptor is valid. This is done with this code:
INT32 CreateStackBypassSocket()
{
INT32 socket_descriptor = -1;
socket_descriptor = sl_Socket(SL_AF_INET, SL_SOCK_RAW, 0);
unsigned long header = 1; //1; When it is enabled, the packet must contain an IP header file:///C:/ti/CC3200SDK/cc3200-sdk/docs/simplelink_api/html/group__socket.html#ga173062c9a3a1ca728e651e98aedca7fb
sl_SetSockOpt (socket_descriptor, SL_IPPROTO_IP, SL_IP_HDRINCL, &header, sizeof(header));
return socket_descriptor;
}
// Open Stack-Bypass-Socket
//
socket_descriptor = CreateStackBypassSocket();
UART_PRINT("Stack Bypass Socket created!. Socket Descriptor: %d \n\r",socket_descriptor);
Note that header is set to 1! Is this correct?
Afterwards, I follow the code in
http://processors.wiki.ti.com/index.php/CC31xx_%26_CC32xx_Advanced_Networking#Use-cases
to transmit from the STA. The code is:
SlSockAddrIn_t Addr;
INT16 AddrSize = 0;
Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons((UINT16)0); /* No concept of port-number in raw-sockets */
// Addr.sin_addr.s_addr = sl_Htonl((UINT32)<destination_ip_address>); // No IP needed in Stack bypass sockets?
Addr.sin_addr.s_addr = sl_Htonl((UINT32)"0xC0A80102"); // 192.168.1.2 //No IP needed in Stack bypass sockets?
AddrSize = sizeof(SlSockAddrIn_t);
Socket_Handle = sl_Connect(socket_descriptor, ( SlSockAddr_t *)&Addr, AddrSize);
//Note that trying to be as close as possible to the example I use sl_Connect, although the STA is already connected to the AP, I understand this maps the IP Address to the socket_descriptor. Is this correct? I am using the IP address in hex. as shown above. From this operation, I am obtaining the Socket_Handle and then I use it to transmit. Is this correct? or is the socket_descriptor the same as the socket_handle? I already tried this, deleting the sl_Connect function line, but it did not work.
Report("Socket_Handle = %d.\n\r",Socket_Handle);
lRetVal = Tx_continuous(User.channel,User.rate,User.packets,User.Txpower,0,Socket_Handle);
// with:
static int Tx_continuous(int iChannel,int rate,int iNumberOfPackets,int iTxPowerLevel,long dIntervalMiliSec,int Socket_Handle)
{
long lRetVal = -1;
long ulIndex;
UART_PRINT("Transmitting data...\r\n");
for(ulIndex = 0 ; ulIndex < iNumberOfPackets ; ulIndex++)
//while (1)
{
lRetVal = sl_Send(Socket_Handle,RawData,sizeof(RawData),SL_RAW_RF_TX_PARAMS(iChannel, rate, iTxPowerLevel, PREAMBLE));
//lRetVal = sl_Send(socket_descriptor,RawData,sizeof(RawData),0);
Report("Data sent: %s. ",RawData);
if(lRetVal < 0)
{
UART_PRINT("Transmition Failed!\r\n");
sl_Close(Socket_Handle);
ASSERT_ON_ERROR(__LINE__, lRetVal);
}
//Sleep(dIntervalMiliSec);
MAP_UtilsDelay(4000000);
}
lRetVal = sl_Close(Socket_Handle);
ASSERT_ON_ERROR(__LINE__, lRetVal);
UART_PRINT("Transmission complete.\r\n");
return SUCCESS;
}
The whole output from the STA terminal is:
********************************************************
CC3200 WLAN STATION and Tx traffic generator Application
********************************************************
Transmission Parameters:
Channel [1:13]: 6. //The channel was checked with a "sniffer", and it is working on channel 6
Number of packets to transmitt (1,65535): 60000.
Transmit power [0:15]: 15.
Rate (1,2,3,4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21): 1.
Host Driver Version: 0.0.5.1
Build Version 2.0.7.0.31.0.0.4.2.1.5.3.3
Device is configured in default state
Device started as STATION
[WLAN EVENT] STA Connected to the AP: mysimplelink-1130F7 ,BSSID: 78:a5:4:11:30:f7
[NETAPP EVENT] IP Acquired: IP=192.168.1.2 , Gateway=192.168.1.1
Connection established w/ AP and IP is aquired
Stack Bypass Socket created!. Socket Descriptor: 160
Socket_Handle = 0.
Transmitting data...
Data sent: À. Data sent: À. Data sent: À. Data sent: À. Data sent: À. Data sent: À.
...
At the STA we have:
#define PREAMBLE 1//1 /* Preamble value 0- short, 1- long */ //Is this correct, I am not setting preamble at the AP
char RawData[] = {0x01,0x06, 0x01};
At the AP, I open a socket and then try to follow the code in the webpage above. The code is:
SlSockAddrIn_t Addr;
UINT8 buffer[3]={'\0'};
INT32 recievedBytes = 0;
INT16 AddrSize = 0;
long lRetValRx = -1;
char acBuffer[5];
int pkts_to_receive = 10;
int Socket_Handle;
//
// Open Stack-Bypass-Socket
//
socket_descriptor = CreateStackBypassSocket();
UART_PRINT("Stack Bypass Socket created!. Socket Descriptor: %d \n\r",socket_descriptor);
if(socket_descriptor < 0)
{
UART_PRINT("Failed to create socket\r\n");
//ASSERT_ON_ERROR(__LINE__, socket_descriptor);
UART_PRINT("Error.\r\n");
}
Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons((UINT16)0);
Addr.sin_addr.s_addr = sl_Htonl((UINT32)"0xC0A80101"); //192.168.1.1 //Is this IP correct?
AddrSize = sizeof(SlSockAddrIn_t);
Socket_Handle = sl_Connect(socket_descriptor, ( SlSockAddr_t *)&Addr, AddrSize); //Is this correct?, the STA is already connected to the AP.
while(pkts_to_receive--)
{
memset(&buffer[0], 0, sizeof(buffer));
// recievedBytes = sl_Recv(Socket_Handle, buffer, 3, 0);
recievedBytes = sl_Recv(Socket_Handle, acBuffer, 3, 0);
//recievedBytes = sl_Recv (<socket_handle>, <raw_data_packet>, <packet_szie>, 0); // How do I get <raw_data_packet>?
Report("Received data: %s",recievedBytes);
}
sl_Close(Socket_Handle);
The whole output at the AP is:
************************************************
CC3200 WLAN AP Rx Stack bypass mode Application
************************************************
Host Driver Version: 1.0.0.1
Build Version 2.0.7.0.31.0.0.4.2.1.5.3.3
Device is configured in default state
Device started as STATION
WLAN name: mysimplelink-1130F7
Device is configured in AP mode
Connect a client to Device
[NETAPP EVENT] IP Leased to Client: IP=192.168.1.2 ,
Client is connected to Device
Stack Bypass Socket created!. Socket Descriptor: 160
Socket_Handle = 0.
The receiver is stuck at:
lRetValRx = sl_Recv(socket_descriptor,acBuffer,3,0); //sl_Recv(socket_descriptor,acBuffer,3,0); //sl_Recv(iSoc,acBuffer,1470,0);
What changes do I need to do, to properly transmit from the STA to the AP in stack bypass mode?
Could you please include a working example?
Thanks!