mirror of
https://github.com/esphome/esphome.git
synced 2024-12-18 19:44:53 +01:00
improved pin checks
This commit is contained in:
parent
32f2c9f88e
commit
d67fa07ee2
1 changed files with 16 additions and 8 deletions
|
@ -177,20 +177,28 @@ void ModemComponent::start_connect_() {
|
||||||
ESP_LOGI(TAG, "not set_flow_control, because 2-wire mode active.");
|
ESP_LOGI(TAG, "not set_flow_control, because 2-wire mode active.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup basic operation mode for the DCE (pin if used, CMUX mode) */
|
|
||||||
if (!this->pin_code_.empty()) {
|
|
||||||
bool pin_ok = true;
|
bool pin_ok = true;
|
||||||
ESP_LOGV(TAG, "Set pin code: %s", this->pin_code_.c_str());
|
|
||||||
if (this->dce->read_pin(pin_ok) == command_result::OK && !pin_ok) {
|
if (this->dce->read_pin(pin_ok) == command_result::OK && !pin_ok) {
|
||||||
ESP_MODEM_THROW_IF_FALSE(this->dce->set_pin(this->pin_code_) == command_result::OK, "Cannot set PIN!");
|
if (!this->pin_code_.empty()) {
|
||||||
|
ESP_LOGV(TAG, "Set pin code: %s", this->pin_code_.c_str());
|
||||||
|
this->dce->set_pin(this->pin_code_);
|
||||||
vTaskDelay(pdMS_TO_TICKS(2000)); // Need to wait for some time after unlocking the SIM
|
vTaskDelay(pdMS_TO_TICKS(2000)); // Need to wait for some time after unlocking the SIM
|
||||||
}
|
}
|
||||||
|
if (this->dce->read_pin(pin_ok) == command_result::OK && !pin_ok) {
|
||||||
|
ESP_LOGE(TAG, "Invalid PIN");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pin_ok) {
|
||||||
|
if (this->pin_code_.empty()) {
|
||||||
|
ESP_LOGD(TAG, "PIN not needed");
|
||||||
|
} else {
|
||||||
|
ESP_LOGD(TAG, "PIN unlocked");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Entering CMUX mode");
|
ESP_LOGD(TAG, "Entering CMUX mode");
|
||||||
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(2000));
|
vTaskDelay(pdMS_TO_TICKS(2000));
|
||||||
|
|
||||||
if (this->dce->set_mode(modem_mode::CMUX_MODE)) {
|
if (this->dce->set_mode(modem_mode::CMUX_MODE)) {
|
||||||
ESP_LOGD(TAG, "Modem has correctly entered multiplexed command/data mode");
|
ESP_LOGD(TAG, "Modem has correctly entered multiplexed command/data mode");
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue