forked from TMaxElectronics/UD3-Fibernet-Firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FiberComms.c
534 lines (442 loc) · 19.6 KB
/
FiberComms.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
/*
* File: FiberCommys.c
* Author: Thorb
*
* Created on October 20, 2020, 6:07 PM
*/
#include <xc.h>
#include <stdio.h>
#include "FiberComms.h"
#include "FreeRTOS_Sockets.h"
#include "FreeRTOS_IP.h"
#include "FreeRTOS_DHCP.h"
#include "FreeRTOS_Sockets.h"
#include "min.h"
#include "LAN9250.h"
#include "UART.h"
#include "min_id.h"
#include "UD3_Wrapper.h"
#include "TTerm.h"
#include "startup.h"
#include "TTerm_cmd.h"
#include "FreeRTOS/Core/include/stream_buffer.h"
#include "apps/apps.h"
#include "LED.h"
char FIND_queryString[] = "FINDReq=1;";
struct min_context * COMMS_UDP;
struct min_context * COMMS_UART;
struct freertos_sockaddr lastClient;
uint32_t clientLength = sizeof(lastClient);
Socket_t dataSocket;
TERMINAL_HANDLE * term;
uint8_t dhcpEnable = pdTRUE;
ConnStats ConnectionStats;
StreamBufferHandle_t streamRx;
#define STREAM_SIZE 255
void Term_task(void *pvParameters);
void COMMS_init(){
//initialize min contexts
COMMS_UDP = pvPortMalloc(sizeof(struct min_context));
COMMS_UART = pvPortMalloc(sizeof(struct min_context));
min_init_context(COMMS_UDP, COMMS_UDP);
min_init_context(COMMS_UART, COMMS_UART);
TERM_addCommand(CMD_ifconfig, "ifconfig", "displays network interface parameters", 0, &TERM_cmdListHead);
TERM_addCommand(CMD_testAlarm, "testAlarm", "sends an alarm to the UD3", 0, &TERM_cmdListHead);
TERM_addCommand(CMD_boot, "boot", "Bootloader", 0, &TERM_cmdListHead);
TERM_addCommand(CMD_cat, "cat", "cat... meow!", 0, &TERM_cmdListHead);
TERM_addCommand(CMD_echo, "echo", "echo echo", 0, &TERM_cmdListHead);
iotop_stat_ptr(&ConnectionStats);
streamRx = xStreamBufferCreate(STREAM_SIZE,1);
term = TERM_createNewHandle(UART_termPrint, 0, 1, &TERM_cmdListHead, 0, "root");
xTaskCreate(Term_task, "Term", configMINIMAL_STACK_SIZE + 500, term, tskIDLE_PRIORITY + 2, NULL);
}
void COMMS_statsHandler(void * params){
while(1){
ConnectionStats.rxDataRateLast = ConnectionStats.rxBytesLast * 2;
ConnectionStats.rxBytesLast = 0;
ConnectionStats.rxDataRateAVG = ((ConnectionStats.rxDataRateAVG * 97) + (ConnectionStats.rxDataRateLast * 3)) / 100;
ConnectionStats.txDataRateLast = ConnectionStats.txBytesLast * 2;
ConnectionStats.txBytesLast = 0;
ConnectionStats.txDataRateAVG = ((ConnectionStats.txDataRateAVG * 97) + (ConnectionStats.txDataRateLast * 3)) / 100;
ConnectionStats.rxPacketRateLast = (ConnectionStats.rxPacketsTotal - ConnectionStats.rxPacketsLast) * 2;
ConnectionStats.rxPacketsLast = ConnectionStats.rxPacketsTotal;
ConnectionStats.rxPacketRateAVG = ((ConnectionStats.rxPacketRateAVG * 90) + (ConnectionStats.rxPacketRateLast * 10)) / 100;
ConnectionStats.txPacketRateLast = (ConnectionStats.txPacketsTotal - ConnectionStats.txPacketsLast) * 2;
ConnectionStats.txPacketsLast = ConnectionStats.txPacketsTotal;
ConnectionStats.txPacketRateAVG = ((ConnectionStats.txPacketRateAVG * 90) + (ConnectionStats.txPacketRateLast * 10)) / 100;
vTaskDelay(pdMS_TO_TICKS(500));
}
}
void COMMS_udpDataHandler(void * params){
int32_t receivedDataLength;
uint8_t * udpData = pvPortMalloc(COMMS_UDP_BUFFER_SIZE);
struct freertos_sockaddr dataPort;
//set up the socket for the data
dataSocket = FreeRTOS_socket(FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP);
configASSERT( dataSocket != FREERTOS_INVALID_SOCKET );
dataPort.sin_port = FreeRTOS_htons(COMMS_DATA_PORT);
FreeRTOS_bind( dataSocket, &dataPort, sizeof( dataPort ) );
while(1){
receivedDataLength = FreeRTOS_recvfrom(dataSocket, udpData, COMMS_UDP_BUFFER_SIZE, 0, &lastClient, &clientLength);
//check if we have received data or are here because of a timeout
if(receivedDataLength > 0){
//do a quick check on the received data. If it is a valid min frame and has the transport bit set we can immediately forward it without checking anything
uint16_t length = min_checkUDPFrame(udpData);
ConnectionStats.rxPacketsTotal++;
ConnectionStats.rxBytesLast += receivedDataLength;
if(UART_bootloader==pdFALSE){
if(length <= MAX_PAYLOAD){
UART_queBuffer(udpData, receivedDataLength, 1);
LED_ethPacketReceivedHook();
udpData = pvPortMalloc(COMMS_UDP_BUFFER_SIZE);
}else if(length == MIN_NON_TRANSPORT_FRAME){
//if it is a non transport min frame we have to deal with it properly
min_poll(COMMS_UDP, udpData, receivedDataLength);
}else{
//we have received an invalid min frame
UART_printDebug("Invalid MIN frame received\r\n");
}
}
}
}
}
void COMMS_udpDiscoverHandler(void * params){
int32_t receivedDataLength;
uint8_t * udpData = pvPortMalloc(COMMS_UDP_BUFFER_SIZE);
struct freertos_sockaddr dataPort;
Socket_t discoverySocet;
struct freertos_sockaddr discoverClient;
uint32_t dClientLength = sizeof(discoverClient);
//set up the socket for the data
discoverySocet = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_DGRAM, FREERTOS_IPPROTO_UDP );
configASSERT( discoverySocet != FREERTOS_INVALID_SOCKET );
dataPort.sin_port = FreeRTOS_htons(COMMS_DISCOVER_PORT);
FreeRTOS_bind( discoverySocet, &dataPort, sizeof( dataPort ) );
while(1){
receivedDataLength = FreeRTOS_recvfrom(discoverySocet, udpData, COMMS_UDP_BUFFER_SIZE, 0, &discoverClient, &dClientLength);
//check if we have received data or are here because of a timeout
if(receivedDataLength == sizeof(FIND_queryString)){
if(memcmp(udpData, FIND_queryString, sizeof(FIND_queryString)) == 0){
ConnectionStats.findPacketsTotal ++;
uint8_t * response = pvPortMalloc(FIND_MAX_RESPONSE_SIZE);
uint8_t * IPAdrr = pvPortMalloc(16);
const uint8_t * MACAdrr = FreeRTOS_GetMACAddress();
uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
FreeRTOS_GetAddressConfiguration(&ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress);
FreeRTOS_inet_ntoa(ulIPAddress, IPAdrr);
uint16_t length = snprintf(response,FIND_MAX_RESPONSE_SIZE, "FIND=1;IP=%s;HWADDR=%02x:%02x:%02x:%02x:%02x:%02x;DeviceName=%s;SN=%s;deviceType=UD3;", IPAdrr, MACAdrr[0], MACAdrr[1], MACAdrr[2], MACAdrr[3], MACAdrr[4], MACAdrr[5], UD3_name, UD3_sn);
FreeRTOS_sendto(dataSocket, response, length, 0, &discoverClient, dClientLength);
vPortFree(response);
vPortFree(IPAdrr);
}
}
}
}
//send data to the last client we got a packet from
void COMMS_sendDataToLastClient(uint8_t * data, uint16_t dataLength){
if(!ETH_CheckLinkUp()) return;
FreeRTOS_sendto(dataSocket, data, dataLength, 0, &lastClient, clientLength);
}
//quickly check if a received UDP packet is a min transport frame, a normal min frame or something entirely different (This does mean that min frames have to be aligned to a single UDP packet)
uint16_t min_checkUDPFrame(uint8_t * data){
if(data[0] != 0xaa || data[1] != 0xaa || data[2] != 0xaa) return MIN_FRAME_INVALID;
if(data[3] & 0x80U) return data[8]; //return length if the frame needs to be forwarded
return MIN_NON_TRANSPORT_FRAME;
}
void send_and_free(uint8_t * min_payload, uint16_t len_payload){
ConnectionStats.txPacketsTotal++;
ConnectionStats.txBytesLast += len_payload;
//we got a valid transport frame from the UD3, so we send it on to the PC
COMMS_sendDataToLastClient(min_payload, len_payload);
LED_minPacketReceivedHook();
vPortFree(min_payload); //the data is copied by the send function so we can free it here
}
//handle incoming MIN frames (except for transport frames from UDP as those are forwarded immediately)
void min_application_handler(uint8_t min_id, uint8_t * min_payload, uint16_t len_payload, void * port){
if(!deviceReady) if(startupMINHandler(min_id, min_payload, len_payload, port)) return;
if(min_id == 0xff){ //frame needs to be forwarded
if(port == COMMS_UDP){
//we should never actually get here
UART_queBuffer(min_payload, len_payload, 1);
LED_ethPacketReceivedHook();
}else if(port == COMMS_UART){
//we got a valid transport frame from the UD3, so we send it on to the PC
send_and_free(min_payload, len_payload);
}
}else{
switch(min_id){
case MIN_ID_DEBUG:
xStreamBufferSend(streamRx, min_payload, len_payload,2);
break;
default:
if(port == COMMS_UDP){
min_send_frame(COMMS_UART, min_id, min_payload, len_payload);
}else if(port == COMMS_UART){
min_send_frame(COMMS_UDP, min_id, min_payload, len_payload);
}
}
}
}
void Term_task(void *pvParameters){
TERMINAL_HANDLE * termPtr = pvParameters;
uint8_t c;
while(1){
xStreamBufferReceive(streamRx, &c,sizeof(c), portMAX_DELAY);
TERM_processBuffer(&c, sizeof(c), termPtr);
}
}
uint32_t min_time_ms(){
return (xTaskGetTickCount() * portTICK_RATE_MS);
}
uint16_t min_tx_space(void * port){
return xPortGetFreeHeapSize();
}
void min_tx_byte(void * port, uint8_t byte){
struct min_context * ctx = port;
if(ctx->tx_data_buffer == NULL) return;
if(ctx->tx_data_position<ctx->tx_data_buffer_size){
ctx->tx_data_buffer[ctx->tx_data_position] = byte;
ctx->tx_data_position++;
}
}
void min_tx_start(void * port, uint16_t on_wire_len){
struct min_context * ctx = port;
if(ctx->tx_data_buffer) return;
ctx->tx_data_buffer = pvPortMalloc(on_wire_len);
ctx->tx_data_buffer_size = on_wire_len;
}
void min_tx_finished(void * port){
struct min_context * ctx = port;
if(ctx->tx_data_buffer == NULL) return;
if(port == COMMS_UART){
UART_queBuffer(ctx->tx_data_buffer, ctx->tx_data_position, 1);
}else{
COMMS_sendDataToLastClient(ctx->tx_data_buffer, ctx->tx_data_position);
vPortFree(ctx->tx_data_buffer);
}
ctx->tx_data_position = 0;
ctx->tx_data_buffer = 0;
}
void COMMS_pushEvent(Event evt){
min_send_frame(COMMS_UART, MIN_ID_EVENT, (uint8_t *) &evt, sizeof(Event));
}
void COMMS_eventHook(Event evt){
char cBuffer[16];
uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
COMMS_pushEvent(evt);
char buffer[50];
switch(evt){
case ETH_INIT_FAIL:
COMMS_pushAlarm(ALARM_PRIO_CRITICAL, "Fibernet initialization failed: LAN9250 could not be initialized, retrying", ALARM_NO_VALUE);
TERM_printDebug(term, "LAN9250 initialization failed!\r\n");
break;
case ETH_INIT_DONE:
COMMS_pushAlarm(ALARM_PRIO_INFO, "LAN9250 initialization complete", ALARM_NO_VALUE);
TERM_printDebug(term, "LAN9250 initialized\r\n");
break;
case ETH_LINK_UP:
TERM_printDebug(term, "link up\r\n");
break;
case ETH_LINK_DOWN:
TERM_printDebug(term, "link down\r\n");
break;
case ETH_DHCP_SUCCESS:
FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
char * string;
if(dhcpEnable){
string = "DHCP";
}else{
string = "IP";
}
snprintf(buffer,sizeof(buffer),"%s Successful (IP=%s)",string, cBuffer);
COMMS_pushAlarm(ALARM_PRIO_INFO, buffer, ALARM_NO_VALUE);
TERM_printDebug(term, "%s Successful (IP=%s)\r\n",string, cBuffer);
break;
case ETH_DHCP_FAIL:
FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
TERM_printDebug(term, "DHCP Failed - reverted to defaults (IP=%s)\r\n", cBuffer);
break;
case FS_CARD_CONNECTED:
TERM_printDebug(term, "SD card connected\r\n");
break;
case FS_CARD_REMOVED:
TERM_printDebug(term, "SD card removed\r\n");
break;
case FTP_CLIENT_CONNECTED:
TERM_printDebug(term, "FTP client connected\r\n");
break;
case FTP_CLIENT_DISCONNECTED:
TERM_printDebug(term, "FTP client disconnected\r\n");
break;
default:
UART_print("unknown Event received\r\n");
}
}
void COMMS_pushAlarm(uint8_t level, char* message, int32_t value){
uint8_t * pl = pvPortMalloc(sizeof(MIN_ALARM_PAYLOAD_DESCRIPTOR) + strlen(message) + 1);
memset(pl, 0, sizeof(MIN_ALARM_PAYLOAD_DESCRIPTOR) + strlen(message) + 1);
MIN_ALARM_PAYLOAD_DESCRIPTOR * alarmPayload = (MIN_ALARM_PAYLOAD_DESCRIPTOR *) pl;
char * alarmMessage = (char *) (&pl[sizeof(MIN_ALARM_PAYLOAD_DESCRIPTOR)]);
alarmPayload->level = level;
alarmPayload->value = value;
strcpy(alarmMessage, message);
min_send_frame(COMMS_UART, MIN_ID_ALARM, pl, sizeof(MIN_ALARM_PAYLOAD_DESCRIPTOR) + strlen(message) + 1);
vPortFree(pl);
}
//WARNING: UNSAFE, NEEDS TO BE RE-CODED!
void COMMS_dumpPacket(uint8_t * data, uint16_t length){
return;
UART_print("\r\nPacket dump:\r\n");
char * buff = pvPortMalloc(length * 7);
uint16_t currPos = 0;
uint16_t nls = 0;
for(;currPos < length; currPos++){
sprintf(&buff[(currPos*5)+nls], "%s0x%02x ", data[currPos], (currPos % 16 == 0) ? "\r\n" : ((currPos % 8 == 0) ? " " : ""));
if(currPos % 16 == 0) nls += 2; else if(currPos % 8 == 0) nls += 1;
}
min_send_frame(COMMS_UART, MIN_ID_DEBUG, buff, (currPos*5)+nls);
vPortFree(buff);
UART_print("\r\n---------\r\n");
}
uint8_t CMD_testAlarm(TERMINAL_HANDLE * handle, uint8_t argCount, char ** args){
uint8_t currArg = 0;
for(;currArg<argCount; currArg++){
if(strcmp(args[currArg], "-?") == 0){
ttprintf("sends a test alarm with a value\r\nUsage:\r\n\ttestAlarm [alarm priority] [alarm text] ([alarm value])");
return TERM_CMD_EXIT_SUCCESS;
}
}
if(argCount < 2) return TERM_CMD_EXIT_ERROR;
uint8_t level = atoi(args[0]);
uint32_t value = ALARM_NO_VALUE;
if(argCount == 3){
value = atoi(args[2]);
}
if(argCount == 2) COMMS_pushAlarm(level, args[1], ALARM_NO_VALUE);
if(argCount == 3) COMMS_pushAlarm(level, args[1], atoi(args[2]));
ttprintf("Sent alarm: priority %d, text \"%s\", value %d%s (lenghth = %d)\r\n", level, args[1], value, (value == ALARM_NO_VALUE) ? " (no value)" : "", sizeof(MIN_ALARM_PAYLOAD_DESCRIPTOR) + strlen(args[1]) + 1);
return TERM_CMD_EXIT_SUCCESS;
}
void DHCP_enable(uint8_t active){
dhcpEnable = active;
}
uint8_t DHCP_enabled(){
return dhcpEnable;
}
eDHCPCallbackAnswer_t xApplicationDHCPHook( eDHCPCallbackPhase_t eDHCPPhase, uint32_t ulIPAddress ){
eDHCPCallbackAnswer_t eReturn;
uint32_t ulStaticIPAddress, ulStaticNetMask;
/* This hook is called in a couple of places during the DHCP process, as
identified by the eDHCPPhase parameter. */
switch( eDHCPPhase ){
case eDHCPPhasePreDiscover :
/* A DHCP discovery is about to be sent out. eDHCPContinue is
returned to allow the discovery to go out.
If eDHCPUseDefaults had been returned instead then the DHCP process
would be stopped and the statically configured IP address would be
used.
If eDHCPStopNoChanges had been returned instead then the DHCP
process would be stopped and whatever the current network
configuration was would continue to be used. */
if(dhcpEnable){
eReturn = eDHCPContinue;
}else{
eReturn = eDHCPStopNoChanges;
}
break;
case eDHCPPhasePreRequest :
/* An offer has been received from the DHCP server, and the offered
IP address is passed in the ulIPAddress parameter. Convert the
offered and statically allocated IP addresses to 32-bit values. */
/* The sub-domains don?t match, so continue with the DHCP
process so the offered IP address is used. */
eReturn = eDHCPContinue;
break;
default :
/* Cannot be reached, but set eReturn to prevent compiler warnings
where compilers are disposed to generating one. */
eReturn = eDHCPContinue;
break;
}
return eReturn;
}
void help_ifconfig(TERMINAL_HANDLE * handle){
ttprintf("\teth0 [ip]\r\n");
ttprintf("\tnetmask [netmask]\r\n");
ttprintf("\tgw [netmask]\r\n");
ttprintf("\tdhcp\r\n");
}
uint8_t CMD_ifconfig(TERMINAL_HANDLE * handle, uint8_t argCount, char ** args){
uint8_t currArg = 0;
uint32_t ip;
for(;currArg<argCount; currArg++){
if(strcmp(args[currArg], "-?") == 0){
help_ifconfig(handle);
return TERM_CMD_EXIT_SUCCESS;
}
if(strcmp(args[currArg], "eth0") == 0){
if(++currArg<argCount){
dhcpEnable = pdFALSE;
ip=FreeRTOS_inet_addr(args[currArg]);
if(ip){
FreeRTOS_SetIPAddress(ip);
}else{
help_ifconfig(handle);
return TERM_CMD_EXIT_SUCCESS;
}
}else{
help_ifconfig(handle);
return TERM_CMD_EXIT_SUCCESS;
}
}
if(strcmp(args[currArg], "netmask") == 0){
if(++currArg<argCount){
dhcpEnable = pdFALSE;
ip=FreeRTOS_inet_addr(args[currArg]);
if(ip){
FreeRTOS_SetNetmask(ip);
}else{
help_ifconfig(handle);
return TERM_CMD_EXIT_SUCCESS;
}
}else{
help_ifconfig(handle);
return TERM_CMD_EXIT_SUCCESS;
}
}
if(strcmp(args[currArg], "gw") == 0){
if(++currArg<argCount){
dhcpEnable = pdFALSE;
ip=FreeRTOS_inet_addr(args[currArg]);
if(ip){
FreeRTOS_SetGatewayAddress(ip);
}else{
help_ifconfig(handle);
return TERM_CMD_EXIT_SUCCESS;
}
}else{
help_ifconfig(handle);
return TERM_CMD_EXIT_SUCCESS;
}
}
if(strcmp(args[currArg], "dhcp") == 0){
dhcpEnable = pdTRUE;
vDHCPProcess(pdTRUE);
}
}
uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
char buff[16];
FreeRTOS_GetAddressConfiguration(&ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress);
ttprintf("eth0\r\x1b[%dCLink type: Ethernet HWaddr %02x:%02x:%02x:%02x:%02x:%02x\r\n", 7, MAC_ADDRESS[0], MAC_ADDRESS[1], MAC_ADDRESS[2], MAC_ADDRESS[3], MAC_ADDRESS[4], MAC_ADDRESS[5]);
FreeRTOS_inet_ntoa(ulIPAddress, buff);
ttprintf("\x1b[%dCinet addr: %s ", 7, buff);
FreeRTOS_inet_ntoa(ulNetMask, buff);
ttprintf("Mask: %s\r\n", buff);
FreeRTOS_inet_ntoa(ulGatewayAddress, buff);
ttprintf("\x1b[%dCgateway: %s ", 7, buff);
FreeRTOS_inet_ntoa(ulDNSServerAddress, buff);
ttprintf("dns: %s\r\n\n", buff);
return TERM_CMD_EXIT_SUCCESS;
}