mirror of
https://github.com/esphome/esphome.git
synced 2024-11-28 01:34:18 +01:00
code clean
This commit is contained in:
parent
bd5fd0c12b
commit
521931d0fe
2 changed files with 11 additions and 52 deletions
|
@ -43,8 +43,6 @@ CONFIG_SCHEMA = cv.All(
|
||||||
cv.Required(CONF_RX_PIN): cv.positive_int,
|
cv.Required(CONF_RX_PIN): cv.positive_int,
|
||||||
cv.Required(CONF_MODEL): cv.string,
|
cv.Required(CONF_MODEL): cv.string,
|
||||||
cv.Required(CONF_APN): cv.string,
|
cv.Required(CONF_APN): cv.string,
|
||||||
# cv.Optional(CONF_ON_SCRIPT): cv.use_id(Script),
|
|
||||||
# cv.Optional(CONF_OFF_SCRIPT): cv.use_id(Script),
|
|
||||||
cv.Optional(CONF_DTR_PIN): cv.positive_int,
|
cv.Optional(CONF_DTR_PIN): cv.positive_int,
|
||||||
cv.Optional(CONF_PIN_CODE): cv.string_strict,
|
cv.Optional(CONF_PIN_CODE): cv.string_strict,
|
||||||
cv.Optional(CONF_USERNAME): cv.string,
|
cv.Optional(CONF_USERNAME): cv.string,
|
||||||
|
@ -109,18 +107,6 @@ async def to_code(config):
|
||||||
for cmd in init_at:
|
for cmd in init_at:
|
||||||
cg.add(var.add_init_at_command(cmd))
|
cg.add(var.add_init_at_command(cmd))
|
||||||
|
|
||||||
# if modem_ready := config.get(CONF_READY, None):
|
|
||||||
# modem_ready_sensor = await cg.get_variable(modem_ready)
|
|
||||||
# cg.add(var.set_ready_bsensor(modem_ready_sensor))
|
|
||||||
|
|
||||||
# if conf_on_script := config.get(CONF_ON_SCRIPT, None):
|
|
||||||
# on_script = await cg.get_variable(conf_on_script)
|
|
||||||
# cg.add(var.set_on_script(on_script))
|
|
||||||
#
|
|
||||||
# if conf_off_script := config.get(CONF_OFF_SCRIPT, None):
|
|
||||||
# off_script = await cg.get_variable(conf_off_script)
|
|
||||||
# cg.add(var.set_off_script(off_script))
|
|
||||||
|
|
||||||
cg.add(var.set_model(config[CONF_MODEL]))
|
cg.add(var.set_model(config[CONF_MODEL]))
|
||||||
cg.add(var.set_apn(config[CONF_APN]))
|
cg.add(var.set_apn(config[CONF_APN]))
|
||||||
|
|
||||||
|
|
|
@ -242,50 +242,23 @@ void ModemComponent::loop() {
|
||||||
case ModemComponentState::STOPPED:
|
case ModemComponentState::STOPPED:
|
||||||
if (this->started_) {
|
if (this->started_) {
|
||||||
if (!this->modem_ready()) {
|
if (!this->modem_ready()) {
|
||||||
// ESP_LOGW(TAG, "Trying to recover dce");
|
ESP_LOGD(TAG, "Modem not responding. Trying to recover...");
|
||||||
// ESP_ERROR_CHECK_WITHOUT_ABORT(this->dce->recover());
|
|
||||||
// delay(1000);
|
// Errors are not checked, because some commands return FAIL, but make the modem to answer again...
|
||||||
// ESP_LOGW(TAG, "Forcing undef mode");
|
ESP_LOGV(TAG, "Forcing cmux manual mode mode");
|
||||||
// ESP_ERROR_CHECK_WITHOUT_ABORT(this->dce->set_mode(esp_modem::modem_mode::UNDEF));
|
this->dce->set_mode(esp_modem::modem_mode::CMUX_MANUAL_MODE);
|
||||||
// delay(1000);
|
|
||||||
ESP_LOGW(TAG, "Forcing cmux manual mode mode");
|
|
||||||
ESP_ERROR_CHECK_WITHOUT_ABORT(this->dce->set_mode(esp_modem::modem_mode::CMUX_MANUAL_MODE));
|
|
||||||
delay(1000); // NOLINT
|
delay(1000); // NOLINT
|
||||||
// // ESP_LOGW(TAG, "Trying to recover dce");
|
ESP_LOGV(TAG, "Forcing cmux manual command mode");
|
||||||
// // ESP_ERROR_CHECK_WITHOUT_ABORT(this->dce->recover());
|
this->dce->set_mode(esp_modem::modem_mode::CMUX_MANUAL_COMMAND);
|
||||||
// // delay(1000);
|
|
||||||
ESP_LOGW(TAG, "Forcing cmux manual command mode");
|
|
||||||
ESP_ERROR_CHECK_WITHOUT_ABORT(this->dce->set_mode(esp_modem::modem_mode::CMUX_MANUAL_COMMAND));
|
|
||||||
delay(1000); // NOLINT
|
delay(1000); // NOLINT
|
||||||
ESP_LOGW(TAG, "Forcing cmux manual exit mode");
|
ESP_LOGW(TAG, "Forcing cmux manual exit mode");
|
||||||
ESP_ERROR_CHECK_WITHOUT_ABORT(this->dce->set_mode(esp_modem::modem_mode::CMUX_MANUAL_EXIT));
|
this->dce->set_mode(esp_modem::modem_mode::CMUX_MANUAL_EXIT);
|
||||||
delay(1000); // NOLINT
|
delay(1000); // NOLINT
|
||||||
// ESP_LOGW(TAG, "Forcing command mode");
|
|
||||||
// ESP_ERROR_CHECK_WITHOUT_ABORT(this->dce->set_mode(esp_modem::modem_mode::COMMAND_MODE));
|
|
||||||
// delay(1000);
|
|
||||||
// ESP_LOGW(TAG, "Forcing reset");
|
|
||||||
// this->dce->reset();
|
|
||||||
// ESP_LOGW(TAG, "Forcing hangup");
|
|
||||||
// this->dce->hang_up();
|
|
||||||
// this->send_at("AT+CGATT=0"); // disconnect network
|
|
||||||
// delay(1000);
|
|
||||||
// this->send_at("ATH"); // hangup
|
|
||||||
// delay(1000);
|
|
||||||
// delay(1000);
|
|
||||||
// ESP_LOGW(TAG, "Forcing disconnect");
|
|
||||||
// this->send_at("AT+CGATT=0"); // disconnect network
|
|
||||||
// delay(1000);
|
|
||||||
// ESP_LOGW(TAG, "Unable to sync modem");
|
|
||||||
if (!this->modem_ready()) {
|
if (!this->modem_ready()) {
|
||||||
this->on_not_responding_callback_.call();
|
this->on_not_responding_callback_.call();
|
||||||
// if (this->on_script_ != nullptr) {
|
}
|
||||||
// ESP_LOGD(TAG, "Executing recover_script");
|
if (this->modem_ready()) {
|
||||||
// this->on_script_->execute();
|
ESP_LOGI(TAG, "Modem is ready");
|
||||||
// } else {
|
|
||||||
// ESP_LOGE(TAG, "Modem not responding, and no recover_script");
|
|
||||||
// }
|
|
||||||
} else {
|
|
||||||
ESP_LOGD(TAG, "Modem is ready");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGI(TAG, "Starting modem connection");
|
ESP_LOGI(TAG, "Starting modem connection");
|
||||||
|
|
Loading…
Reference in a new issue