Enable interrupt-mode for lwIP_ESPHost (#2036)
This commit is contained in:
parent
9c94bab290
commit
22139df33c
4 changed files with 28 additions and 14 deletions
|
|
@ -19,7 +19,8 @@
|
|||
*/
|
||||
|
||||
#include "ESPHost.h"
|
||||
#include "CEspControl.h"
|
||||
#include <CEspControl.h>
|
||||
#include <LwipEthernet.h>
|
||||
|
||||
ESPHost::ESPHost(int8_t cs, arduino::SPIClass &spi, int8_t intrpin) {
|
||||
(void) cs;
|
||||
|
|
@ -42,8 +43,10 @@ void ESPHost::end() {
|
|||
}
|
||||
|
||||
uint16_t ESPHost::sendFrame(const uint8_t *data, uint16_t datalen) {
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
int res = CEspControl::getInstance().sendBuffer(apMode ? ESP_AP_IF : ESP_STA_IF, 0, (uint8_t*) data, datalen);
|
||||
CEspControl::getInstance().communicateWithEsp();
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return (res == ESP_CONTROL_OK) ? datalen : 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public:
|
|||
}
|
||||
|
||||
bool interruptIsPossible() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
PinStatus interruptMode() {
|
||||
|
|
|
|||
|
|
@ -23,9 +23,18 @@
|
|||
|
||||
#define MAX_SOFTAP_CONNECTION_DEF 5
|
||||
|
||||
#if defined(SPIWIFI_ACK) // Arduino Nano RP2040 Connect
|
||||
#define ESPHOST_DATA_READY SPIWIFI_ACK
|
||||
#endif
|
||||
|
||||
bool ESPHostLwIP::wifiHwInitialized = false;
|
||||
ESPHostLwIP* ESPHostLwIP::instance = nullptr;
|
||||
|
||||
ESPHostLwIP::ESPHostLwIP() :
|
||||
LwipIntfDev<ESPHost>(SS, SPI, ESPHOST_DATA_READY) {
|
||||
|
||||
}
|
||||
|
||||
void ESPHostLwIP::setSTA() {
|
||||
apMode = false;
|
||||
}
|
||||
|
|
@ -122,7 +131,7 @@ bool ESPHostLwIP::begin() {
|
|||
if (!initHW()) {
|
||||
return false;
|
||||
}
|
||||
ethernet_arch_lwip_begin();
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
if (!apMode) {
|
||||
CEspControl::getInstance().setWifiMode(WIFI_MODE_STA);
|
||||
if (CEspControl::getInstance().connectAccessPoint(ap) != ESP_CONTROL_OK) {
|
||||
|
|
@ -148,10 +157,10 @@ bool ESPHostLwIP::begin() {
|
|||
}
|
||||
CEspControl::getInstance().getSoftAccessPointConfig(softAP);
|
||||
}
|
||||
ethernet_arch_lwip_end();
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
uint8_t mac[6];
|
||||
if (!LwipIntfDev<ESPHost>::begin(macAddress(apMode, mac))) {
|
||||
ethernet_arch_lwip_begin();
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
if (apMode) {
|
||||
CEspControl::getInstance().stopSoftAccessPoint();
|
||||
wifiStatus = WL_AP_FAILED;
|
||||
|
|
@ -159,7 +168,7 @@ bool ESPHostLwIP::begin() {
|
|||
CEspControl::getInstance().disconnectAccessPoint();
|
||||
wifiStatus = WL_CONNECT_FAILED;
|
||||
}
|
||||
ethernet_arch_lwip_end();
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return false;
|
||||
}
|
||||
if (apMode) {
|
||||
|
|
@ -206,11 +215,11 @@ uint8_t* ESPHostLwIP::macAddress(bool apMode, uint8_t *mac) {
|
|||
}
|
||||
WifiMac_t MAC;
|
||||
MAC.mode = apMode ? WIFI_MODE_AP : WIFI_MODE_STA;
|
||||
ethernet_arch_lwip_begin();
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
if (CEspControl::getInstance().getWifiMacAddress(MAC) == ESP_CONTROL_OK) {
|
||||
CNetUtilities::macStr2macArray(mac, MAC.mac);
|
||||
}
|
||||
ethernet_arch_lwip_end();
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return mac;
|
||||
}
|
||||
|
||||
|
|
@ -227,9 +236,9 @@ int32_t ESPHostLwIP::RSSI() {
|
|||
if (!joined) {
|
||||
return 0;
|
||||
}
|
||||
ethernet_arch_lwip_begin();
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
CEspControl::getInstance().getAccessPointConfig(ap);
|
||||
ethernet_arch_lwip_end();
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
return ap.rssi;
|
||||
}
|
||||
|
||||
|
|
@ -264,9 +273,9 @@ int8_t ESPHostLwIP::scanNetworks(bool async) {
|
|||
if (!initHW()) {
|
||||
return -1;
|
||||
}
|
||||
ethernet_arch_lwip_begin();
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
int res = CEspControl::getInstance().getAccessPointScanList(accessPoints);
|
||||
ethernet_arch_lwip_end();
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
wifiStatus = WL_SCAN_COMPLETED;
|
||||
if (res != ESP_CONTROL_OK) {
|
||||
return -1;
|
||||
|
|
@ -321,9 +330,9 @@ void ESPHostLwIP::lowPowerMode() {
|
|||
if (!initHW()) {
|
||||
return;
|
||||
}
|
||||
ethernet_arch_lwip_begin();
|
||||
ethernet_arch_lwip_gpio_mask();
|
||||
CEspControl::getInstance().setPowerSaveMode(1);
|
||||
ethernet_arch_lwip_end();
|
||||
ethernet_arch_lwip_gpio_unmask();
|
||||
}
|
||||
|
||||
void ESPHostLwIP::noLowPowerMode() {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
class ESPHostLwIP : public LwipIntfDev<ESPHost> {
|
||||
public:
|
||||
|
||||
ESPHostLwIP();
|
||||
|
||||
void setSTA();
|
||||
void setAP();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue