Skip to content

ESPHost library - make the example work #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions libraries/ESPhost/examples/ESP32_TEST/ESP32_TEST.ino
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "CEspControl.h"
#include "CNetIf.h"
#include <string>
#include <vector>

Expand All @@ -23,8 +22,6 @@ using namespace std;

#define SerialESP Serial5

extern int esp_host_spi_init();

void getESPDebugLog();
int displayMenu();
void makeRequest(int req);
Expand All @@ -33,12 +30,15 @@ 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) {
Expand All @@ -47,6 +47,7 @@ int stationDisconnectionEvent(CCtrlMsgWrapper *resp) {
Serial.print("[EVENT !!!!]: C33 was disconnected from AP for reason ");
Serial.println(reason);
}
return ESP_CONTROL_OK;
}

int disconnectionFromSofApEvent(CCtrlMsgWrapper *resp) {
Expand All @@ -56,6 +57,7 @@ int disconnectionFromSofApEvent(CCtrlMsgWrapper *resp) {
Serial.print(MAC);
Serial.println(" disconnected from ESP32 Soft AP");
}
return ESP_CONTROL_OK;
}


Expand All @@ -65,6 +67,7 @@ int heartBeatEvent(CCtrlMsgWrapper *resp) {
Serial.print("[EVENT !!!!]: heart beat n ");
Serial.println(hb);
}
return ESP_CONTROL_OK;
}


Expand All @@ -83,10 +86,19 @@ void setup() {
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");
delay(1000);
}


Expand Down Expand Up @@ -685,7 +697,7 @@ int displayMenu() {
cmd_acquired = true;
rv = stoi(c);
}
else {
else if(ch >= '0' && ch <='9') {
c += ch;
}
}
Expand Down
1 change: 0 additions & 1 deletion libraries/ESPhost/src/CEspControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "CCtrlWrapper.h"
#include "CEspCommunication.h"
#include "EspSpiDriver.h"
#include "CNetIf.h"
#include "CEspCbks.h"
#include <string>

Expand Down