Even more RAM reduction

This commit is contained in:
Pavel Brychta 2019-06-16 10:21:53 +02:00
parent 68b8bf084a
commit 4e61bfdf1e
2 changed files with 37 additions and 12 deletions

25
DTE.h
View File

@ -56,6 +56,31 @@ public:
tick = millis(); tick = millis();
proccess(); proccess();
} }
void SendCommand(const __FlashStringHelper* command, unsigned long timeout, const char* response1, const char* response2 = 0, const char* response3 = 0)
{
// char cmd[32];
match = 0;
result = EXPECT_BUSY;
response[0] = response1;
response[1] = response2;
response[2] = response3;
this->timeout = timeout;
// clear rx buffer
while (stream.available())
{
stream.read();
}
// send command
// strcpy_P(cmd, command);
stream.print((const __FlashStringHelper *)command);
// stream.print(cmd);
buffer = "";
tick = millis();
proccess();
}
void Delay(unsigned long delay) void Delay(unsigned long delay)
{ {
timeout = delay; timeout = delay;

View File

@ -340,14 +340,14 @@ private:
case STARTUP_DELAY: case STARTUP_DELAY:
if(millis() - tick >= THREADEDGSM_STARTUP_DELAY) if(millis() - tick >= THREADEDGSM_STARTUP_DELAY)
{ {
dte.SendCommand("AT\r", THREADEDGSM_AT_TIMEOUT, "OK\r"); dte.SendCommand(F("AT\r"), THREADEDGSM_AT_TIMEOUT, "OK\r");
state = STARTUP_ENTER_AT; state = STARTUP_ENTER_AT;
} }
break; break;
case STARTUP_ENTER_AT: case STARTUP_ENTER_AT:
if(dte.getResult() == DTE::EXPECT_RESULT) if(dte.getResult() == DTE::EXPECT_RESULT)
{ {
dte.SendCommand("AT+CPIN?\r", 10000, "OK\r"); dte.SendCommand(F("AT+CPIN?\r"), 10000, "OK\r");
state = STARTUP_CHK_CPIN; state = STARTUP_CHK_CPIN;
} }
else else
@ -360,7 +360,7 @@ private:
{ {
if(dte.getBuffer().indexOf(F("+CPIN: READY")) != -1) if(dte.getBuffer().indexOf(F("+CPIN: READY")) != -1)
{ {
dte.SendCommand("AT+CREG?\r", THREADEDGSM_AT_TIMEOUT, "OK\r"); dte.SendCommand(F("AT+CREG?\r"), THREADEDGSM_AT_TIMEOUT, "OK\r");
state = STARTUP_CHK_CREG; state = STARTUP_CHK_CREG;
}else }else
{ {
@ -374,7 +374,7 @@ private:
{ {
if((dte.getBuffer().indexOf(F(",1")) >= 0) || (dte.getBuffer().indexOf(F(",5")) >= 0)) if((dte.getBuffer().indexOf(F(",1")) >= 0) || (dte.getBuffer().indexOf(F(",5")) >= 0))
{ {
dte.SendCommand("AT+CLTS=1\r", THREADEDGSM_AT_TIMEOUT, "OK\r"); dte.SendCommand(F("AT+CLTS=1\r"), THREADEDGSM_AT_TIMEOUT, "OK\r");
state = STARTUP_CHK_CLTS; state = STARTUP_CHK_CLTS;
}else }else
state = STARTUP_POWER_OFF; state = STARTUP_POWER_OFF;
@ -384,7 +384,7 @@ private:
case STARTUP_CHK_CLTS: case STARTUP_CHK_CLTS:
if(dte.getResult() == DTE::EXPECT_RESULT) if(dte.getResult() == DTE::EXPECT_RESULT)
{ {
dte.SendCommand("AT+CENG=3\r", THREADEDGSM_AT_TIMEOUT, "OK\r"); dte.SendCommand(F("AT+CENG=3\r"), THREADEDGSM_AT_TIMEOUT, "OK\r");
state = STARTUP_CHK_CENG; state = STARTUP_CHK_CENG;
}else }else
state = STARTUP_POWER_OFF; state = STARTUP_POWER_OFF;
@ -417,7 +417,7 @@ private:
switch(state) switch(state)
{ {
case CLOCK_REQ: case CLOCK_REQ:
dte.SendCommand("AT+CCLK?\r", THREADEDGSM_AT_TIMEOUT, "OK\r"); dte.SendCommand(F("AT+CCLK?\r"), THREADEDGSM_AT_TIMEOUT, "OK\r");
state = CLOCK_VERIFY; state = CLOCK_VERIFY;
break; break;
case CLOCK_VERIFY: case CLOCK_VERIFY:
@ -465,7 +465,7 @@ private:
switch(state) switch(state)
{ {
case SIGNAL_REQ: case SIGNAL_REQ:
dte.SendCommand("AT+CSQ\r", THREADEDGSM_AT_TIMEOUT, "OK\r"); dte.SendCommand(F("AT+CSQ\r"), THREADEDGSM_AT_TIMEOUT, "OK\r");
state = SIGNAL_VERIFY; state = SIGNAL_VERIFY;
break; break;
case SIGNAL_VERIFY: case SIGNAL_VERIFY:
@ -499,7 +499,7 @@ private:
switch(state) switch(state)
{ {
case BATTERY_REQ: case BATTERY_REQ:
dte.SendCommand("AT+CBC\r", THREADEDGSM_AT_TIMEOUT, "OK\r"); dte.SendCommand(F("AT+CBC\r"), THREADEDGSM_AT_TIMEOUT, "OK\r");
state = BATTERY_VERIFY; state = BATTERY_VERIFY;
break; break;
case BATTERY_VERIFY: case BATTERY_VERIFY:
@ -541,13 +541,13 @@ private:
case READ_REQ: case READ_REQ:
SMSi.Text = ""; SMSi.Text = "";
SMSi.Number = ""; SMSi.Number = "";
dte.SendCommand("AT+CMGF=0\r", THREADEDGSM_AT_TIMEOUT, "OK\r"); // SMS Message format set as PDU dte.SendCommand(F("AT+CMGF=0\r"), THREADEDGSM_AT_TIMEOUT, "OK\r"); // SMS Message format set as PDU
state = READ_CHK_CMGF; state = READ_CHK_CMGF;
break; break;
case READ_CHK_CMGF: case READ_CHK_CMGF:
if(dte.getResult() == DTE::EXPECT_RESULT) if(dte.getResult() == DTE::EXPECT_RESULT)
{ {
dte.SendCommand("AT+CPMS=\"SM\"\r", THREADEDGSM_AT_TIMEOUT, "OK\r"); // SIM Message storage dte.SendCommand(F("AT+CPMS=\"SM\"\r"), THREADEDGSM_AT_TIMEOUT, "OK\r"); // SIM Message storage
state = READ_CHK_CPMS; state = READ_CHK_CPMS;
} }
else clearReq(REQ_INBOX); else clearReq(REQ_INBOX);
@ -584,7 +584,7 @@ private:
break; break;
case READ_DELAY_CLEAR_BUFF: case READ_DELAY_CLEAR_BUFF:
dte.SendCommand("AT+CMGF=1\r", THREADEDGSM_AT_TIMEOUT, "OK\r"); // SMS Message format set as TEXT dte.SendCommand(F("AT+CMGF=1\r"), THREADEDGSM_AT_TIMEOUT, "OK\r"); // SMS Message format set as TEXT
state = READ_TEXT_CMGR; state = READ_TEXT_CMGR;
break; break;
@ -657,7 +657,7 @@ private:
switch(state) switch(state)
{ {
case SEND_REQ: case SEND_REQ:
dte.SendCommand("AT+CMGF=1\r", THREADEDGSM_AT_TIMEOUT, "OK\r"); // SMS Text mode dte.SendCommand(F("AT+CMGF=1\r"), THREADEDGSM_AT_TIMEOUT, "OK\r"); // SMS Text mode
state = SEND_CHK_CMGF; state = SEND_CHK_CMGF;
break; break;