mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-21 12:56:11 +02:00
fix Interrupt
fix connect to WiFi with only one AP
This commit is contained in:
parent
a85ed6c089
commit
edefcf1c83
5 changed files with 26 additions and 8 deletions
|
@ -13,6 +13,7 @@ app::app() : ah::Scheduler() {}
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
void app::setup() {
|
||||
mSys = NULL;
|
||||
Serial.begin(115200);
|
||||
while (!Serial)
|
||||
yield();
|
||||
|
|
|
@ -60,6 +60,11 @@ class app : public IApp, public ah::Scheduler {
|
|||
void onWifi(bool gotIp);
|
||||
void regularTickers(void);
|
||||
|
||||
void handleIntr(void) {
|
||||
if(NULL != mSys)
|
||||
mSys->Radio.handleIntr();
|
||||
}
|
||||
|
||||
uint32_t getUptime() {
|
||||
return Scheduler::getUptime();
|
||||
}
|
||||
|
|
|
@ -82,7 +82,6 @@ class HmRadio {
|
|||
void setup(uint8_t ampPwr = RF24_PA_LOW, uint8_t irq = IRQ_PIN, uint8_t ce = CE_PIN, uint8_t cs = CS_PIN) {
|
||||
DPRINTLN(DBG_VERBOSE, F("hmRadio.h:setup"));
|
||||
pinMode(irq, INPUT_PULLUP);
|
||||
attachInterrupt(digitalPinToInterrupt(irq), []()IRAM_ATTR{ mIrqRcvd = true; }, FALLING);
|
||||
|
||||
uint32_t dtuSn = 0x87654321;
|
||||
uint32_t chipID = 0; // will be filled with last 3 bytes of MAC
|
||||
|
@ -166,6 +165,10 @@ class HmRadio {
|
|||
return true;
|
||||
}
|
||||
|
||||
void handleIntr(void) {
|
||||
mIrqRcvd = true;
|
||||
}
|
||||
|
||||
bool isChipConnected(void) {
|
||||
//DPRINTLN(DBG_VERBOSE, F("hmRadio.h:isChipConnected"));
|
||||
return mNrf24.isChipConnected();
|
||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -7,11 +7,21 @@
|
|||
#include "app.h"
|
||||
#include "config/config.h"
|
||||
|
||||
|
||||
app myApp;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
IRAM_ATTR void handleIntr(void) {
|
||||
myApp.handleIntr();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void setup() {
|
||||
myApp.setup();
|
||||
|
||||
// TODO: move to HmRadio
|
||||
attachInterrupt(digitalPinToInterrupt(myApp.getIrqPin()), handleIntr, FALLING);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -88,7 +88,12 @@ void ahoywifi::tickWifiLoop() {
|
|||
}
|
||||
mCnt++;
|
||||
|
||||
if(!mScanActive && mBSSIDList.empty()) { // start scanning APs with the given SSID
|
||||
uint8_t timeout = 10; // seconds
|
||||
if (mStaConn == CONNECTED) // connected but no ip
|
||||
timeout = 20;
|
||||
|
||||
|
||||
if(!mScanActive && mBSSIDList.empty() && ((mCnt % timeout) == 0)) { // start scanning APs with the given SSID
|
||||
DBGPRINT(F("scanning APs with SSID "));
|
||||
DBGPRINTLN(String(mConfig->sys.stationSsid));
|
||||
mScanCnt = 0;
|
||||
|
@ -100,12 +105,6 @@ void ahoywifi::tickWifiLoop() {
|
|||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t timeout = 10; // seconds
|
||||
|
||||
if (mStaConn == CONNECTED) // connected but no ip
|
||||
timeout = 20;
|
||||
|
||||
DBGPRINT(F("reconnect in "));
|
||||
DBGPRINT(String(timeout-mCnt));
|
||||
DBGPRINTLN(F(" seconds"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue