Opravy vetsinou nefunkcni inicializace modemu (odstranenim mych pokusu o detekci RING - udelam jinak)

This commit is contained in:
Pavel Brychta 2023-09-02 14:29:55 +02:00
parent e6ba94d9e3
commit 6b1c5bf3c8
2 changed files with 5 additions and 24 deletions

View File

@ -15,14 +15,12 @@ class DTE {
EXPECT_BUSY, EXPECT_BUSY,
EXPECT_TIMEOUT, EXPECT_TIMEOUT,
EXPECT_DELAY, EXPECT_DELAY,
EXPECT_RESULT, EXPECT_RESULT
EXPECT_RING
}; };
private: private:
String buffer; String buffer;
Stream & stream; Stream & stream;
unsigned int bufferIndex;
unsigned int bufferSize; unsigned int bufferSize;
String response[3]; String response[3];
unsigned long timeout; unsigned long timeout;
@ -39,7 +37,7 @@ class DTE {
~DTE() = default; ~DTE() = default;
void SendCommand(const char * command, unsigned long timeout, const char * response1, const char * response2 = 0, const char * response3 = 0) void SendCommand(const char * command, unsigned long timeout, const char * response1, const char * response2 = nullptr, const char * response3 = nullptr)
{ {
match = 0; match = 0;
result = EXPECT_BUSY; result = EXPECT_BUSY;
@ -54,7 +52,7 @@ class DTE {
proccess(); proccess();
} }
void SendCommand(const __FlashStringHelper * command, unsigned long timeout, const char * response1, const char * response2 = 0, const char * response3 = 0) void SendCommand(const __FlashStringHelper * command, unsigned long timeout, const char * response1, const char * response2 = nullptr, const char * response3 = nullptr)
{ {
match = 0; match = 0;
@ -119,21 +117,8 @@ class DTE {
return; return;
} }
if (result != EXPECT_BUSY) { if (result != EXPECT_BUSY)
if (stream.available()) {
char c;
c = stream.read();
buffer += c;
if (buffer.length() > 4) {
if (buffer.endsWith(F("RING\n"))) {
result = EXPECT_RING;
}
buffer.remove(0);
}
}
return; return;
}
char c; char c;
unsigned long now = millis(); unsigned long now = millis();
@ -141,7 +126,7 @@ class DTE {
while (millis() - tick < timeout) { while (millis() - tick < timeout) {
while (stream.available() && (buffer.length() < bufferSize)) { while (stream.available() && (buffer.length() < bufferSize)) {
c = stream.read(); c = stream.read();
buffer += c; buffer.concat(c);
if (buffer.endsWith(response[0])) { if (buffer.endsWith(response[0])) {
match = 0; match = 0;
result = EXPECT_RESULT; result = EXPECT_RESULT;

View File

@ -676,10 +676,6 @@ class ThreadedGSM {
int lastState = ringState; int lastState = ringState;
switch (ringState) { switch (ringState) {
case RING_WAIT: case RING_WAIT:
if (dte.getResult() == DTE::EXPECT_RING) {
ringState = RING_CHK;
}
break; break;
case RING_CHK: case RING_CHK: