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 {
|
||||
|
||||
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)
|
||||
return;
|
||||
arg->can_send = can_send;
|
||||
|
@ -343,7 +343,7 @@ void EbyteLoraComponent::get_current_config_() {
|
|||
}
|
||||
ModeType EbyteLoraComponent::get_mode_() {
|
||||
ModeType internal_mode = MODE_INIT;
|
||||
if (!this->can_send_) {
|
||||
if (!this->store_.can_send) {
|
||||
ESP_LOGD(TAG, "Can't sent it right now");
|
||||
return internal_mode;
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ ModeType EbyteLoraComponent::get_mode_() {
|
|||
return internal_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");
|
||||
return;
|
||||
}
|
||||
|
@ -509,8 +509,6 @@ void EbyteLoraComponent::process_(uint8_t *buf, const size_t len) {
|
|||
}
|
||||
};
|
||||
void EbyteLoraComponent::loop() {
|
||||
this->can_send_ = this->store_.can_send;
|
||||
|
||||
if (auto len = this->available()) {
|
||||
uint8_t 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;
|
||||
}
|
||||
void EbyteLoraComponent::send_data_(bool all) {
|
||||
if (!this->can_send_) {
|
||||
if (!this->store_.can_send) {
|
||||
ESP_LOGD(TAG, "Can't sent it right now");
|
||||
return;
|
||||
}
|
||||
|
@ -595,7 +593,7 @@ void EbyteLoraComponent::send_data_(bool all) {
|
|||
}
|
||||
|
||||
void EbyteLoraComponent::send_repeater_info_() {
|
||||
if (!this->can_send_) {
|
||||
if (!this->store_.can_send) {
|
||||
ESP_LOGD(TAG, "Can't sent it right now");
|
||||
return;
|
||||
}
|
||||
|
@ -607,7 +605,7 @@ void EbyteLoraComponent::send_repeater_info_() {
|
|||
this->write_array(data, sizeof(data));
|
||||
}
|
||||
void EbyteLoraComponent::request_repeater_info_() {
|
||||
if (!this->can_send_) {
|
||||
if (!this->store_.can_send) {
|
||||
ESP_LOGD(TAG, "Can't sent it right now");
|
||||
return;
|
||||
}
|
||||
|
@ -619,7 +617,7 @@ void EbyteLoraComponent::request_repeater_info_() {
|
|||
}
|
||||
void EbyteLoraComponent::repeat_message_(uint8_t *buf) {
|
||||
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");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -131,7 +131,6 @@ class EbyteLoraComponent : public PollingComponent, public uart::UARTDevice {
|
|||
int network_id_ = 0;
|
||||
int rssi_ = 0;
|
||||
EbyteAuxStore store_;
|
||||
bool can_send_ = true;
|
||||
RegisterConfig current_config_;
|
||||
RegisterConfig expected_config_;
|
||||
#ifdef USE_SENSOR
|
||||
|
|
Loading…
Reference in a new issue