mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 05:24:53 +01:00
parent
4c03cebef3
commit
b6920025b2
1 changed files with 14 additions and 13 deletions
|
@ -67,12 +67,18 @@ void Sim800LComponent::parse_cmd_(std::string message) {
|
|||
}
|
||||
|
||||
switch (this->state_) {
|
||||
case STATE_INIT:
|
||||
if (message.compare(0, 6, "+CMTI:") == 0) {
|
||||
// While we were waiting for update to check for messages, this notifies a message
|
||||
// is available. Grab it quickly
|
||||
this->state_ = STATE_CHECK_SMS;
|
||||
}
|
||||
case STATE_INIT: {
|
||||
// While we were waiting for update to check for messages, this notifies a message
|
||||
// is available.
|
||||
bool message_available = message.compare(0, 6, "+CMTI:") == 0;
|
||||
if (!message_available)
|
||||
break;
|
||||
// Else fall thru ...
|
||||
}
|
||||
case STATE_CHECK_SMS:
|
||||
send_cmd_("AT+CMGL=\"ALL\"");
|
||||
this->state_ = STATE_PARSE_SMS;
|
||||
this->parse_index_ = 0;
|
||||
break;
|
||||
case STATE_DISABLE_ECHO:
|
||||
send_cmd_("ATE0");
|
||||
|
@ -95,7 +101,6 @@ void Sim800LComponent::parse_cmd_(std::string message) {
|
|||
if (registered) {
|
||||
if (!this->registered_)
|
||||
ESP_LOGD(TAG, "Registered OK");
|
||||
send_cmd_("AT+CSQ");
|
||||
this->state_ = STATE_CSQ;
|
||||
this->expect_ack_ = true;
|
||||
} else {
|
||||
|
@ -113,6 +118,7 @@ void Sim800LComponent::parse_cmd_(std::string message) {
|
|||
break;
|
||||
}
|
||||
case STATE_CSQ:
|
||||
send_cmd_("AT+CSQ");
|
||||
this->state_ = STATE_CSQ_RESPONSE;
|
||||
break;
|
||||
case STATE_CSQ_RESPONSE:
|
||||
|
@ -123,6 +129,7 @@ void Sim800LComponent::parse_cmd_(std::string message) {
|
|||
ESP_LOGD(TAG, "RSSI: %d", this->rssi_);
|
||||
}
|
||||
}
|
||||
this->expect_ack_ = true;
|
||||
this->state_ = STATE_CHECK_SMS;
|
||||
break;
|
||||
case STATE_PARSE_SMS:
|
||||
|
@ -209,12 +216,6 @@ void Sim800LComponent::parse_cmd_(std::string message) {
|
|||
ESP_LOGD(TAG, "Unhandled: %s - %d", message.c_str(), this->state_);
|
||||
break;
|
||||
}
|
||||
if (this->state_ == STATE_CHECK_SMS) {
|
||||
send_cmd_("AT+CMGL=\"ALL\"");
|
||||
this->state_ = STATE_PARSE_SMS;
|
||||
this->parse_index_ = 0;
|
||||
this->expect_ack_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Sim800LComponent::loop() {
|
||||
|
|
Loading…
Reference in a new issue