forked from arduino/ArduinoCore-renesas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathESP32_TEST.ino
715 lines (608 loc) · 21.6 KB
/
ESP32_TEST.ino
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
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
#include "CEspControl.h"
#include <string>
#include <vector>
using namespace std;
/* GPIO_LOCAL C33
- 0. P010
- 1. P207
- 2. P803 - D100 - DOWNLOAD - IO9 - DATA_READY - TEST POINT tra 2 e 3
- 3. P804 - D101 - RESET
- 4. P806 - D102 - ACK - IO5 - HANDSHAKE - ESP MDTI
- 5. P504
- 6. P906
CHIP SELECT SPI
P104 - D104
*/
//#define ENABLE_ESP_LOG
#define SerialESP Serial5
void getESPDebugLog();
int displayMenu();
void makeRequest(int req);
string prompt(string p);
const char mac_address[] = "aa:bb:cc:dd:ee:ff";
bool wifiHwInitialized = false;
int initEvent(CCtrlMsgWrapper *resp) {
if(resp->isInitEventReceived() == ESP_CONTROL_OK) {
Serial.println("[EVENT !!!!]: Init event received");
wifiHwInitialized = true;
}
return ESP_CONTROL_OK;
}
int stationDisconnectionEvent(CCtrlMsgWrapper *resp) {
int reason;
if(resp->isStationDisconnectionEventReceived(reason) == ESP_CONTROL_OK) {
Serial.print("[EVENT !!!!]: C33 was disconnected from AP for reason ");
Serial.println(reason);
}
return ESP_CONTROL_OK;
}
int disconnectionFromSofApEvent(CCtrlMsgWrapper *resp) {
char MAC[18];
if(resp->isDisconnectionFromSoftApReceived(MAC,18) == ESP_CONTROL_OK) {
Serial.print("[EVENT !!!!]: the station with MAC address ");
Serial.print(MAC);
Serial.println(" disconnected from ESP32 Soft AP");
}
return ESP_CONTROL_OK;
}
int heartBeatEvent(CCtrlMsgWrapper *resp) {
int hb;
if(resp->isHeartBeatEventReceived(hb) == ESP_CONTROL_OK) {
Serial.print("[EVENT !!!!]: heart beat n ");
Serial.println(hb);
}
return ESP_CONTROL_OK;
}
/* -------------------------------------------------------------------------- */
/* SETUP */
/* -------------------------------------------------------------------------- */
void setup() {
Serial.begin(115200);
SerialESP.begin(115200);
while(!Serial) {
}
CEspControl::getInstance().listenForInitEvent(initEvent);
CEspControl::getInstance().listenForStationDisconnectEvent(stationDisconnectionEvent);
CEspControl::getInstance().listenForDisconnectionFromSoftApEvent(disconnectionFromSofApEvent);
int err = CEspControl::getInstance().initSpiDriver();
if (err != 0) {
Serial.print("Error initSpiDriver err ");
Serial.println(err);
} else {
Serial.println("initSpiDriver OK");
}
while (!wifiHwInitialized) {
CEspControl::getInstance().communicateWithEsp();
delay(100);
}
Serial.println("STARTING PROGRAM");
}
/* -------------------------------------------------------------------------- */
/* SETUP */
/* -------------------------------------------------------------------------- */
void loop() {
#ifdef ENABLE_ESP_LOG
getESPDebugLog();
#endif
int request = displayMenu();
makeRequest(request);
}
/* ##########################################################################
# GLOBAL APPLICATION VARIABLES #
########################################################################## */
/* -------------------------------------------------------------------------- */
bool connected_to_access_point = false;
vector<AccessPoint_t> access_point_list;
WifiMode_t status_wifi_mode = WIFI_MODE_NONE;
/* -------------------------------------------------------------------------- */
/* ##########################################################################
# PRINTING FUNCTION #
########################################################################## */
/* -------------------------------------------------------------------------- */
void printResult(int res, const char* desc, const char *val) {
/* -------------------------------------------------------------------------- */
if(res == ESP_CONTROL_WRONG_REQUEST_INVALID_MSG) {
Serial.println("*** [WARNING]: request NOT sent, invalid request");
}
else if(res == ESP_CONTROL_OK) {
Serial.print("--- [OK]: ");
if(desc != nullptr) {
Serial.print(desc);
Serial.print(" ");
}
if(val != nullptr)
Serial.println(val);
}
else {
Serial.print("!!! [ERROR]: ");
if(desc != nullptr) {
Serial.print(desc);
Serial.print(" ");
}
}
}
/* -------------------------------------------------------------------------- */
void printIndex(unsigned int i, const char* desc) {
/* -------------------------------------------------------------------------- */
Serial.print(i);
Serial.print(". ");
Serial.print(desc);
Serial.print(": ");
}
/* -------------------------------------------------------------------------- */
void printBufferAsString(uint8_t *b, bool ret) {
/* -------------------------------------------------------------------------- */
Serial.print((char *)b);
if(ret) {
Serial.println();
}
}
/* -------------------------------------------------------------------------- */
void printBuffer(uint8_t *b, int len, bool ret) {
/* -------------------------------------------------------------------------- */
for(int i = 0; i < len; i++) {
Serial.print(*(b + i));
}
if(ret) {
Serial.println();
}
}
/* -------------------------------------------------------------------------- */
void printAccessPointList(vector<AccessPoint_t>& list) {
/* -------------------------------------------------------------------------- */
for(unsigned int i = 0; i < list.size(); i++) {
printIndex(i,"SSID");
printBufferAsString(list[i].ssid, true);
printIndex(i,"BSSID");
printBufferAsString(list[i].bssid, true);
printIndex(i,"RSSI");
Serial.println(list[i].rssi);
printIndex(i,"Channel");
Serial.println(list[i].channel);
printIndex(i,"Encryption mode:");
Serial.println(list[i].encryption_mode);
Serial.println();
}
}
/* -------------------------------------------------------------------------- */
void printAccessPointCfg(WifiApCfg_t &cfg) {
/* -------------------------------------------------------------------------- */
Serial.print("SSID: ");
printBufferAsString(cfg.ssid, true);
Serial.print("BSSID: ");
printBufferAsString(cfg.bssid, true);
Serial.print("PSW: ");
printBufferAsString(cfg.pwd, true);
Serial.print("status: ");
printBufferAsString((uint8_t *)cfg.status, true);
Serial.print("MAC Address: ");
printBufferAsString((uint8_t *)cfg.out_mac, true);
Serial.print("WPA3 supported: ");
if(cfg.is_wpa3_supported) {
Serial.println("Yes");
}
else {
Serial.println("No");
}
Serial.print("RSSI: ");
Serial.println(cfg.rssi);
Serial.print("Channel: ");
Serial.println(cfg.channel);
Serial.print("Encryption Mode: ");
Serial.println(cfg.encryption_mode);
Serial.print("Listen interval: ");
Serial.println(cfg.listen_interval);
}
/* -------------------------------------------------------------------------- */
void printSoftAccessPointCfg(SoftApCfg_t &cfg) {
/* -------------------------------------------------------------------------- */
Serial.print("SSID: ");
printBufferAsString(cfg.ssid, true);
Serial.print("PSW: ");
printBufferAsString(cfg.pwd, true);
Serial.print("Channel: ");
Serial.println(cfg.channel);
Serial.print("Encryption mode: ");
Serial.println(cfg.encryption_mode);
Serial.print("Max connections: ");
Serial.println(cfg.max_connections);
Serial.print("SSID hidden: ");
if(cfg.ssid_hidden) {
Serial.println("YES");
}
else {
Serial.println("No");
}
Serial.print("Bandwitdh: ");
Serial.println((int)cfg.bandwidth);
Serial.print("MAC OUT: ");
Serial.println(cfg.out_mac);
}
/* -------------------------------------------------------------------------- */
void printConnectedStationList(vector<WifiConnectedSta_t>& list) {
/* -------------------------------------------------------------------------- */
for(unsigned int i = 0; i < list.size(); i++) {
printIndex(i,"SSID");
printBufferAsString(list[i].bssid, true);
printIndex(i,"RSSI");
Serial.println(list[i].rssi);
Serial.println();
}
}
/* ##########################################################################
# WIFI FUNCTIONS #
########################################################################## */
/* -------------------------------------------------------------------------- */
void connectAccessPoint() {
/* -------------------------------------------------------------------------- */
if(access_point_list.size() == 0) {
Serial.println("***[WARNING]: Access point list is empty, please first read available access points");
}
else {
printAccessPointList(access_point_list);
string ap_str = prompt("Choose Access Point from the previous list : ");
if(stoi(ap_str) < 0 || stoi(ap_str) >= access_point_list.size() ) {
Serial.println("[ERROR]: Invalid choice");
return;
}
string pwd = prompt("Enter the password: ");
int i = stoi(ap_str);
Serial.println(">>> [APP]: Connecting to Access Point");
WifiApCfg_t ap;
memcpy(ap.ssid,access_point_list[i].ssid,SSID_LENGTH);
memcpy(ap.pwd,pwd.c_str(),pwd.size());
memcpy(ap.bssid,access_point_list[i].bssid,BSSID_LENGTH);
ap.channel = access_point_list[i].channel;
ap.encryption_mode = access_point_list[i].encryption_mode;
int res = CEspControl::getInstance().connectAccessPoint(ap);
if(ESP_CONTROL_OK == res) {
Serial.println("<<< [APP OK]: Connected to the selected access point, configuration");
printAccessPointCfg(ap);
connected_to_access_point = true;
}
else {
Serial.println("<<< [APP ERROR]: Unable to connect to selected access point");
}
}
}
/* -------------------------------------------------------------------------- */
void getAccessPointCfg() {
/* -------------------------------------------------------------------------- */
if(!connected_to_access_point) {
Serial.println("***[WARNING]: It seems that the device is currently not connected to any access point");
}
WifiApCfg_t ap_out;
int res = CEspControl::getInstance().getAccessPointConfig(ap_out);
if(ESP_CONTROL_OK == res) {
Serial.println("<<< [APP OK]: Access point configuration is: ");
printAccessPointCfg(ap_out);
}
else {
Serial.println("<<< [APP ERROR]: Unable to get access point configuration");
}
}
/* -------------------------------------------------------------------------- */
void disconnectAccessPoint() {
/* -------------------------------------------------------------------------- */
if(!connected_to_access_point) {
Serial.println("***[WARNING]: It seems that the device is currently not connected to any access point");
}
int res = CEspControl::getInstance().disconnectAccessPoint();
if(ESP_CONTROL_OK == res) {
Serial.println("<<< [APP OK]: Disconnected from access point");
connected_to_access_point = false;
}
else {
Serial.println("<<< [APP ERROR]: Unable to disconnect from access point");
}
}
/* -------------------------------------------------------------------------- */
void getWifiMacAddress() {
/* -------------------------------------------------------------------------- */
WifiMac_t MAC;
MAC.mode = status_wifi_mode;
Serial.println(">>> [APP]: Sending request GET MAC ADDRESS");
int res = CEspControl::getInstance().getWifiMacAddress(MAC);
printResult(res, "get MAC Address", MAC.mac);
}
/* -------------------------------------------------------------------------- */
void setWifiMacAddress() {
/* -------------------------------------------------------------------------- */
string mac = prompt("Enter the new MAC address:");
WifiMac_t MMM;
MMM.mode = status_wifi_mode;
memcpy(MMM.mac,mac.c_str(), mac.size());
Serial.println(">>> [APP]: Sending request SET MAC ADDRESS");
int res = CEspControl::getInstance().setWifiMacAddress(MMM);
printResult(res, "set MAC Address", mac.c_str());
}
/* -------------------------------------------------------------------------- */
void getWifiMode() {
/* -------------------------------------------------------------------------- */
Serial.println(">>> [APP]: Sending request GET WIFI MODE");
int res = CEspControl::getInstance().getWifiMode(status_wifi_mode);
printResult(res, "get Wifi Mode", to_string(status_wifi_mode).c_str());
}
/* -------------------------------------------------------------------------- */
void setWifiMode() {
/* -------------------------------------------------------------------------- */
string mode_str = prompt("Enter the new Wifi mode 1. none / 2.sta / 3.ap / 4.apsta: ");
int mode = stoi(mode_str);
Serial.print(">>> [APP]: Sending request SET WIFI MODE to ");
Serial.print(mode);
int res = CEspControl::getInstance().setWifiMode(WifiMode_t (mode - 1));
if(res == ESP_CONTROL_OK) {
status_wifi_mode = (WifiMode_t )mode;
}
printResult(res, "set Wifi Mode", to_string(status_wifi_mode).c_str());
}
/* -------------------------------------------------------------------------- */
void getAccessPointList() {
/* -------------------------------------------------------------------------- */
Serial.println(">>> [APP]: Sending request GET ACCESS POINT LIST");
int res = CEspControl::getInstance().getAccessPointScanList(access_point_list);
if(ESP_CONTROL_OK == res) {
Serial.println("<<< [APP OK]: Available access points");
printAccessPointList(access_point_list);
}
else {
Serial.println("<<< [APP ERROR]: Unable to get access point list");
}
}
SoftApCfg_t cfg;
/* -------------------------------------------------------------------------- */
void startSoftAccessPoint() {
/* -------------------------------------------------------------------------- */
uint8_t mySSID[] = "TestAP";
memset(cfg.ssid, 0x00, SSID_LENGTH);
memcpy(cfg.ssid, mySSID, sizeof(mySSID));
uint8_t myPSW[] = "123456789";
memset(cfg.pwd, 0x00, PASSWORD_LENGTH);
memcpy(cfg.pwd, myPSW, sizeof(myPSW));
cfg.channel = 1;
cfg.encryption_mode = WIFI_AUTH_WPA2_PSK;
cfg.max_connections = 2;
cfg.ssid_hidden = 0;
cfg.bandwidth = WIFI_BW_HT20;
Serial.println(">>> [APP]: Sending request START SOFT ACCESS POINT");
int res = CEspControl::getInstance().startSoftAccessPoint(cfg);
if(ESP_CONTROL_OK == res) {
Serial.println("<<< [APP OK]: SOFT ACCESS POINT STARTED");
Serial.print(" MAC ADDRESS: ");
Serial.println((char*)cfg.out_mac);
}
else {
Serial.println("<<< [APP ERROR]: START SOFT ACCESS POINT");
}
}
SoftApCfg_t cfg_1;
/* -------------------------------------------------------------------------- */
void getSoftAccessPointCfg() {
/* -------------------------------------------------------------------------- */
Serial.println(">>> [APP]: Sending request get SOFT ACCESS POINT CONFIGURATION");
int res = CEspControl::getInstance().getSoftAccessPointConfig(cfg_1);
if(ESP_CONTROL_OK == res) {
Serial.println("<<< [APP OK]: GET SOFT ACCESS POINT CONFIGURATION");
printSoftAccessPointCfg(cfg_1);
}
else {
Serial.println("<<< [APP ERROR]: UNABLE TO GET ACCESS POINT CONFIGURATION");
}
}
/* -------------------------------------------------------------------------- */
void stopSoftAccessPoint() {
/* -------------------------------------------------------------------------- */
Serial.println(">>> [APP]: Sending request STOP SOFT ACCESS POINT");
int res = CEspControl::getInstance().stopSoftAccessPoint();
if(ESP_CONTROL_OK == res) {
Serial.println("<<< [APP OK]: SOFT ACCESS POINT STOPPED");
}
else {
Serial.println("<<< [APP ERROR]: UNABLE TO STOP ACCESS POINT");
}
}
vector<WifiConnectedSta_t> connected_stations;
/* -------------------------------------------------------------------------- */
void getConnectedStationList() {
/* -------------------------------------------------------------------------- */
Serial.println(">>> [APP]: Sending request GET CONNECTED STATION LIST");
int res = CEspControl::getInstance().getSoftConnectedStationList(connected_stations);
if(ESP_CONTROL_OK == res) {
Serial.println("<<< [APP OK]: Connected Station list");
printConnectedStationList(connected_stations);
}
else {
Serial.println("<<< [APP ERROR]: UNABLE TO GET CONNECTED STATION LIST");
}
}
WifiVendorSoftApIe_t vendor_ie;
/* -------------------------------------------------------------------------- */
void setSoftApVendorIe() {
/* -------------------------------------------------------------------------- */
vendor_ie.enable = true;
vendor_ie.type = WIFI_VND_IE_TYPE_BEACON;
vendor_ie.idx = WIFI_VND_IE_ID_0;
vendor_ie.vnd_ie.element_id = 0xDD;
vendor_ie.vnd_ie.length = 4;
vendor_ie.vnd_ie.vendor_oui[0] = 0x0A;
vendor_ie.vnd_ie.vendor_oui[1] = 0x0B;
vendor_ie.vnd_ie.vendor_oui[2] = 0x0C;
vendor_ie.vnd_ie.vendor_oui_type = 0;
vendor_ie.vnd_ie.payload_len = 0;
vendor_ie.vnd_ie.payload = nullptr;
Serial.println(">>> [APP]: Sending request SET SOFTAP VENDOR IE");
int res = CEspControl::getInstance().setSoftAccessPointVndIe(vendor_ie);
if(ESP_CONTROL_OK == res) {
Serial.println("<<< [APP OK]: SOFTAP VENDOR IE SET");
}
else {
Serial.println("<<< [APP ERROR]: UNABLE TO SET SOFTAP VENDOR IE");
}
}
void setUpHearthBeat() {
HeartBeat_t hb;
hb.enable = 1;
hb.duration = 100;
hb.hb_num = 0;
Serial.println(">>> [APP]: Sending request Configure HEARTHBEAT");
int res = CEspControl::getInstance().configureHeartbeat(hb, heartBeatEvent);
if(ESP_CONTROL_OK == res) {
Serial.println("<<< [APP OK]: HEARTHBEAT CONFIGURED");
}
else {
Serial.println("<<< [APP ERROR]: FAILED TO CONFIGURE HEARTHBEAT");
}
}
/* ##########################################################################
# APPLICATION FUNCTIONS #
########################################################################## */
/* -------------------------------------------------------------------------- */
string prompt(string p) {
/* -------------------------------------------------------------------------- */
Serial.println(p.c_str());
string c;
bool cmd_acquired = false;
while(!cmd_acquired) {
char ch;
if(Serial.available()) {
ch = Serial.read();
if(ch == 0x0A) {
cmd_acquired = true;
return c;
}
else {
c += ch;
}
}
else {
delay(100);
}
}
return "";
}
/* -------------------------------------------------------------------------- */
void makeRequest(int req) {
/* -------------------------------------------------------------------------- */
switch(req) {
case 1:
getWifiMacAddress();
break;
case 2:
setWifiMacAddress();
break;
case 3:
getWifiMode();
break;
case 4:
setWifiMode();
break;
case 5:
getAccessPointList();
break;
case 6:
connectAccessPoint();
break;
case 7:
getAccessPointCfg();
break;
case 8:
disconnectAccessPoint();
break;
case 9:
startSoftAccessPoint();
break;
case 10:
stopSoftAccessPoint();
break;
case 11:
getConnectedStationList();
break;
case 12:
getSoftAccessPointCfg();
break;
case 13:
setSoftApVendorIe();
break;
case 14:
break;
case 15:
break;
case 16:
break;
case 17:
break;
case 18:
break;
case 19:
break;
case 21:
setUpHearthBeat();
break;
default:
Serial.println("[WARNING] Option not recognized!");
break;
}
}
/* -------------------------------------------------------------------------- */
int displayMenu() {
/* -------------------------------------------------------------------------- */
Serial.println("-----------------------------------------------------------");
Serial.println("*** ESP control test menu:");
Serial.println("- MAC ADDRESS:");
Serial.println(" 1. Get Wifi MAC address");
Serial.println(" 2. Set Wifi MAC address");
Serial.println("- Wifi Mode");
Serial.println(" 3. Get Wifi Mode");
Serial.println(" 4. Set Wifi Mode");
Serial.println("- Access point:");
Serial.println(" 5. Get Access Points list");
Serial.println(" 6. Connect to Access Point");
Serial.println(" 7. Get Access Point Configuration");
Serial.println(" 8. Disconnect Access Point");
Serial.println("- SoftAP");
Serial.println(" 9. Start SoftAP");
Serial.println(" 10. Stop SoftAP");
Serial.println(" 11. Get Connected Station List");
Serial.println(" 12. Get SoftAP Configuration");
Serial.println(" 13. Set SoftAP Vendor Configuration");
Serial.println("- Power Save:");
Serial.println(" 14. Get Power Save mode");
Serial.println(" 15. Set Power Save mode");
Serial.println("- OTA:");
Serial.println(" 16. Start OTA");
Serial.println(" 17. End OTA");
Serial.println(" 18. Write OTA");
Serial.println("- Power:");
Serial.println(" 19. Get Wifi current power");
Serial.println(" 20. Set Max Wifi power");
Serial.println("- Heartbeat:");
Serial.println(" 21. Configure hearbeat");
Serial.println();
Serial.println("Choose the option number:>");
Serial.println("-----------------------------------------------------------");
string c;
bool cmd_acquired = false;
int rv = -1;
while(!cmd_acquired) {
char ch;
if(Serial.available()) {
ch = Serial.read();
if(ch == 0x0A) {
cmd_acquired = true;
rv = stoi(c);
}
else if(ch >= '0' && ch <='9') {
c += ch;
}
}
else {
CEspControl::getInstance().communicateWithEsp();
}
}
return rv;
}
void getESPDebugLog() {
while(SerialESP.available()) {
Serial.write(SerialESP.read());
}
}