mirror of
https://github.com/esphome/esphome.git
synced 2024-12-27 16:01:43 +01:00
add thisw
This commit is contained in:
parent
262a6be989
commit
6fed4d268f
2 changed files with 26 additions and 16 deletions
|
@ -4,6 +4,16 @@ namespace ebyte_lora {
|
||||||
static const uint8_t SWITCH_PUSH = 0x55;
|
static const uint8_t SWITCH_PUSH = 0x55;
|
||||||
static const uint8_t SWITCH_INFO = 0x66;
|
static const uint8_t SWITCH_INFO = 0x66;
|
||||||
static const uint8_t PROGRAM_CONF = 0xC1;
|
static const uint8_t PROGRAM_CONF = 0xC1;
|
||||||
|
void EbyteLoraComponent::update() {
|
||||||
|
if (get_mode_() != NORMAL) {
|
||||||
|
if (this->config.command == 0) {
|
||||||
|
ESP_LOGD(TAG, "Config not set yet!");
|
||||||
|
}
|
||||||
|
ESP_LOGD(TAG, "Mode was not set right");
|
||||||
|
set_mode_(NORMAL);
|
||||||
|
}
|
||||||
|
send_switch_info_();
|
||||||
|
}
|
||||||
void EbyteLoraComponent::setup() {
|
void EbyteLoraComponent::setup() {
|
||||||
this->pin_aux_->setup();
|
this->pin_aux_->setup();
|
||||||
this->pin_m0_->setup();
|
this->pin_m0_->setup();
|
||||||
|
@ -15,25 +25,24 @@ void EbyteLoraComponent::get_current_config_() {
|
||||||
set_mode_(CONFIGURATION);
|
set_mode_(CONFIGURATION);
|
||||||
uint8_t data[3] = {PROGRAM_CONF, 0x00, 0x08};
|
uint8_t data[3] = {PROGRAM_CONF, 0x00, 0x08};
|
||||||
this->write_array(data, sizeof(data));
|
this->write_array(data, sizeof(data));
|
||||||
RegisterConfig buffer;
|
|
||||||
if (!this->available()) {
|
if (!this->available()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (read_array((uint8_t *) &buffer, sizeof(buffer))) {
|
if (read_array((uint8_t *) &this->config, sizeof(this->config))) {
|
||||||
ESP_LOGD(TAG, "Found config");
|
ESP_LOGD(TAG, "Found config");
|
||||||
ESP_LOGD(TAG, buffer.addh_description_().c_str());
|
ESP_LOGD(TAG, this->config.addh_description_().c_str());
|
||||||
ESP_LOGD(TAG, buffer.addl_description_().c_str());
|
ESP_LOGD(TAG, this->config.addl_description_().c_str());
|
||||||
ESP_LOGD(TAG, buffer.reg_0.air_data_rate_description_().c_str());
|
ESP_LOGD(TAG, this->config.reg_0.air_data_rate_description_().c_str());
|
||||||
ESP_LOGD(TAG, buffer.reg_0.uart_baud_description_().c_str());
|
ESP_LOGD(TAG, this->config.reg_0.uart_baud_description_().c_str());
|
||||||
ESP_LOGD(TAG, buffer.reg_0.parity_description_().c_str());
|
ESP_LOGD(TAG, this->config.reg_0.parity_description_().c_str());
|
||||||
ESP_LOGD(TAG, buffer.reg_1.rssi_noise_description_().c_str());
|
ESP_LOGD(TAG, this->config.reg_1.rssi_noise_description_().c_str());
|
||||||
ESP_LOGD(TAG, buffer.reg_1.sub_packet_description_().c_str());
|
ESP_LOGD(TAG, this->config.reg_1.sub_packet_description_().c_str());
|
||||||
ESP_LOGD(TAG, buffer.reg_1.transmission_power_description_().c_str());
|
ESP_LOGD(TAG, this->config.reg_1.transmission_power_description_().c_str());
|
||||||
ESP_LOGD(TAG, buffer.channel_description_().c_str());
|
ESP_LOGD(TAG, this->config.channel_description_().c_str());
|
||||||
ESP_LOGD(TAG, buffer.reg_3.enable_lbt_description_().c_str());
|
ESP_LOGD(TAG, this->config.reg_3.enable_lbt_description_().c_str());
|
||||||
ESP_LOGD(TAG, buffer.reg_3.wor_period_description_().c_str());
|
ESP_LOGD(TAG, this->config.reg_3.wor_period_description_().c_str());
|
||||||
ESP_LOGD(TAG, buffer.reg_3.enable_rssi_description_().c_str());
|
ESP_LOGD(TAG, this->config.reg_3.enable_rssi_description_().c_str());
|
||||||
ESP_LOGD(TAG, buffer.reg_3.transmission_type_description_().c_str());
|
ESP_LOGD(TAG, this->config.reg_3.transmission_type_description_().c_str());
|
||||||
set_mode_(NORMAL);
|
set_mode_(NORMAL);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGW(TAG, "Junk on wire. Throwing away partial message");
|
ESP_LOGW(TAG, "Junk on wire. Throwing away partial message");
|
||||||
|
|
|
@ -24,7 +24,7 @@ class EbyteLoraSwitch;
|
||||||
class EbyteLoraComponent : public PollingComponent, public uart::UARTDevice {
|
class EbyteLoraComponent : public PollingComponent, public uart::UARTDevice {
|
||||||
public:
|
public:
|
||||||
void setup() override;
|
void setup() override;
|
||||||
void update() override { send_switch_info_(); }
|
void update() override;
|
||||||
float get_setup_priority() const override { return setup_priority::HARDWARE; }
|
float get_setup_priority() const override { return setup_priority::HARDWARE; }
|
||||||
void loop() override;
|
void loop() override;
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
@ -55,6 +55,7 @@ class EbyteLoraComponent : public PollingComponent, public uart::UARTDevice {
|
||||||
uint32_t starting_to_check_;
|
uint32_t starting_to_check_;
|
||||||
uint32_t time_out_after_;
|
uint32_t time_out_after_;
|
||||||
std::string raw_message_;
|
std::string raw_message_;
|
||||||
|
RegisterConfig config;
|
||||||
sensor::Sensor *rssi_sensor_{nullptr};
|
sensor::Sensor *rssi_sensor_{nullptr};
|
||||||
GPIOPin *pin_aux_;
|
GPIOPin *pin_aux_;
|
||||||
GPIOPin *pin_m0_;
|
GPIOPin *pin_m0_;
|
||||||
|
|
Loading…
Reference in a new issue