11#include " CEspControl.h"
2- #include " CNetIf.h"
32#include < string>
43#include < vector>
54
@@ -23,8 +22,6 @@ using namespace std;
2322
2423#define SerialESP Serial5
2524
26- extern int esp_host_spi_init ();
27-
2825void getESPDebugLog ();
2926int displayMenu ();
3027void makeRequest (int req);
@@ -33,12 +30,15 @@ string prompt(string p);
3330
3431const char mac_address[] = " aa:bb:cc:dd:ee:ff" ;
3532
33+ bool wifiHwInitialized = false ;
3634
3735
3836int initEvent (CCtrlMsgWrapper *resp) {
3937 if (resp->isInitEventReceived () == ESP_CONTROL_OK) {
4038 Serial.println (" [EVENT !!!!]: Init event received" );
39+ wifiHwInitialized = true ;
4140 }
41+ return ESP_CONTROL_OK;
4242}
4343
4444int stationDisconnectionEvent (CCtrlMsgWrapper *resp) {
@@ -47,6 +47,7 @@ int stationDisconnectionEvent(CCtrlMsgWrapper *resp) {
4747 Serial.print (" [EVENT !!!!]: C33 was disconnected from AP for reason " );
4848 Serial.println (reason);
4949 }
50+ return ESP_CONTROL_OK;
5051}
5152
5253int disconnectionFromSofApEvent (CCtrlMsgWrapper *resp) {
@@ -56,6 +57,7 @@ int disconnectionFromSofApEvent(CCtrlMsgWrapper *resp) {
5657 Serial.print (MAC);
5758 Serial.println (" disconnected from ESP32 Soft AP" );
5859 }
60+ return ESP_CONTROL_OK;
5961}
6062
6163
@@ -65,6 +67,7 @@ int heartBeatEvent(CCtrlMsgWrapper *resp) {
6567 Serial.print (" [EVENT !!!!]: heart beat n " );
6668 Serial.println (hb);
6769 }
70+ return ESP_CONTROL_OK;
6871}
6972
7073
@@ -83,10 +86,19 @@ void setup() {
8386 CEspControl::getInstance ().listenForDisconnectionFromSoftApEvent (disconnectionFromSofApEvent);
8487
8588
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+ }
87100
88101 Serial.println (" STARTING PROGRAM" );
89- delay (1000 );
90102}
91103
92104
@@ -685,7 +697,7 @@ int displayMenu() {
685697 cmd_acquired = true ;
686698 rv = stoi (c);
687699 }
688- else {
700+ else if (ch >= ' 0 ' && ch <= ' 9 ' ) {
689701 c += ch;
690702 }
691703 }
0 commit comments