Skip to content

Commit 13ae45a

Browse files
authored
Merge pull request #227 from JAndrassy/esphost_fix_example
ESPHost library - make the example work
2 parents 6ee152f + fab97fc commit 13ae45a

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

Diff for: libraries/ESPhost/examples/ESP32_TEST/ESP32_TEST.ino

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
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-
2825
void getESPDebugLog();
2926
int displayMenu();
3027
void makeRequest(int req);
@@ -33,12 +30,15 @@ string prompt(string p);
3330

3431
const char mac_address[] = "aa:bb:cc:dd:ee:ff";
3532

33+
bool wifiHwInitialized = false;
3634

3735

3836
int 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

4444
int 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

5253
int 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
}

Diff for: libraries/ESPhost/src/CEspControl.h

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "CCtrlWrapper.h"
3636
#include "CEspCommunication.h"
3737
#include "EspSpiDriver.h"
38-
#include "CNetIf.h"
3938
#include "CEspCbks.h"
4039
#include <string>
4140

0 commit comments

Comments
 (0)