cc3100_Socket_Wifi_Server with Ethernet Interface not working

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of cc3100_Test_Demo by David Fletcher

Committer:
artpes
Date:
Fri May 19 14:45:14 2017 +0000
Revision:
8:f4eb30a34ea7
Parent:
7:0687d16b9781
Child:
9:fd9f64918306
fix

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:e89ba455dbcf 1 #include "cc3100_simplelink.h"
dflet 0:e89ba455dbcf 2 #include "cc3100_sl_common.h"
dflet 0:e89ba455dbcf 3 #include "fPtr_func.h"
dflet 3:b89198ac2efe 4 #include "cc3100.h"
dflet 0:e89ba455dbcf 5 #include "cc3100_spi.h"
dflet 0:e89ba455dbcf 6 #include "myBoardInit.h"
artpes 8:f4eb30a34ea7 7 #include "cc3100_socket.h"
artpes 8:f4eb30a34ea7 8 #include "cc3100_driver.h"
artpes 8:f4eb30a34ea7 9 #include "cc3100_nonos.h"
artpes 8:f4eb30a34ea7 10 #include "mbed.h"
artpes 8:f4eb30a34ea7 11 #include "rtos.h"
dflet 0:e89ba455dbcf 12
dflet 0:e89ba455dbcf 13 using namespace mbed_cc3100;
dflet 0:e89ba455dbcf 14
artpes 8:f4eb30a34ea7 15 #define SL_STOP_TIMEOUT 0xFF
artpes 8:f4eb30a34ea7 16
artpes 8:f4eb30a34ea7 17 /* IP addressed of server side socket. Should be in long format,
artpes 8:f4eb30a34ea7 18 * E.g: 0xc0a8010a == 192.168.1.10 */
artpes 8:f4eb30a34ea7 19 //#define IP_ADDR 0xc0a82b69 //192.168.43.105
artpes 8:f4eb30a34ea7 20 #define PORT_NUM 50001 /* Port number to be used */
artpes 8:f4eb30a34ea7 21
artpes 8:f4eb30a34ea7 22 #define BUF_SIZE 1400
artpes 8:f4eb30a34ea7 23 #define NO_OF_PACKETS 1000
artpes 8:f4eb30a34ea7 24
dflet 0:e89ba455dbcf 25 cc3100 _cc3100(p9, p10, p8, SPI(p11, p12, p13));//LPC1768 irq, nHib, cs, mosi, miso, sck
dflet 0:e89ba455dbcf 26 Serial pc(USBTX, USBRX);//lpc1768
artpes 8:f4eb30a34ea7 27 DigitalOut myled1(LED1);
artpes 8:f4eb30a34ea7 28 DigitalOut myled2(LED2);
artpes 8:f4eb30a34ea7 29 DigitalOut myled3(LED3);
artpes 8:f4eb30a34ea7 30 DigitalOut myled4(LED4);
dflet 0:e89ba455dbcf 31
dflet 0:e89ba455dbcf 32
artpes 8:f4eb30a34ea7 33 //GLOBAL VARIABLES -- Start
dflet 3:b89198ac2efe 34 int32_t demo = 0;
artpes 8:f4eb30a34ea7 35 //GLOBAL VARIABLES -- End
dflet 0:e89ba455dbcf 36
dflet 0:e89ba455dbcf 37
dflet 0:e89ba455dbcf 38 static void displayBanner()
dflet 0:e89ba455dbcf 39 {
artpes 8:f4eb30a34ea7 40 printf("\n\r\n\r");
artpes 8:f4eb30a34ea7 41 printf("***********Getting started with station application***********");
artpes 8:f4eb30a34ea7 42 printf("\n\r*******************************************************************************\n\r");
artpes 8:f4eb30a34ea7 43 }
artpes 8:f4eb30a34ea7 44 void ethernet(char a)
artpes 8:f4eb30a34ea7 45 {
artpes 8:f4eb30a34ea7 46 EthernetInterface eth;
artpes 8:f4eb30a34ea7 47 eth.init(); //Use DHCP
artpes 8:f4eb30a34ea7 48 int i = eth.connect();
artpes 8:f4eb30a34ea7 49 printf("Connection = %d\n", i);
artpes 8:f4eb30a34ea7 50
artpes 8:f4eb30a34ea7 51 printf("IP Address is %s\n", eth.getIPAddress());
artpes 8:f4eb30a34ea7 52 printf("Gateway is %s\n", eth.getGateway());
artpes 8:f4eb30a34ea7 53 printf("MAC Address is %s\n", eth.getMACAddress());
artpes 8:f4eb30a34ea7 54
artpes 8:f4eb30a34ea7 55 TCPSocketConnection sock;
artpes 8:f4eb30a34ea7 56 sock.connect("mbed.org", 80);
dflet 0:e89ba455dbcf 57
artpes 8:f4eb30a34ea7 58 char http_cmd[] = "GET /www.google.com \n\n";
artpes 8:f4eb30a34ea7 59 sock.send_all(http_cmd, sizeof(http_cmd)-1);
artpes 8:f4eb30a34ea7 60
artpes 8:f4eb30a34ea7 61 char buffer[300];
artpes 8:f4eb30a34ea7 62 int ret;
artpes 8:f4eb30a34ea7 63 while (true) {
artpes 8:f4eb30a34ea7 64 ret = sock.receive(buffer, sizeof(buffer)-1);
artpes 8:f4eb30a34ea7 65 if (ret <= 0)
artpes 8:f4eb30a34ea7 66 break;
artpes 8:f4eb30a34ea7 67 buffer[ret] = '\0';
artpes 8:f4eb30a34ea7 68 printf("Received %d chars from server:\n%s\n", ret, buffer);
dflet 0:e89ba455dbcf 69 }
artpes 8:f4eb30a34ea7 70
artpes 8:f4eb30a34ea7 71 sock.close();
artpes 8:f4eb30a34ea7 72
artpes 8:f4eb30a34ea7 73 eth.disconnect();
artpes 8:f4eb30a34ea7 74
dflet 0:e89ba455dbcf 75 }
dflet 0:e89ba455dbcf 76
artpes 8:f4eb30a34ea7 77 //******************************STATION_MODE***********************************************
artpes 8:f4eb30a34ea7 78 //*****************************************************************************************
artpes 8:f4eb30a34ea7 79 void station_app()
artpes 8:f4eb30a34ea7 80 {
dflet 0:e89ba455dbcf 81 int32_t retVal = -1;
dflet 5:d3b320ebd469 82
dflet 0:e89ba455dbcf 83 /* Connecting to WLAN AP */
dflet 0:e89ba455dbcf 84 retVal = _cc3100.establishConnectionWithAP();
artpes 8:f4eb30a34ea7 85 //printf("retVal 000: %d\n\r",retVal);
dflet 0:e89ba455dbcf 86 if(retVal < 0)
dflet 0:e89ba455dbcf 87 {
dflet 0:e89ba455dbcf 88 printf(" Failed to establish connection w/ an AP \n\r");
dflet 0:e89ba455dbcf 89 LOOP_FOREVER();
dflet 5:d3b320ebd469 90 }
dflet 0:e89ba455dbcf 91 printf(" Connection established w/ AP and IP is acquired \n\r");
dflet 5:d3b320ebd469 92
dflet 0:e89ba455dbcf 93 printf(" Pinging...! \n\r");
dflet 0:e89ba455dbcf 94 retVal = _cc3100.checkLanConnection();
artpes 8:f4eb30a34ea7 95 //printf("retVal 001: %d\n\r",retVal);
dflet 0:e89ba455dbcf 96 if(retVal < 0)
dflet 0:e89ba455dbcf 97 {
dflet 0:e89ba455dbcf 98 printf(" Device couldn't connect to LAN \n\r");
dflet 0:e89ba455dbcf 99 LOOP_FOREVER();
dflet 0:e89ba455dbcf 100 }
artpes 8:f4eb30a34ea7 101 printf(" Device successfully connected to the LAN\n\r");
artpes 8:f4eb30a34ea7 102 /*
dflet 0:e89ba455dbcf 103 retVal = _cc3100.checkInternetConnection();
dflet 0:e89ba455dbcf 104 if(retVal < 0)
dflet 0:e89ba455dbcf 105 {
dflet 0:e89ba455dbcf 106 printf(" Device couldn't connect to the internet \n\r");
dflet 0:e89ba455dbcf 107 LOOP_FOREVER();
dflet 0:e89ba455dbcf 108 }
dflet 0:e89ba455dbcf 109
artpes 8:f4eb30a34ea7 110 printf(" Device successfully connected to the internet \n\r");*/
artpes 8:f4eb30a34ea7 111 }
artpes 8:f4eb30a34ea7 112 //****************************END_STATION_MODE*********************************************
artpes 8:f4eb30a34ea7 113 //*****************************************************************************************
artpes 8:f4eb30a34ea7 114 void led(int result){
artpes 8:f4eb30a34ea7 115
artpes 8:f4eb30a34ea7 116 if (result > 0)
artpes 8:f4eb30a34ea7 117 {
artpes 8:f4eb30a34ea7 118 myled1 = 1;
artpes 8:f4eb30a34ea7 119 wait(0.05);
artpes 8:f4eb30a34ea7 120 myled1 = 0;
artpes 8:f4eb30a34ea7 121 wait(0.05);
artpes 8:f4eb30a34ea7 122 myled2 = 1;
artpes 8:f4eb30a34ea7 123 wait(0.05);
artpes 8:f4eb30a34ea7 124 myled2 = 0;
artpes 8:f4eb30a34ea7 125 wait(0.05);
artpes 8:f4eb30a34ea7 126 myled3 = 1;
artpes 8:f4eb30a34ea7 127 wait(0.05);
artpes 8:f4eb30a34ea7 128 myled3 = 0;
artpes 8:f4eb30a34ea7 129 wait(0.05);
artpes 8:f4eb30a34ea7 130 myled4 = 1;
artpes 8:f4eb30a34ea7 131 wait(0.05);
artpes 8:f4eb30a34ea7 132 myled4 = 0;
artpes 8:f4eb30a34ea7 133 wait(0.05);
artpes 8:f4eb30a34ea7 134 }
artpes 8:f4eb30a34ea7 135 else
artpes 8:f4eb30a34ea7 136 { myled1 = 0;
artpes 8:f4eb30a34ea7 137 myled2 = 0;
artpes 8:f4eb30a34ea7 138 myled3 = 0;
artpes 8:f4eb30a34ea7 139 myled4 = 0;
artpes 8:f4eb30a34ea7 140 }
artpes 8:f4eb30a34ea7 141
artpes 8:f4eb30a34ea7 142 }
artpes 8:f4eb30a34ea7 143
artpes 8:f4eb30a34ea7 144 //osThreadDef(led, osPriorityNormal, DEFAULT_STACK_SIZE);
artpes 8:f4eb30a34ea7 145 static int32_t BsdTcpServer(uint16_t Port)
artpes 8:f4eb30a34ea7 146 {
artpes 8:f4eb30a34ea7 147
artpes 8:f4eb30a34ea7 148 SlSockAddrIn_t Addr;
artpes 8:f4eb30a34ea7 149 SlSockAddrIn_t LocalAddr;
artpes 8:f4eb30a34ea7 150 char stringa[100];
artpes 8:f4eb30a34ea7 151 //int16_t idx = 0;
artpes 8:f4eb30a34ea7 152 int16_t AddrSize = 0;
artpes 8:f4eb30a34ea7 153 int16_t SockID = 0;
artpes 8:f4eb30a34ea7 154 int32_t Status = 0;
artpes 8:f4eb30a34ea7 155 int16_t newSockID = 0;
artpes 8:f4eb30a34ea7 156 int16_t LoopCount = 0;
artpes 8:f4eb30a34ea7 157 //int16_t SlSockAddrIn_t = 0;
artpes 8:f4eb30a34ea7 158 int16_t recvSize = 0;
artpes 8:f4eb30a34ea7 159 //Thread thread;
artpes 8:f4eb30a34ea7 160
artpes 8:f4eb30a34ea7 161 /*
artpes 8:f4eb30a34ea7 162 for (idx=0 ; idx<BUF_SIZE ; idx++)
artpes 8:f4eb30a34ea7 163 {
artpes 8:f4eb30a34ea7 164 uBuf.BsdBuf[idx] = (_u8)(idx % 10);
artpes 8:f4eb30a34ea7 165 }
artpes 8:f4eb30a34ea7 166 */
artpes 8:f4eb30a34ea7 167
artpes 8:f4eb30a34ea7 168 LocalAddr.sin_family = SL_AF_INET;
artpes 8:f4eb30a34ea7 169 LocalAddr.sin_port = _cc3100._socket.sl_Htons(PORT_NUM);
artpes 8:f4eb30a34ea7 170 LocalAddr.sin_addr.s_addr = 0;
artpes 8:f4eb30a34ea7 171 //int port = 1;
artpes 8:f4eb30a34ea7 172 //osThreadCreate(osThread(led), (void *) port);
artpes 8:f4eb30a34ea7 173 //thread.start(led(1));
artpes 8:f4eb30a34ea7 174
artpes 8:f4eb30a34ea7 175 SockID = _cc3100._socket.sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
artpes 8:f4eb30a34ea7 176 if( SockID < 0 )
artpes 8:f4eb30a34ea7 177 {
artpes 8:f4eb30a34ea7 178 printf(" \n[TCP Server] Create socket Error \n\r");
artpes 8:f4eb30a34ea7 179 ASSERT_ON_ERROR(SockID);
artpes 8:f4eb30a34ea7 180 }
artpes 8:f4eb30a34ea7 181 else
artpes 8:f4eb30a34ea7 182 printf("\nCreate socket \n\r");
artpes 8:f4eb30a34ea7 183
artpes 8:f4eb30a34ea7 184
artpes 8:f4eb30a34ea7 185 AddrSize = sizeof(SlSockAddrIn_t);
artpes 8:f4eb30a34ea7 186 Status = _cc3100._socket.sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
artpes 8:f4eb30a34ea7 187 if( Status < 0 )
artpes 8:f4eb30a34ea7 188 {
artpes 8:f4eb30a34ea7 189 _cc3100._socket.sl_Close(SockID);
artpes 8:f4eb30a34ea7 190 printf(" \n[TCP Server] Socket address assignment Error \n\r");
artpes 8:f4eb30a34ea7 191 ASSERT_ON_ERROR(Status);
artpes 8:f4eb30a34ea7 192 }
artpes 8:f4eb30a34ea7 193 else
artpes 8:f4eb30a34ea7 194 printf("\nSocket address assignment \n\r");
artpes 8:f4eb30a34ea7 195
artpes 8:f4eb30a34ea7 196 Status = _cc3100._socket.sl_Listen(SockID, 0);
artpes 8:f4eb30a34ea7 197 if( Status < 0 )
artpes 8:f4eb30a34ea7 198 {
artpes 8:f4eb30a34ea7 199 _cc3100._socket.sl_Close(SockID);
artpes 8:f4eb30a34ea7 200 printf("\n [TCP Server] Listen Error \n\r");
artpes 8:f4eb30a34ea7 201 ASSERT_ON_ERROR(Status);
artpes 8:f4eb30a34ea7 202 }
artpes 8:f4eb30a34ea7 203 else
artpes 8:f4eb30a34ea7 204 printf("\nListen for a Connection \n\r");
artpes 8:f4eb30a34ea7 205
artpes 8:f4eb30a34ea7 206 newSockID = _cc3100._socket.sl_Accept(SockID, (SlSockAddr_t *)&Addr,(SlSocklen_t*)&AddrSize);
artpes 8:f4eb30a34ea7 207 if( newSockID < 0 )
artpes 8:f4eb30a34ea7 208 {
artpes 8:f4eb30a34ea7 209 _cc3100._socket.sl_Close(SockID);
artpes 8:f4eb30a34ea7 210 printf("\n [TCP Server] Accept connection Error \n\r");
artpes 8:f4eb30a34ea7 211 ASSERT_ON_ERROR(newSockID);
artpes 8:f4eb30a34ea7 212 }
artpes 8:f4eb30a34ea7 213 else
artpes 8:f4eb30a34ea7 214 printf("\nAccept connection \n\r");
artpes 8:f4eb30a34ea7 215
artpes 8:f4eb30a34ea7 216 while (LoopCount < NO_OF_PACKETS)
artpes 8:f4eb30a34ea7 217 {
artpes 8:f4eb30a34ea7 218 //TODO : sarebbe da chiamare la funzione led() con un altro thread così da farla girare in background
artpes 8:f4eb30a34ea7 219 led(1);
artpes 8:f4eb30a34ea7 220 recvSize = BUF_SIZE;
artpes 8:f4eb30a34ea7 221 //printf("RecvSize = %d \n\r",recvSize);
artpes 8:f4eb30a34ea7 222 do
artpes 8:f4eb30a34ea7 223 {
artpes 8:f4eb30a34ea7 224 Status = _cc3100._socket.sl_Recv(newSockID, &(stringa), strlen(stringa), 0);
artpes 8:f4eb30a34ea7 225 if( Status <= 0 )
artpes 8:f4eb30a34ea7 226 {
artpes 8:f4eb30a34ea7 227 _cc3100._socket.sl_Close(newSockID);
artpes 8:f4eb30a34ea7 228 _cc3100._socket.sl_Close(SockID);
artpes 8:f4eb30a34ea7 229 led(1);
artpes 8:f4eb30a34ea7 230 printf(" \n[TCP Server] Data recv Error. Close socket %d \n\n\r",SockID);
artpes 8:f4eb30a34ea7 231 //ASSERT_ON_ERROR(TCP_RECV_ERROR);
artpes 8:f4eb30a34ea7 232
artpes 8:f4eb30a34ea7 233 /*-----Accept new connection----------*/
artpes 8:f4eb30a34ea7 234 SockID = _cc3100._socket.sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
artpes 8:f4eb30a34ea7 235 printf("----------Create new socket---------- \n\n\r");
artpes 8:f4eb30a34ea7 236 AddrSize = sizeof(SlSockAddrIn_t);
artpes 8:f4eb30a34ea7 237 Status = _cc3100._socket.sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
artpes 8:f4eb30a34ea7 238 printf("----------Socket address assignment---------- \n\n\r");
artpes 8:f4eb30a34ea7 239 Status = _cc3100._socket.sl_Listen(SockID, 0);
artpes 8:f4eb30a34ea7 240 printf("----------Listen for a new Connection---------- \n\n\r");
artpes 8:f4eb30a34ea7 241 newSockID = _cc3100._socket.sl_Accept(SockID, (SlSockAddr_t *)&Addr,(SlSocklen_t*)&AddrSize);
artpes 8:f4eb30a34ea7 242 printf("----------Accept new connection---------- \n\n\r");
artpes 8:f4eb30a34ea7 243 led(1);
artpes 8:f4eb30a34ea7 244 }
artpes 8:f4eb30a34ea7 245
artpes 8:f4eb30a34ea7 246 //printf("Status = %d \n\r",Status);
artpes 8:f4eb30a34ea7 247 recvSize -= Status;
artpes 8:f4eb30a34ea7 248 //printf("RecvSize = %d \n\r",recvSize);
artpes 8:f4eb30a34ea7 249 printf("%s",stringa);
artpes 8:f4eb30a34ea7 250 led(1);
artpes 8:f4eb30a34ea7 251 char thanks [] = "Data received";
artpes 8:f4eb30a34ea7 252 _cc3100._socket.sl_Send(SockID, &(thanks), strlen(thanks), 0);
artpes 8:f4eb30a34ea7 253
artpes 8:f4eb30a34ea7 254 }
artpes 8:f4eb30a34ea7 255 while(recvSize > 0);
artpes 8:f4eb30a34ea7 256
artpes 8:f4eb30a34ea7 257 LoopCount++;
artpes 8:f4eb30a34ea7 258 }
artpes 8:f4eb30a34ea7 259
artpes 8:f4eb30a34ea7 260 Status = _cc3100._socket.sl_Close(newSockID);
artpes 8:f4eb30a34ea7 261 ASSERT_ON_ERROR(Status);
artpes 8:f4eb30a34ea7 262
artpes 8:f4eb30a34ea7 263 Status = _cc3100._socket.sl_Close(SockID);
artpes 8:f4eb30a34ea7 264 ASSERT_ON_ERROR(Status);
artpes 8:f4eb30a34ea7 265
artpes 8:f4eb30a34ea7 266 return SUCCESS;
artpes 8:f4eb30a34ea7 267
artpes 8:f4eb30a34ea7 268 }
dflet 0:e89ba455dbcf 269
dflet 0:e89ba455dbcf 270
artpes 8:f4eb30a34ea7 271
artpes 8:f4eb30a34ea7 272 //**************************_START_APPLICATION_*********************************
artpes 8:f4eb30a34ea7 273 int main(void)
artpes 8:f4eb30a34ea7 274 {
artpes 8:f4eb30a34ea7 275 pc.baud(115200);
artpes 8:f4eb30a34ea7 276
artpes 8:f4eb30a34ea7 277
artpes 8:f4eb30a34ea7 278
artpes 8:f4eb30a34ea7 279 int32_t retVal = -1;
artpes 8:f4eb30a34ea7 280
artpes 8:f4eb30a34ea7 281 retVal = _cc3100.initializeAppVariables();
artpes 8:f4eb30a34ea7 282
artpes 8:f4eb30a34ea7 283 displayBanner();
artpes 8:f4eb30a34ea7 284
artpes 8:f4eb30a34ea7 285 _cc3100.CLR_STATUS_BIT(g_Status, STATUS_BIT_PING_DONE);
artpes 8:f4eb30a34ea7 286 g_PingPacketsRecv = 0;
artpes 8:f4eb30a34ea7 287 //printf("\n\r FUNZIONE CLR_STATUS_BIT ESEGUITA CON SUCCESSO\n\r");
artpes 8:f4eb30a34ea7 288
artpes 8:f4eb30a34ea7 289 //retVal = _cc3100.configureSimpleLinkToDefaultState();
artpes 8:f4eb30a34ea7 290
artpes 8:f4eb30a34ea7 291 //printf("\n\rRetval 2: %d \n\r ",retVal);
artpes 8:f4eb30a34ea7 292
artpes 8:f4eb30a34ea7 293 if(retVal < 0) {
artpes 8:f4eb30a34ea7 294 if (DEVICE_NOT_IN_STATION_MODE == retVal)
artpes 8:f4eb30a34ea7 295 printf(" Failed to configure the device to its default state \n\r");
artpes 8:f4eb30a34ea7 296
artpes 8:f4eb30a34ea7 297 LOOP_FOREVER();
artpes 8:f4eb30a34ea7 298 }
artpes 8:f4eb30a34ea7 299
artpes 8:f4eb30a34ea7 300 printf("\n\rDevice is configured in it's default state \n\r");
artpes 8:f4eb30a34ea7 301 /*printf("\n\r******************************************************************************************************\n\r");
artpes 8:f4eb30a34ea7 302 printf("\n\r*****_DA_QUI_IN_POI_SCELTA_TIPO_FUNZIONE_IN_BASE_AL_VALORE_demo_*****\n\r");
artpes 8:f4eb30a34ea7 303 printf("\n\r******************************************************************************************************\n\r");*/
artpes 8:f4eb30a34ea7 304
artpes 8:f4eb30a34ea7 305 /*
artpes 8:f4eb30a34ea7 306 * Assumption is that the device is configured in station mode already
artpes 8:f4eb30a34ea7 307 * and it is in its default state
artpes 8:f4eb30a34ea7 308 */
artpes 8:f4eb30a34ea7 309 /* Initializing the CC3100 device */
artpes 8:f4eb30a34ea7 310
artpes 8:f4eb30a34ea7 311 retVal = _cc3100.sl_Start(0, 0, 0);
artpes 8:f4eb30a34ea7 312
artpes 8:f4eb30a34ea7 313 if ((retVal < 0) || (ROLE_STA != retVal) )
artpes 8:f4eb30a34ea7 314 {
artpes 8:f4eb30a34ea7 315 printf(" Failed to start the device \n\r");
artpes 8:f4eb30a34ea7 316 LOOP_FOREVER();
artpes 8:f4eb30a34ea7 317 }
artpes 8:f4eb30a34ea7 318
artpes 8:f4eb30a34ea7 319 printf("\n\r Device started as STATION \n\r");
artpes 8:f4eb30a34ea7 320
artpes 8:f4eb30a34ea7 321
artpes 8:f4eb30a34ea7 322 station_app();
artpes 8:f4eb30a34ea7 323
artpes 8:f4eb30a34ea7 324 printf("Establishing connection with TCP server \n\r");
artpes 8:f4eb30a34ea7 325 /*Before proceeding, please make sure to have a server waiting on PORT_NUM*/
artpes 8:f4eb30a34ea7 326 retVal = BsdTcpServer(PORT_NUM);
artpes 8:f4eb30a34ea7 327 if(retVal < 0)
artpes 8:f4eb30a34ea7 328 printf(" Failed to establishing connection with TCP server \n\r");
artpes 8:f4eb30a34ea7 329 else
artpes 8:f4eb30a34ea7 330 printf(" Connection with TCP server established successfully \n\r");
artpes 8:f4eb30a34ea7 331
artpes 8:f4eb30a34ea7 332 return 0;
artpes 8:f4eb30a34ea7 333
artpes 8:f4eb30a34ea7 334
artpes 8:f4eb30a34ea7 335
artpes 8:f4eb30a34ea7 336
artpes 8:f4eb30a34ea7 337 }
artpes 8:f4eb30a34ea7 338