From 71d5b061c667f0909029fb483814c99686e09fe4 Mon Sep 17 00:00:00 2001 From: Pablo2048 Date: Tue, 5 Sep 2023 13:51:00 +0200 Subject: [PATCH] Nepristupne metody presunuty do protected, snaha o zrychleni obsluhy --- src/ThreadedGSM.cpp | 21 ++++++++++++--------- src/ThreadedGSM.h | 12 ++++++------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/ThreadedGSM.cpp b/src/ThreadedGSM.cpp index 047e631..e69b7fe 100644 --- a/src/ThreadedGSM.cpp +++ b/src/ThreadedGSM.cpp @@ -70,13 +70,16 @@ void ThreadedGSM::exec() case INTERVAL_BATTERY: mRequests |= REQ_BATTERY; break; + + default: + break; } tickSync[i] = millis(); } } } - if (mJob == 0) { + if (mJob == 0 && mRequests != 0) { // no assigned mJob, assign it if (mRequests & REQ_CLOCK) mJob = REQ_CLOCK; @@ -140,7 +143,7 @@ void ThreadedGSM::Startup() int lastState = mState; switch (mState) { case STARTUP_POWER_OFF: - if (mConfiguration.power != nullptr) + if (mConfiguration.power) mConfiguration.power(*this, false); mTick = millis(); mState = STARTUP_POWER_OFF_DELAY; @@ -152,7 +155,7 @@ void ThreadedGSM::Startup() break; case STARTUP_POWER_ON: - if (mConfiguration.power != nullptr) + if (mConfiguration.power) mConfiguration.power(*this, true); // begin delay mTick = millis(); @@ -263,7 +266,7 @@ void ThreadedGSM::Clock() ClockTime.hour = clockTime.substring(9, 11).toInt(); ClockTime.minute = clockTime.substring(12, 14).toInt(); ClockTime.second = clockTime.substring(15, 17).toInt(); - if (mConfiguration.clock != nullptr) + if (mConfiguration.clock) mConfiguration.clock(*this, ClockTime); } } @@ -294,7 +297,7 @@ void ThreadedGSM::Signal() GsmSignal.Value = mDte.getBuffer().substring(index, index + 2).toInt(); GsmSignal.Dbm = mDte.getBuffer().substring(index + 3, index + 5).toInt(); if (GsmSignal.Value != 0) { - if (mConfiguration.signal != nullptr) + if (mConfiguration.signal) 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 buffer2 = buffer.substring(buffer.indexOf(F(",")) + 1); 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); } clearReq(REQ_BATTERY); @@ -464,7 +467,7 @@ void ThreadedGSM::Inbox() case READ_CHK_CMGD: // if( (mDte.getResult() == DTE::EXPECT_RESULT) && (SMS.InboxMsgContents != "")) if (mDte.getResult() == DTE::EXPECT_RESULT) { - if (mConfiguration.incoming != nullptr) + if (mConfiguration.incoming) mConfiguration.incoming(*this, mSMSi); } clearReq(REQ_INBOX); @@ -511,7 +514,7 @@ void ThreadedGSM::Outbox() case SEND_CHK_OK: if (mDte.getResult() == DTE::EXPECT_RESULT) { - if (mConfiguration.outgoing != nullptr) + if (mConfiguration.outgoing) mConfiguration.outgoing(*this); } clearReq(REQ_OUTBOX); @@ -582,7 +585,7 @@ void ThreadedGSM::startupDone() clearReq(REQ_STARTUP); for (unsigned long & i : tickSync) i = millis(); - if (mConfiguration.ready != nullptr) + if (mConfiguration.ready) mConfiguration.ready(*this); } diff --git a/src/ThreadedGSM.h b/src/ThreadedGSM.h index 53b8a86..28c1910 100644 --- a/src/ThreadedGSM.h +++ b/src/ThreadedGSM.h @@ -7,7 +7,6 @@ #pragma once #include "DTE.h" -//#include #include // Defaults @@ -189,8 +188,6 @@ class ThreadedGSM : public Executable ~ThreadedGSM() override = default; - void nextJob(); - void setHandlers(conf config); void setInterval(IntervalSourceE source, unsigned long interval); @@ -198,9 +195,6 @@ class ThreadedGSM : public Executable // Initialization void begin(); - // Call this function for executing thread - void exec() override; - // Requests void sendSMS(String & Number, String & Text); @@ -211,6 +205,8 @@ class ThreadedGSM : public Executable void restartModem(); protected: + void nextJob(); + void startupDone(); // States @@ -232,4 +228,8 @@ class ThreadedGSM : public Executable void Hangup(); void CheckRing(); + + // executing threads + void exec() override; + }; // ThreadedGSM