mirror of
https://github.com/esphome/esphome.git
synced 2024-11-24 07:58:09 +01:00
Add that logic, wrong way around
This commit is contained in:
parent
e4f83b15c0
commit
9efa534e8f
2 changed files with 7 additions and 10 deletions
|
@ -3,7 +3,7 @@ namespace esphome {
|
||||||
namespace ebyte_lora {
|
namespace ebyte_lora {
|
||||||
|
|
||||||
void IRAM_ATTR HOT EbyteAuxStore::gpio_intr(EbyteAuxStore *arg) {
|
void IRAM_ATTR HOT EbyteAuxStore::gpio_intr(EbyteAuxStore *arg) {
|
||||||
const bool can_send = arg->pin.digital_read();
|
const bool can_send = !arg->pin.digital_read();
|
||||||
if (can_send == arg->can_send)
|
if (can_send == arg->can_send)
|
||||||
return;
|
return;
|
||||||
arg->can_send = can_send;
|
arg->can_send = can_send;
|
||||||
|
@ -343,7 +343,7 @@ void EbyteLoraComponent::get_current_config_() {
|
||||||
}
|
}
|
||||||
ModeType EbyteLoraComponent::get_mode_() {
|
ModeType EbyteLoraComponent::get_mode_() {
|
||||||
ModeType internal_mode = MODE_INIT;
|
ModeType internal_mode = MODE_INIT;
|
||||||
if (!this->can_send_) {
|
if (!this->store_.can_send) {
|
||||||
ESP_LOGD(TAG, "Can't sent it right now");
|
ESP_LOGD(TAG, "Can't sent it right now");
|
||||||
return internal_mode;
|
return internal_mode;
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ ModeType EbyteLoraComponent::get_mode_() {
|
||||||
return internal_mode;
|
return internal_mode;
|
||||||
}
|
}
|
||||||
void EbyteLoraComponent::set_mode_(ModeType mode) {
|
void EbyteLoraComponent::set_mode_(ModeType mode) {
|
||||||
if (!this->can_send_) {
|
if (!this->store_.can_send) {
|
||||||
ESP_LOGD(TAG, "Can't sent it right now");
|
ESP_LOGD(TAG, "Can't sent it right now");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -509,8 +509,6 @@ void EbyteLoraComponent::process_(uint8_t *buf, const size_t len) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
void EbyteLoraComponent::loop() {
|
void EbyteLoraComponent::loop() {
|
||||||
this->can_send_ = this->store_.can_send;
|
|
||||||
|
|
||||||
if (auto len = this->available()) {
|
if (auto len = this->available()) {
|
||||||
uint8_t buf[len];
|
uint8_t buf[len];
|
||||||
this->read_array(buf, len);
|
this->read_array(buf, len);
|
||||||
|
@ -552,7 +550,7 @@ void EbyteLoraComponent::setup_conf_(uint8_t const *conf) {
|
||||||
this->current_config_.enable_rssi = (conf[8] >> 7) & 0b1;
|
this->current_config_.enable_rssi = (conf[8] >> 7) & 0b1;
|
||||||
}
|
}
|
||||||
void EbyteLoraComponent::send_data_(bool all) {
|
void EbyteLoraComponent::send_data_(bool all) {
|
||||||
if (!this->can_send_) {
|
if (!this->store_.can_send) {
|
||||||
ESP_LOGD(TAG, "Can't sent it right now");
|
ESP_LOGD(TAG, "Can't sent it right now");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -595,7 +593,7 @@ void EbyteLoraComponent::send_data_(bool all) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EbyteLoraComponent::send_repeater_info_() {
|
void EbyteLoraComponent::send_repeater_info_() {
|
||||||
if (!this->can_send_) {
|
if (!this->store_.can_send) {
|
||||||
ESP_LOGD(TAG, "Can't sent it right now");
|
ESP_LOGD(TAG, "Can't sent it right now");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -607,7 +605,7 @@ void EbyteLoraComponent::send_repeater_info_() {
|
||||||
this->write_array(data, sizeof(data));
|
this->write_array(data, sizeof(data));
|
||||||
}
|
}
|
||||||
void EbyteLoraComponent::request_repeater_info_() {
|
void EbyteLoraComponent::request_repeater_info_() {
|
||||||
if (!this->can_send_) {
|
if (!this->store_.can_send) {
|
||||||
ESP_LOGD(TAG, "Can't sent it right now");
|
ESP_LOGD(TAG, "Can't sent it right now");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -619,7 +617,7 @@ void EbyteLoraComponent::request_repeater_info_() {
|
||||||
}
|
}
|
||||||
void EbyteLoraComponent::repeat_message_(uint8_t *buf) {
|
void EbyteLoraComponent::repeat_message_(uint8_t *buf) {
|
||||||
ESP_LOGD(TAG, "Got some info that i need to repeat for network %u", buf[1]);
|
ESP_LOGD(TAG, "Got some info that i need to repeat for network %u", buf[1]);
|
||||||
if (!this->can_send_) {
|
if (!this->store_.can_send) {
|
||||||
ESP_LOGD(TAG, "Can't sent it right now");
|
ESP_LOGD(TAG, "Can't sent it right now");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,6 @@ class EbyteLoraComponent : public PollingComponent, public uart::UARTDevice {
|
||||||
int network_id_ = 0;
|
int network_id_ = 0;
|
||||||
int rssi_ = 0;
|
int rssi_ = 0;
|
||||||
EbyteAuxStore store_;
|
EbyteAuxStore store_;
|
||||||
bool can_send_ = true;
|
|
||||||
RegisterConfig current_config_;
|
RegisterConfig current_config_;
|
||||||
RegisterConfig expected_config_;
|
RegisterConfig expected_config_;
|
||||||
#ifdef USE_SENSOR
|
#ifdef USE_SENSOR
|
||||||
|
|
Loading…
Reference in a new issue