mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 17:27:59 +01:00
Update ebyte_lora_component.cpp
This commit is contained in:
parent
a1d2578c3e
commit
95b5962cca
1 changed files with 19 additions and 12 deletions
|
@ -290,10 +290,16 @@ void EbyteLoraComponent::setup() {
|
||||||
#ifdef USE_BINARY_SENSOR
|
#ifdef USE_BINARY_SENSOR
|
||||||
this->should_send_ |= !this->binary_sensors_.empty();
|
this->should_send_ |= !this->binary_sensors_.empty();
|
||||||
#endif
|
#endif
|
||||||
this->pin_aux_->pin_mode(gpio::FLAG_INPUT | gpio::FLAG_PULLUP);
|
this->pin_aux_->pin_mode(gpio::FLAG_INPUT);
|
||||||
this->pin_aux_->setup();
|
this->pin_aux_->setup();
|
||||||
this->pin_m0_->setup();
|
this->pin_m0_->setup();
|
||||||
|
this->pin_m0_->pin_mode(gpio::FLAG_OUTPUT);
|
||||||
|
this->pin_m0_->digital_write(HIGH);
|
||||||
this->pin_m1_->setup();
|
this->pin_m1_->setup();
|
||||||
|
this->pin_m1_->pin_mode(gpio::FLAG_OUTPUT);
|
||||||
|
this->pin_m1_->digital_write(HIGH);
|
||||||
|
delay(20);
|
||||||
|
set_mode_(NORMAL);
|
||||||
ESP_LOGD(TAG, "Setup success");
|
ESP_LOGD(TAG, "Setup success");
|
||||||
}
|
}
|
||||||
void EbyteLoraComponent::request_current_config_() {
|
void EbyteLoraComponent::request_current_config_() {
|
||||||
|
@ -302,8 +308,8 @@ void EbyteLoraComponent::request_current_config_() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this->get_mode_() != CONFIGURATION) {
|
if (this->get_mode_() != CONFIGURATION) {
|
||||||
ESP_LOGD(TAG, "Mode not set right, setting it to wat we got");
|
ESP_LOGD(TAG, "Mode not set right");
|
||||||
this->set_mode_(this->get_mode_());
|
delay(20);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,31 +343,33 @@ void EbyteLoraComponent::set_mode_(ModeType mode) {
|
||||||
ESP_LOGD(TAG, "The M0 and M1 pins is not set, this mean that you are connect directly the pins as you need!");
|
ESP_LOGD(TAG, "The M0 and M1 pins is not set, this mean that you are connect directly the pins as you need!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
delay(5);
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
this->pin_m0_->digital_write(false);
|
this->pin_m0_->digital_write(LOW);
|
||||||
this->pin_m1_->digital_write(false);
|
this->pin_m1_->digital_write(LOW);
|
||||||
ESP_LOGD(TAG, "MODE NORMAL!");
|
ESP_LOGD(TAG, "MODE NORMAL!");
|
||||||
break;
|
break;
|
||||||
case WOR_SEND:
|
case WOR_SEND:
|
||||||
this->pin_m0_->digital_write(true);
|
this->pin_m0_->digital_write(HIGH);
|
||||||
this->pin_m1_->digital_write(false);
|
this->pin_m1_->digital_write(LOW);
|
||||||
ESP_LOGD(TAG, "MODE WOR SEND!");
|
ESP_LOGD(TAG, "MODE WOR SEND!");
|
||||||
break;
|
break;
|
||||||
case WOR_RECEIVER:
|
case WOR_RECEIVER:
|
||||||
this->pin_m0_->digital_write(false);
|
this->pin_m0_->digital_write(LOW);
|
||||||
this->pin_m1_->digital_write(true);
|
this->pin_m1_->digital_write(HIGH);
|
||||||
ESP_LOGD(TAG, "MODE RECEIVING!");
|
ESP_LOGD(TAG, "MODE RECEIVING!");
|
||||||
break;
|
break;
|
||||||
case CONFIGURATION:
|
case CONFIGURATION:
|
||||||
this->pin_m0_->digital_write(true);
|
this->pin_m0_->digital_write(HIGH);
|
||||||
this->pin_m1_->digital_write(true);
|
this->pin_m1_->digital_write(HIGH);
|
||||||
ESP_LOGD(TAG, "MODE SLEEP and CONFIG!");
|
ESP_LOGD(TAG, "MODE SLEEP and CONFIG!");
|
||||||
break;
|
break;
|
||||||
case MODE_INIT:
|
case MODE_INIT:
|
||||||
ESP_LOGD(TAG, "Don't call this!");
|
ESP_LOGD(TAG, "Don't call this!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
delay(5);
|
||||||
this->current_mode_ = mode;
|
this->current_mode_ = mode;
|
||||||
}
|
}
|
||||||
bool EbyteLoraComponent::can_send_message_(const char *info) {
|
bool EbyteLoraComponent::can_send_message_(const char *info) {
|
||||||
|
@ -381,7 +389,6 @@ void EbyteLoraComponent::update() {
|
||||||
return;
|
return;
|
||||||
if (!this->current_config_.config_set) {
|
if (!this->current_config_.config_set) {
|
||||||
this->set_mode_(CONFIGURATION);
|
this->set_mode_(CONFIGURATION);
|
||||||
delay(5);
|
|
||||||
ESP_LOGD(TAG, "Config not set yet! Requesting");
|
ESP_LOGD(TAG, "Config not set yet! Requesting");
|
||||||
this->request_current_config_();
|
this->request_current_config_();
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue