Nepristupne metody presunuty do protected, snaha o zrychleni obsluhy

This commit is contained in:
Pavel Brychta 2023-09-05 13:51:00 +02:00
parent 972ec4d354
commit 71d5b061c6
2 changed files with 18 additions and 15 deletions

View File

@ -70,13 +70,16 @@ void ThreadedGSM::exec()
case INTERVAL_BATTERY: case INTERVAL_BATTERY:
mRequests |= REQ_BATTERY; mRequests |= REQ_BATTERY;
break; break;
default:
break;
} }
tickSync[i] = millis(); tickSync[i] = millis();
} }
} }
} }
if (mJob == 0) { if (mJob == 0 && mRequests != 0) {
// no assigned mJob, assign it // no assigned mJob, assign it
if (mRequests & REQ_CLOCK) if (mRequests & REQ_CLOCK)
mJob = REQ_CLOCK; mJob = REQ_CLOCK;
@ -140,7 +143,7 @@ void ThreadedGSM::Startup()
int lastState = mState; int lastState = mState;
switch (mState) { switch (mState) {
case STARTUP_POWER_OFF: case STARTUP_POWER_OFF:
if (mConfiguration.power != nullptr) if (mConfiguration.power)
mConfiguration.power(*this, false); mConfiguration.power(*this, false);
mTick = millis(); mTick = millis();
mState = STARTUP_POWER_OFF_DELAY; mState = STARTUP_POWER_OFF_DELAY;
@ -152,7 +155,7 @@ void ThreadedGSM::Startup()
break; break;
case STARTUP_POWER_ON: case STARTUP_POWER_ON:
if (mConfiguration.power != nullptr) if (mConfiguration.power)
mConfiguration.power(*this, true); mConfiguration.power(*this, true);
// begin delay // begin delay
mTick = millis(); mTick = millis();
@ -263,7 +266,7 @@ void ThreadedGSM::Clock()
ClockTime.hour = clockTime.substring(9, 11).toInt(); ClockTime.hour = clockTime.substring(9, 11).toInt();
ClockTime.minute = clockTime.substring(12, 14).toInt(); ClockTime.minute = clockTime.substring(12, 14).toInt();
ClockTime.second = clockTime.substring(15, 17).toInt(); ClockTime.second = clockTime.substring(15, 17).toInt();
if (mConfiguration.clock != nullptr) if (mConfiguration.clock)
mConfiguration.clock(*this, ClockTime); mConfiguration.clock(*this, ClockTime);
} }
} }
@ -294,7 +297,7 @@ void ThreadedGSM::Signal()
GsmSignal.Value = mDte.getBuffer().substring(index, index + 2).toInt(); GsmSignal.Value = mDte.getBuffer().substring(index, index + 2).toInt();
GsmSignal.Dbm = mDte.getBuffer().substring(index + 3, index + 5).toInt(); GsmSignal.Dbm = mDte.getBuffer().substring(index + 3, index + 5).toInt();
if (GsmSignal.Value != 0) { if (GsmSignal.Value != 0) {
if (mConfiguration.signal != nullptr) if (mConfiguration.signal)
mConfiguration.signal(*this, GsmSignal); mConfiguration.signal(*this, GsmSignal);
} }
} }
@ -327,7 +330,7 @@ void ThreadedGSM::Battery()
BattInfo.Percent = buffer2.substring(0, buffer2.indexOf(F(","))).toInt(); // converts the mResult to interger BattInfo.Percent = buffer2.substring(0, buffer2.indexOf(F(","))).toInt(); // converts the mResult to interger
buffer2 = buffer.substring(buffer.indexOf(F(",")) + 1); buffer2 = buffer.substring(buffer.indexOf(F(",")) + 1);
BattInfo.Voltage = buffer2.substring(0, buffer2.indexOf(F("\r"))).toInt(); // converts the mResult to interger BattInfo.Voltage = buffer2.substring(0, buffer2.indexOf(F("\r"))).toInt(); // converts the mResult to interger
if (mConfiguration.battery != nullptr) if (mConfiguration.battery)
mConfiguration.battery(*this, BattInfo); mConfiguration.battery(*this, BattInfo);
} }
clearReq(REQ_BATTERY); clearReq(REQ_BATTERY);
@ -464,7 +467,7 @@ void ThreadedGSM::Inbox()
case READ_CHK_CMGD: case READ_CHK_CMGD:
// if( (mDte.getResult() == DTE::EXPECT_RESULT) && (SMS.InboxMsgContents != "")) // if( (mDte.getResult() == DTE::EXPECT_RESULT) && (SMS.InboxMsgContents != ""))
if (mDte.getResult() == DTE::EXPECT_RESULT) { if (mDte.getResult() == DTE::EXPECT_RESULT) {
if (mConfiguration.incoming != nullptr) if (mConfiguration.incoming)
mConfiguration.incoming(*this, mSMSi); mConfiguration.incoming(*this, mSMSi);
} }
clearReq(REQ_INBOX); clearReq(REQ_INBOX);
@ -511,7 +514,7 @@ void ThreadedGSM::Outbox()
case SEND_CHK_OK: case SEND_CHK_OK:
if (mDte.getResult() == DTE::EXPECT_RESULT) { if (mDte.getResult() == DTE::EXPECT_RESULT) {
if (mConfiguration.outgoing != nullptr) if (mConfiguration.outgoing)
mConfiguration.outgoing(*this); mConfiguration.outgoing(*this);
} }
clearReq(REQ_OUTBOX); clearReq(REQ_OUTBOX);
@ -582,7 +585,7 @@ void ThreadedGSM::startupDone()
clearReq(REQ_STARTUP); clearReq(REQ_STARTUP);
for (unsigned long & i : tickSync) for (unsigned long & i : tickSync)
i = millis(); i = millis();
if (mConfiguration.ready != nullptr) if (mConfiguration.ready)
mConfiguration.ready(*this); mConfiguration.ready(*this);
} }

View File

@ -7,7 +7,6 @@
#pragma once #pragma once
#include "DTE.h" #include "DTE.h"
//#include <Arduino.h>
#include <Chronos.hpp> #include <Chronos.hpp>
// Defaults // Defaults
@ -189,8 +188,6 @@ class ThreadedGSM : public Executable
~ThreadedGSM() override = default; ~ThreadedGSM() override = default;
void nextJob();
void setHandlers(conf config); void setHandlers(conf config);
void setInterval(IntervalSourceE source, unsigned long interval); void setInterval(IntervalSourceE source, unsigned long interval);
@ -198,9 +195,6 @@ class ThreadedGSM : public Executable
// Initialization // Initialization
void begin(); void begin();
// Call this function for executing thread
void exec() override;
// Requests // Requests
void sendSMS(String & Number, String & Text); void sendSMS(String & Number, String & Text);
@ -211,6 +205,8 @@ class ThreadedGSM : public Executable
void restartModem(); void restartModem();
protected: protected:
void nextJob();
void startupDone(); void startupDone();
// States // States
@ -232,4 +228,8 @@ class ThreadedGSM : public Executable
void Hangup(); void Hangup();
void CheckRing(); void CheckRing();
// executing threads
void exec() override;
}; // ThreadedGSM }; // ThreadedGSM