mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 15:08:10 +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_) {
|
switch (this->state_) {
|
||||||
case STATE_INIT:
|
case STATE_INIT: {
|
||||||
if (message.compare(0, 6, "+CMTI:") == 0) {
|
|
||||||
// While we were waiting for update to check for messages, this notifies a message
|
// While we were waiting for update to check for messages, this notifies a message
|
||||||
// is available. Grab it quickly
|
// is available.
|
||||||
this->state_ = STATE_CHECK_SMS;
|
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;
|
break;
|
||||||
case STATE_DISABLE_ECHO:
|
case STATE_DISABLE_ECHO:
|
||||||
send_cmd_("ATE0");
|
send_cmd_("ATE0");
|
||||||
|
@ -95,7 +101,6 @@ void Sim800LComponent::parse_cmd_(std::string message) {
|
||||||
if (registered) {
|
if (registered) {
|
||||||
if (!this->registered_)
|
if (!this->registered_)
|
||||||
ESP_LOGD(TAG, "Registered OK");
|
ESP_LOGD(TAG, "Registered OK");
|
||||||
send_cmd_("AT+CSQ");
|
|
||||||
this->state_ = STATE_CSQ;
|
this->state_ = STATE_CSQ;
|
||||||
this->expect_ack_ = true;
|
this->expect_ack_ = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -113,6 +118,7 @@ void Sim800LComponent::parse_cmd_(std::string message) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case STATE_CSQ:
|
case STATE_CSQ:
|
||||||
|
send_cmd_("AT+CSQ");
|
||||||
this->state_ = STATE_CSQ_RESPONSE;
|
this->state_ = STATE_CSQ_RESPONSE;
|
||||||
break;
|
break;
|
||||||
case STATE_CSQ_RESPONSE:
|
case STATE_CSQ_RESPONSE:
|
||||||
|
@ -123,6 +129,7 @@ void Sim800LComponent::parse_cmd_(std::string message) {
|
||||||
ESP_LOGD(TAG, "RSSI: %d", this->rssi_);
|
ESP_LOGD(TAG, "RSSI: %d", this->rssi_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this->expect_ack_ = true;
|
||||||
this->state_ = STATE_CHECK_SMS;
|
this->state_ = STATE_CHECK_SMS;
|
||||||
break;
|
break;
|
||||||
case STATE_PARSE_SMS:
|
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_);
|
ESP_LOGD(TAG, "Unhandled: %s - %d", message.c_str(), this->state_);
|
||||||
break;
|
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() {
|
void Sim800LComponent::loop() {
|
||||||
|
|
Loading…
Reference in a new issue