1
1
#include " CEspControl.h"
2
- #include " CNetIf.h"
3
2
#include < string>
4
3
#include < vector>
5
4
@@ -23,8 +22,6 @@ using namespace std;
23
22
24
23
#define SerialESP Serial5
25
24
26
- extern int esp_host_spi_init ();
27
-
28
25
void getESPDebugLog ();
29
26
int displayMenu ();
30
27
void makeRequest (int req);
@@ -33,12 +30,15 @@ string prompt(string p);
33
30
34
31
const char mac_address[] = " aa:bb:cc:dd:ee:ff" ;
35
32
33
+ bool wifiHwInitialized = false ;
36
34
37
35
38
36
int initEvent (CCtrlMsgWrapper *resp) {
39
37
if (resp->isInitEventReceived () == ESP_CONTROL_OK) {
40
38
Serial.println (" [EVENT !!!!]: Init event received" );
39
+ wifiHwInitialized = true ;
41
40
}
41
+ return ESP_CONTROL_OK;
42
42
}
43
43
44
44
int stationDisconnectionEvent (CCtrlMsgWrapper *resp) {
@@ -47,6 +47,7 @@ int stationDisconnectionEvent(CCtrlMsgWrapper *resp) {
47
47
Serial.print (" [EVENT !!!!]: C33 was disconnected from AP for reason " );
48
48
Serial.println (reason);
49
49
}
50
+ return ESP_CONTROL_OK;
50
51
}
51
52
52
53
int disconnectionFromSofApEvent (CCtrlMsgWrapper *resp) {
@@ -56,6 +57,7 @@ int disconnectionFromSofApEvent(CCtrlMsgWrapper *resp) {
56
57
Serial.print (MAC);
57
58
Serial.println (" disconnected from ESP32 Soft AP" );
58
59
}
60
+ return ESP_CONTROL_OK;
59
61
}
60
62
61
63
@@ -65,6 +67,7 @@ int heartBeatEvent(CCtrlMsgWrapper *resp) {
65
67
Serial.print (" [EVENT !!!!]: heart beat n " );
66
68
Serial.println (hb);
67
69
}
70
+ return ESP_CONTROL_OK;
68
71
}
69
72
70
73
@@ -83,10 +86,19 @@ void setup() {
83
86
CEspControl::getInstance ().listenForDisconnectionFromSoftApEvent (disconnectionFromSofApEvent);
84
87
85
88
86
-
89
+ int err = CEspControl::getInstance ().initSpiDriver ();
90
+ if (err != 0 ) {
91
+ Serial.print (" Error initSpiDriver err " );
92
+ Serial.println (err);
93
+ } else {
94
+ Serial.println (" initSpiDriver OK" );
95
+ }
96
+ while (!wifiHwInitialized) {
97
+ CEspControl::getInstance ().communicateWithEsp ();
98
+ delay (100 );
99
+ }
87
100
88
101
Serial.println (" STARTING PROGRAM" );
89
- delay (1000 );
90
102
}
91
103
92
104
@@ -685,7 +697,7 @@ int displayMenu() {
685
697
cmd_acquired = true ;
686
698
rv = stoi (c);
687
699
}
688
- else {
700
+ else if (ch >= ' 0 ' && ch <= ' 9 ' ) {
689
701
c += ch;
690
702
}
691
703
}
0 commit comments