Transfer data between UART ports and Ethernet.

Dependencies:   BufferedSerial

Transfer data between UART ports and Ethernet.

  • Support multiple UART ports.
  • Support fixed IP address and DHCP.
  • Support TCP server and TCP client modes.
  • Support a simple web server for UART and Ethernet configuration.
Committer:
morgandu
Date:
Fri Mar 22 09:59:52 2019 +0000
Revision:
6:dc9f344f4bf0
Parent:
5:7e7ad7c079fe
Child:
7:cbb5a2a2a0d2
Update to MbedOS v5.11; Update NuMaker-mbed-SD-driver; Fix socket control due to MbedOS upgrade; Support NuMaker-IoT-M487 board

Who changed what in which revision?

UserRevisionLine numberNew contents of line
morgandu 0:11bc39d0f367 1 /*
morgandu 0:11bc39d0f367 2 * Copyright (c) 2017 Nuvoton Tecnology Corp. All rights reserved.
morgandu 0:11bc39d0f367 3 *
morgandu 0:11bc39d0f367 4 * The code is forward data from UART port to Ethernet, and vice versa.
morgandu 0:11bc39d0f367 5 *
morgandu 0:11bc39d0f367 6 *
morgandu 0:11bc39d0f367 7 */
morgandu 0:11bc39d0f367 8
morgandu 0:11bc39d0f367 9 #include "ste_config.h"
morgandu 0:11bc39d0f367 10
morgandu 0:11bc39d0f367 11 /* If define USE_STATIC_IP, specify the default IP address. */
morgandu 0:11bc39d0f367 12 #if 0
morgandu 0:11bc39d0f367 13 // private IP address for general purpose
morgandu 0:11bc39d0f367 14 #define IP_ADDRESS "192.168.1.2"
morgandu 0:11bc39d0f367 15 #define NETWORK_MASK "255.255.255.0"
morgandu 0:11bc39d0f367 16 #define GATEWAY_ADDRESS "192.168.1.1"
morgandu 0:11bc39d0f367 17 #else
morgandu 0:11bc39d0f367 18 // private IP address only for test with Windows when DHCP server doesn't exist.
morgandu 2:35f2cc8b05fa 19 // Windows set its LAN IP address to 169.254.xxx.xxx / 255.255.0.0
morgandu 0:11bc39d0f367 20 #define IP_ADDRESS "169.254.108.2"
morgandu 0:11bc39d0f367 21 #define NETWORK_MASK "255.255.0.0"
morgandu 0:11bc39d0f367 22 #define GATEWAY_ADDRESS "169.254.108.1"
morgandu 0:11bc39d0f367 23 #endif
morgandu 0:11bc39d0f367 24
morgandu 0:11bc39d0f367 25 /* Default configuration for network */
morgandu 0:11bc39d0f367 26 S_NET_CONFIG net_config = {IP_STATIC_MODE, IP_ADDRESS, NETWORK_MASK, GATEWAY_ADDRESS};
morgandu 0:11bc39d0f367 27
morgandu 6:dc9f344f4bf0 28 #if defined (TARGET_NUMAKER_PFM_M487) || defined(TARGET_NUMAKER_IOT_M487)
morgandu 5:7e7ad7c079fe 29 BufferedSerial serial_0(PB_3, PB_2, 256, 4); // UART1
morgandu 1:c53f82eb6b42 30 BufferedSerial serial_1(PA_5, PA_4, 256, 4); // UART5
morgandu 5:7e7ad7c079fe 31 //BufferedSerial serial_2(PB_13, PB_12, 256, 4); // UART0, Debug
morgandu 0:11bc39d0f367 32
morgandu 0:11bc39d0f367 33 #elif defined (TARGET_NUMAKER_PFM_NUC472)
morgandu 0:11bc39d0f367 34 BufferedSerial serial_0(PH_1, PH_0, 256, 4); // UART4
morgandu 0:11bc39d0f367 35 BufferedSerial serial_1(PG_2, PG_1, 256, 4); // UART0
morgandu 0:11bc39d0f367 36 BufferedSerial serial_2(PC_11, PC_10, 256, 4); // UART2
morgandu 0:11bc39d0f367 37
morgandu 1:c53f82eb6b42 38 #elif defined (TARGET_NUMAKER_PFM_M453) || defined(TARGET_NUMAKER_PFM_NANO130)
morgandu 0:11bc39d0f367 39 #error The board has no Ethernet.
morgandu 0:11bc39d0f367 40
morgandu 0:11bc39d0f367 41 #else
morgandu 0:11bc39d0f367 42 #error define UART ports for your board.
morgandu 0:11bc39d0f367 43 #endif
morgandu 0:11bc39d0f367 44
morgandu 0:11bc39d0f367 45 /* Default configuration for network ports and UART ports, etc. */
morgandu 0:11bc39d0f367 46 S_PORT_CONFIG port_config[MAX_UART_PORTS] = {
morgandu 0:11bc39d0f367 47
morgandu 0:11bc39d0f367 48 #if MAX_UART_PORTS == 1
morgandu 0:11bc39d0f367 49 {NET_SERVER_MODE, NET_PORT_BASE, &serial_0, DEFAULT_UART_BAUD, 8, 1, SerialBase::None}
morgandu 0:11bc39d0f367 50
morgandu 0:11bc39d0f367 51 #elif MAX_UART_PORTS == 2
morgandu 0:11bc39d0f367 52 {NET_SERVER_MODE, NET_PORT_BASE + 0, &serial_0, DEFAULT_UART_BAUD, 8, 1, SerialBase::None},
morgandu 0:11bc39d0f367 53 {NET_SERVER_MODE, NET_PORT_BASE + 1, &serial_1, DEFAULT_UART_BAUD, 8, 1, SerialBase::None}
morgandu 0:11bc39d0f367 54
morgandu 0:11bc39d0f367 55 #elif MAX_UART_PORTS == 3
morgandu 0:11bc39d0f367 56 {NET_SERVER_MODE, NET_PORT_BASE + 0, &serial_0, DEFAULT_UART_BAUD, 8, 1, SerialBase::None},
morgandu 0:11bc39d0f367 57 {NET_SERVER_MODE, NET_PORT_BASE + 1, &serial_1, DEFAULT_UART_BAUD, 8, 1, SerialBase::None},
morgandu 0:11bc39d0f367 58 {NET_SERVER_MODE, NET_PORT_BASE + 2, &serial_2, DEFAULT_UART_BAUD, 8, 1, SerialBase::None}
morgandu 0:11bc39d0f367 59
morgandu 0:11bc39d0f367 60 #else
morgandu 0:11bc39d0f367 61 #error You have to define ports mapping table.
morgandu 0:11bc39d0f367 62 #endif
morgandu 0:11bc39d0f367 63 };
morgandu 0:11bc39d0f367 64
morgandu 0:11bc39d0f367 65 /* UART port to output debug message */
morgandu 2:35f2cc8b05fa 66 RawSerial output(USBTX, USBRX); // UART3 on NuMaker-PFM-NUC472, UART0 on NuMaker-PFM-M487
morgandu 0:11bc39d0f367 67 EthernetInterface eth;
morgandu 0:11bc39d0f367 68
morgandu 0:11bc39d0f367 69 #ifdef ENABLE_WEB_CONFIG
morgandu 0:11bc39d0f367 70
morgandu 0:11bc39d0f367 71 /* Declare the SD card as storage */
morgandu 0:11bc39d0f367 72 NuSDBlockDevice bd;
morgandu 0:11bc39d0f367 73 FATFileSystem fs("fs");
morgandu 0:11bc39d0f367 74 bool SD_Card_Mounted = FALSE;
morgandu 0:11bc39d0f367 75
morgandu 0:11bc39d0f367 76 #endif
morgandu 0:11bc39d0f367 77
morgandu 0:11bc39d0f367 78 /* --- --- */
morgandu 0:11bc39d0f367 79
morgandu 0:11bc39d0f367 80 /*
morgandu 0:11bc39d0f367 81 * Forward serial port data to ethernet, and vice versa.
morgandu 0:11bc39d0f367 82 *
morgandu 0:11bc39d0f367 83 */
morgandu 0:11bc39d0f367 84 void exchange_data(S_PORT_CONFIG *pmap, TCPSocket *psocket)
morgandu 0:11bc39d0f367 85 {
morgandu 0:11bc39d0f367 86 unsigned char n_buf[256];
morgandu 0:11bc39d0f367 87 unsigned char s_buf[256];
morgandu 0:11bc39d0f367 88 int n_len = 0, n_index = 0;
morgandu 0:11bc39d0f367 89 int s_len = 0, s_index = 0;
morgandu 1:c53f82eb6b42 90 unsigned int eth_tx_count = 0;
morgandu 0:11bc39d0f367 91
morgandu 0:11bc39d0f367 92 while(1)
morgandu 0:11bc39d0f367 93 {
morgandu 0:11bc39d0f367 94 /*** Network to Serial ***/
morgandu 0:11bc39d0f367 95
morgandu 1:c53f82eb6b42 96 if (n_len == 0)
morgandu 0:11bc39d0f367 97 {
morgandu 0:11bc39d0f367 98 // net buffer is empty, try to get new data from network.
morgandu 0:11bc39d0f367 99 n_len = psocket->recv(n_buf, sizeof(n_buf));
morgandu 1:c53f82eb6b42 100 if (n_len == 0)
morgandu 0:11bc39d0f367 101 {
morgandu 1:c53f82eb6b42 102 eth_tx_count += 3;
morgandu 1:c53f82eb6b42 103 }
morgandu 1:c53f82eb6b42 104 else if (n_len == NSAPI_ERROR_WOULD_BLOCK)
morgandu 1:c53f82eb6b42 105 {
morgandu 1:c53f82eb6b42 106 n_len = 0;
morgandu 0:11bc39d0f367 107 }
morgandu 0:11bc39d0f367 108 else if (n_len < 0)
morgandu 0:11bc39d0f367 109 {
morgandu 0:11bc39d0f367 110 printf("Socket Recv Err (%d)\r\n", n_len);
morgandu 0:11bc39d0f367 111 break;
morgandu 0:11bc39d0f367 112 }
morgandu 0:11bc39d0f367 113 }
morgandu 0:11bc39d0f367 114 else
morgandu 0:11bc39d0f367 115 {
morgandu 1:c53f82eb6b42 116 n_index += pmap->pserial->write(n_buf+n_index, n_len-n_index);
morgandu 1:c53f82eb6b42 117 if (n_index == n_len)
morgandu 0:11bc39d0f367 118 {
morgandu 1:c53f82eb6b42 119 n_len = 0;
morgandu 1:c53f82eb6b42 120 n_index = 0;
morgandu 0:11bc39d0f367 121 }
morgandu 0:11bc39d0f367 122 }
morgandu 0:11bc39d0f367 123
morgandu 0:11bc39d0f367 124 /*** Serial to Network ***/
morgandu 1:c53f82eb6b42 125
morgandu 1:c53f82eb6b42 126 // try to get more data from serial port
morgandu 1:c53f82eb6b42 127 for(; s_index < sizeof(s_buf) && pmap->pserial->readable(); s_index++)
morgandu 1:c53f82eb6b42 128 s_buf[s_index] = pmap->pserial->getc();
morgandu 0:11bc39d0f367 129
morgandu 1:c53f82eb6b42 130 if (s_index >= 240 || (s_index != 0 && ++eth_tx_count >= 5))
morgandu 0:11bc39d0f367 131 {
morgandu 1:c53f82eb6b42 132 s_len = psocket->send(s_buf, s_index);
morgandu 1:c53f82eb6b42 133
morgandu 1:c53f82eb6b42 134 if (s_len == NSAPI_ERROR_WOULD_BLOCK)
morgandu 1:c53f82eb6b42 135 {
morgandu 1:c53f82eb6b42 136 printf("Socket Send no block.\r\n");
morgandu 1:c53f82eb6b42 137 }
morgandu 1:c53f82eb6b42 138 else if (s_len < 0)
morgandu 0:11bc39d0f367 139 {
morgandu 1:c53f82eb6b42 140 printf("Socket Send Err (%d)\r\n", s_len);
morgandu 1:c53f82eb6b42 141 break;
morgandu 0:11bc39d0f367 142 }
morgandu 1:c53f82eb6b42 143 else // s_len >= s_index
morgandu 1:c53f82eb6b42 144 {
morgandu 1:c53f82eb6b42 145 unsigned int i;
morgandu 1:c53f82eb6b42 146
morgandu 1:c53f82eb6b42 147 // move remain data if existed.
morgandu 1:c53f82eb6b42 148 for(i=0; s_len < s_index; i++, s_len++)
morgandu 1:c53f82eb6b42 149 s_buf[i] = s_buf[s_len];
morgandu 1:c53f82eb6b42 150
morgandu 1:c53f82eb6b42 151 s_index = i;
morgandu 1:c53f82eb6b42 152 eth_tx_count = 0;
morgandu 1:c53f82eb6b42 153 }
morgandu 1:c53f82eb6b42 154 }
morgandu 0:11bc39d0f367 155 }
morgandu 0:11bc39d0f367 156 }
morgandu 1:c53f82eb6b42 157
morgandu 0:11bc39d0f367 158 void bridge_net_client(S_PORT_CONFIG *pmap)
morgandu 0:11bc39d0f367 159 {
morgandu 0:11bc39d0f367 160 TCPSocket socket;
morgandu 0:11bc39d0f367 161 SocketAddress server_address;
morgandu 0:11bc39d0f367 162 nsapi_error_t err;
morgandu 0:11bc39d0f367 163
morgandu 0:11bc39d0f367 164 printf("Thread %x in TCP client mode.\r\n", (unsigned int)pmap);
morgandu 0:11bc39d0f367 165
morgandu 0:11bc39d0f367 166 if ((err=socket.open(&eth)) < 0)
morgandu 0:11bc39d0f367 167 {
morgandu 0:11bc39d0f367 168 printf("TCP socket can't open (%d)(%x).\r\n", err, (unsigned int)pmap);
morgandu 0:11bc39d0f367 169 return;
morgandu 0:11bc39d0f367 170 }
morgandu 0:11bc39d0f367 171
morgandu 0:11bc39d0f367 172 printf("Connecting server %s:%d ...\r\n", pmap->server_addr, pmap->server_port);
morgandu 0:11bc39d0f367 173 while(1)
morgandu 0:11bc39d0f367 174 {
morgandu 0:11bc39d0f367 175 if ((err=socket.connect(pmap->server_addr, pmap->server_port)) >= 0)
morgandu 1:c53f82eb6b42 176 {
morgandu 1:c53f82eb6b42 177 printf("\r\nConnected.");
morgandu 0:11bc39d0f367 178 break;
morgandu 1:c53f82eb6b42 179 }
morgandu 0:11bc39d0f367 180 }
morgandu 0:11bc39d0f367 181
morgandu 0:11bc39d0f367 182 socket.set_timeout(1);
morgandu 0:11bc39d0f367 183 exchange_data(pmap, &socket);
morgandu 6:dc9f344f4bf0 184 socket.close();
morgandu 0:11bc39d0f367 185 }
morgandu 0:11bc39d0f367 186
morgandu 0:11bc39d0f367 187 void bridge_net_server(S_PORT_CONFIG *pmap)
morgandu 0:11bc39d0f367 188 {
morgandu 6:dc9f344f4bf0 189 TCPSocket tcp_server;
morgandu 6:dc9f344f4bf0 190 TCPSocket *client_socket;
morgandu 0:11bc39d0f367 191 SocketAddress client_address;
morgandu 0:11bc39d0f367 192 nsapi_error_t err;
morgandu 0:11bc39d0f367 193
morgandu 0:11bc39d0f367 194 printf("Thread %x in TCP server mode.\r\n", (unsigned int)pmap);
morgandu 0:11bc39d0f367 195
morgandu 0:11bc39d0f367 196 if ((err=tcp_server.open(&eth)) < 0)
morgandu 0:11bc39d0f367 197 {
morgandu 0:11bc39d0f367 198 printf("TCP server can't open (%d)(%x).\r\n", err, (unsigned int)pmap);
morgandu 0:11bc39d0f367 199 return;
morgandu 0:11bc39d0f367 200 }
morgandu 0:11bc39d0f367 201 if ((err=tcp_server.bind(eth.get_ip_address(), pmap->port)) < 0)
morgandu 0:11bc39d0f367 202 {
morgandu 0:11bc39d0f367 203 printf("TCP server can't bind address and port (%d)(%x).\r\n", err, (unsigned int)pmap);
morgandu 0:11bc39d0f367 204 return;
morgandu 0:11bc39d0f367 205 }
morgandu 0:11bc39d0f367 206 if ((err=tcp_server.listen(1)) < 0)
morgandu 0:11bc39d0f367 207 {
morgandu 0:11bc39d0f367 208 printf("TCP server can't listen (%d)(%x).\r\n", err, (unsigned int)pmap);
morgandu 0:11bc39d0f367 209 return;
morgandu 0:11bc39d0f367 210 }
morgandu 0:11bc39d0f367 211
morgandu 0:11bc39d0f367 212 while(1)
morgandu 0:11bc39d0f367 213 {
morgandu 6:dc9f344f4bf0 214 client_socket = tcp_server.accept(&err);
morgandu 6:dc9f344f4bf0 215 if (err < 0) // && err != NSAPI_ERROR_WOULD_BLOCK)
morgandu 0:11bc39d0f367 216 {
morgandu 0:11bc39d0f367 217 printf("TCP server fail to accept connection (%d)(%x).\r\n", err, (unsigned int)pmap);
morgandu 0:11bc39d0f367 218 return;
morgandu 0:11bc39d0f367 219 }
morgandu 6:dc9f344f4bf0 220 else
morgandu 6:dc9f344f4bf0 221 {
morgandu 6:dc9f344f4bf0 222 client_socket->getpeername(&client_address);
morgandu 6:dc9f344f4bf0 223 printf("Connect (%d) from %s:%d ...\r\n", pmap->port, client_address.get_ip_address(), client_address.get_port());
morgandu 6:dc9f344f4bf0 224
morgandu 6:dc9f344f4bf0 225 client_socket->set_timeout(1);
morgandu 6:dc9f344f4bf0 226 exchange_data(pmap, client_socket);
morgandu 6:dc9f344f4bf0 227 client_socket->close();
morgandu 6:dc9f344f4bf0 228 }
morgandu 0:11bc39d0f367 229 }
morgandu 0:11bc39d0f367 230 }
morgandu 0:11bc39d0f367 231
morgandu 0:11bc39d0f367 232 int main()
morgandu 0:11bc39d0f367 233 {
morgandu 0:11bc39d0f367 234 /* Set the console baud-rate */
morgandu 0:11bc39d0f367 235 output.baud(115200);
morgandu 0:11bc39d0f367 236 printf("\r\nmbed OS version is %d.\r\n", MBED_VERSION);
morgandu 0:11bc39d0f367 237 printf("Start Serial-to-Ethernet...\r\n");
morgandu 0:11bc39d0f367 238
morgandu 0:11bc39d0f367 239 #ifdef ENABLE_WEB_CONFIG
morgandu 0:11bc39d0f367 240
morgandu 0:11bc39d0f367 241 /* Restore configuration from SD card */
morgandu 0:11bc39d0f367 242
morgandu 0:11bc39d0f367 243 SD_Card_Mounted = (fs.mount(&bd) >= 0);
morgandu 0:11bc39d0f367 244 if (SD_Card_Mounted)
morgandu 0:11bc39d0f367 245 {
morgandu 0:11bc39d0f367 246 FILE *fd = fopen(SER_CONFIG_FILE, "r");
morgandu 0:11bc39d0f367 247 if (fd != NULL)
morgandu 0:11bc39d0f367 248 {
morgandu 0:11bc39d0f367 249 char pBuf[sizeof(port_config)+2];
morgandu 0:11bc39d0f367 250 int len = fread(pBuf, 1, sizeof(port_config)+2, fd);
morgandu 0:11bc39d0f367 251 if (len == (sizeof(port_config)+2) && pBuf[0] == 'N' && pBuf[1] == 'T')
morgandu 0:11bc39d0f367 252 {
morgandu 0:11bc39d0f367 253 printf("Set Serial ports from config file in SD card.\r\n");
morgandu 0:11bc39d0f367 254 memcpy(port_config, pBuf+2, sizeof(port_config));
morgandu 0:11bc39d0f367 255 }
morgandu 0:11bc39d0f367 256 else
morgandu 0:11bc39d0f367 257 printf("Incorrect serial config file.\r\n");
morgandu 0:11bc39d0f367 258
morgandu 0:11bc39d0f367 259 fclose(fd);
morgandu 0:11bc39d0f367 260 }
morgandu 0:11bc39d0f367 261 else
morgandu 0:11bc39d0f367 262 printf("Can't open serial config file.\r\n");
morgandu 0:11bc39d0f367 263
morgandu 0:11bc39d0f367 264 fd = fopen(NET_CONFIG_FILE, "r");
morgandu 0:11bc39d0f367 265 if (fd != NULL)
morgandu 0:11bc39d0f367 266 {
morgandu 0:11bc39d0f367 267 char pBuf[sizeof(net_config)+2];
morgandu 0:11bc39d0f367 268 int len = fread(pBuf, 1, sizeof(net_config)+2, fd);
morgandu 0:11bc39d0f367 269 if (len == (sizeof(net_config)+2) && pBuf[0] == 'N' && pBuf[1] == 'T')
morgandu 0:11bc39d0f367 270 {
morgandu 0:11bc39d0f367 271 printf("Set network from config file in SD card.\r\n");
morgandu 0:11bc39d0f367 272 memcpy(&net_config, pBuf+2, sizeof(net_config));
morgandu 0:11bc39d0f367 273 }
morgandu 0:11bc39d0f367 274 else
morgandu 0:11bc39d0f367 275 printf("Incorrect network config file.\r\n");
morgandu 0:11bc39d0f367 276
morgandu 0:11bc39d0f367 277 fclose(fd);
morgandu 0:11bc39d0f367 278 }
morgandu 0:11bc39d0f367 279 else
morgandu 0:11bc39d0f367 280 printf("Can't open network config file.\r\n");
morgandu 0:11bc39d0f367 281 }
morgandu 0:11bc39d0f367 282 else
morgandu 0:11bc39d0f367 283 {
morgandu 0:11bc39d0f367 284 printf("Can't find SD card.\r\n");
morgandu 0:11bc39d0f367 285 }
morgandu 0:11bc39d0f367 286
morgandu 0:11bc39d0f367 287 #endif
morgandu 0:11bc39d0f367 288
morgandu 0:11bc39d0f367 289 printf("Configure UART ports...\r\n");
morgandu 0:11bc39d0f367 290 for(int i=0; i<MAX_UART_PORTS; i++)
morgandu 0:11bc39d0f367 291 {
morgandu 0:11bc39d0f367 292 port_config[i].pserial->baud(port_config[i].baud);
morgandu 0:11bc39d0f367 293 port_config[i].pserial->format(port_config[i].data, port_config[i].parity, port_config[i].stop);
morgandu 0:11bc39d0f367 294 }
morgandu 0:11bc39d0f367 295
morgandu 0:11bc39d0f367 296 if (net_config.mode == IP_STATIC_MODE)
morgandu 0:11bc39d0f367 297 {
morgandu 0:11bc39d0f367 298 printf("Start Ethernet in Static mode.\r\n");
morgandu 0:11bc39d0f367 299 eth.disconnect();
morgandu 0:11bc39d0f367 300 ((NetworkInterface *)&eth)->set_network(net_config.ip, net_config.mask, net_config.gateway);
morgandu 0:11bc39d0f367 301 }
morgandu 0:11bc39d0f367 302 else
morgandu 0:11bc39d0f367 303 printf("Start Ethernet in DHCP mode.\r\n");
morgandu 0:11bc39d0f367 304
morgandu 0:11bc39d0f367 305 eth.connect();
morgandu 0:11bc39d0f367 306 printf("IP Address is %s\r\n", eth.get_ip_address());
morgandu 5:7e7ad7c079fe 307
morgandu 0:11bc39d0f367 308 Thread thread[MAX_UART_PORTS];
morgandu 0:11bc39d0f367 309
morgandu 0:11bc39d0f367 310 // Folk thread for each port
morgandu 0:11bc39d0f367 311 for(int i=0; i<MAX_UART_PORTS; i++)
morgandu 0:11bc39d0f367 312 {
morgandu 0:11bc39d0f367 313 if (port_config[i].mode == NET_SERVER_MODE)
morgandu 0:11bc39d0f367 314 {
morgandu 0:11bc39d0f367 315 thread[i].start(callback(bridge_net_server, &(port_config[i])));
morgandu 0:11bc39d0f367 316 }
morgandu 0:11bc39d0f367 317 else // if (port_config[i].mode == TCP_CLIENT_MODE)
morgandu 0:11bc39d0f367 318 {
morgandu 0:11bc39d0f367 319 thread[i].start(callback(bridge_net_client, &(port_config[i])));
morgandu 0:11bc39d0f367 320 }
morgandu 0:11bc39d0f367 321 }
morgandu 0:11bc39d0f367 322
morgandu 0:11bc39d0f367 323 #ifdef ENABLE_WEB_CONFIG
morgandu 0:11bc39d0f367 324
morgandu 0:11bc39d0f367 325 /*** main thread to be a web server for configuration ***/
morgandu 0:11bc39d0f367 326 start_httpd();
morgandu 0:11bc39d0f367 327
morgandu 0:11bc39d0f367 328 #endif
morgandu 0:11bc39d0f367 329
morgandu 0:11bc39d0f367 330 while(1);
morgandu 0:11bc39d0f367 331
morgandu 0:11bc39d0f367 332 /* end of main task */
morgandu 0:11bc39d0f367 333 //eth.disconnect();
morgandu 0:11bc39d0f367 334 }