Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

The Server does not receive any data

$
0
0

Hi,

I'm a newbie with the CC300

I have ported the spi driver to my platform (STM32F103 - ST Cortex M3)

I managed to connect to the AP and the module responds to a PING

I create a Server, and I startwaiting forincoming connections.

When I create anew connectionto the ipand portserver, the accept function return, but i don´t receive anything


Is there something wrong with my code?


/* Variables */
unsigned char pucIP_Addr[4];
unsigned char pucIP_DefaultGWAddr[4];
unsigned char pucSubnetMask[4];
unsigned char pucDNS[4];
long network_status;
int ulSocket;
uint8_t data[10]="1234567890";
int ret;
unsigned long timeout = 100000;
/* WLAN On API Implementation */
wlan_init(CC3000_UsynchCallback, sendWLFWPatch, sendDriverPatch, sendBootLoaderPatch, TSMART_WIFI_ReadWlanInterruptPin, TSMART_WIFI_WlanInterruptEnable, TSMART_WIFI_WlanInterruptDisable, TSMART_WIFI_WriteWlanPowerEnable);
/* Trigger a WLAN device */
wlan_start(0);
/* Mask out all non-required events from CC3000 */
wlan_set_event_mask(HCI_EVNT_WLAN_KEEPALIVE|HCI_EVNT_WLAN_UNSOL_INIT|HCI_EVNT_WLAN_ASYNC_PING_REPORT);
/* Handle any un-solicited event if required - the function shall be triggered few times in a second */
hci_unsolicited_event_handler();
wlan_connect(WLAN_SEC_WPA2, SSID, strlen(SSID), 0, KEY, strlen(KEY));
/* Handle IP configuration command */
/* Network mask is assumed to be 255.255.255.0 */
pucSubnetMask[0] = MASK0;
pucSubnetMask[1] = MASK1;
pucSubnetMask[2] = MASK2;
pucSubnetMask[3] = MASK3;
pucIP_Addr[0] = IP0;
pucIP_Addr[1] = IP1;
pucIP_Addr[2] = IP2;
pucIP_Addr[3] = IP3;
pucIP_DefaultGWAddr[0] = IP_GW0;
pucIP_DefaultGWAddr[1] = IP_GW1;
pucIP_DefaultGWAddr[2] = IP_GW2;
pucIP_DefaultGWAddr[3] = IP_GW3;
/* Currently no implementation of DHCP in hte demo */
pucDNS[0] = DNS0;
pucDNS[1] = DNS1;
pucDNS[2] = DNS2;
pucDNS[3] = DNS3;
netapp_dhcp((unsigned long *)pucIP_Addr, (unsigned long *)pucSubnetMask, (unsigned long *)pucIP_DefaultGWAddr, (unsigned long *)pucDNS);
do{
network_status = wlan_ioctl_statusget();
}while(network_status != 3);
/* wait for DHCP process to finish (if you are using a static IP address please delete the wait for DHCP event - ulCC3000DHCP */
while ((ulCC3000DHCP == 0) || (ulCC3000Connected == 0)){
hci_unsolicited_event_handler();
}
/* Get socket */
ulSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(ulSocket != 0){
for(;;);
}
setsockopt( ulSocket, SOCK_ON, SOCKOPT_NONBLOCK , &timeout, sizeof( timeout ) );
/* Bind a socket */
sockaddr saddrClient,saddrServer;
saddrServer.sa_family =  AF_INET;
saddrServer.sa_data[0] = 0x04;
saddrServer.sa_data[1] = 0xD4;
saddrServer.sa_data[2] = 0x00;
saddrServer.sa_data[3] = 0x00;
saddrServer.sa_data[4] = 0x00;
saddrServer.sa_data[5] = 0x00;
ret = bind(ulSocket, &saddrServer, sizeof(saddrServer));
if (ret < 0) {
for(;;);
}
/* Listen */
ret = listen(ulSocket, 1);
if ( ret != 0 ){
for(;;);
}
socklen_t tSoclength ;
tSoclength = sizeof(saddrClient);
int clientfd;
hci_unsolicited_event_handler();
clientfd = accept(ulSocket, &saddrClient, &tSoclength);
if (clientfd > 0){
memset(data, 0 , sizeof(data));
/* Receive bytes */
ret = recv(clientfd, data, 2, 0);
/* close socket */
closesocket(clientfd);
}



Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>