parent
e2f4b6ec5f
commit
8317f18b86
|
@ -27,7 +27,7 @@ namespace ratgdo {
|
||||||
this->pref_ = global_preferences->make_preference<float>(this->get_object_id_hash());
|
this->pref_ = global_preferences->make_preference<float>(this->get_object_id_hash());
|
||||||
if (!this->pref_.load(&value)) {
|
if (!this->pref_.load(&value)) {
|
||||||
if (this->number_type_ == RATGDO_CLIENT_ID) {
|
if (this->number_type_ == RATGDO_CLIENT_ID) {
|
||||||
value = random(0x1, 0xFFFF);
|
value = ((random_uint32() + 1) % 0xFFFF) << 12 | 0x539;
|
||||||
} else {
|
} else {
|
||||||
value = 0;
|
value = 0;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ namespace ratgdo {
|
||||||
} else if (this->number_type_ == RATGDO_CLIENT_ID) {
|
} else if (this->number_type_ == RATGDO_CLIENT_ID) {
|
||||||
this->parent_->set_client_id(value);
|
this->parent_->set_client_id(value);
|
||||||
}
|
}
|
||||||
this->pref_.save(&value);
|
this->update_state(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ratgdo
|
} // namespace ratgdo
|
||||||
|
|
|
@ -101,7 +101,7 @@ namespace ratgdo {
|
||||||
uint16_t cmd = ((fixed >> 24) & 0xf00) | (data & 0xff);
|
uint16_t cmd = ((fixed >> 24) & 0xf00) | (data & 0xff);
|
||||||
data &= ~0xf000; // clear parity nibble
|
data &= ~0xf000; // clear parity nibble
|
||||||
|
|
||||||
if ((fixed & 0xfffffff) == this->client_id_) { // my commands
|
if ((fixed & 0xFFFFFFFF) == this->client_id_) { // my commands
|
||||||
ESP_LOG1(TAG, "[%ld] received mine: rolling=%07" PRIx32 " fixed=%010" PRIx64 " data=%08" PRIx32, millis(), rolling, fixed, data);
|
ESP_LOG1(TAG, "[%ld] received mine: rolling=%07" PRIx32 " fixed=%010" PRIx64 " data=%08" PRIx32, millis(), rolling, fixed, data);
|
||||||
return static_cast<uint16_t>(Command::UNKNOWN);
|
return static_cast<uint16_t>(Command::UNKNOWN);
|
||||||
} else {
|
} else {
|
||||||
|
@ -547,9 +547,7 @@ namespace ratgdo {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sometimes the door doesn't always close when its fully open
|
this->door_command(data::DOOR_CLOSE);
|
||||||
// so we use ensure_door_command to make sure it closes
|
|
||||||
this->ensure_door_command(data::DOOR_CLOSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RATGDOComponent::stop_door()
|
void RATGDOComponent::stop_door()
|
||||||
|
|
|
@ -133,7 +133,7 @@ namespace ratgdo {
|
||||||
void set_output_gdo_pin(InternalGPIOPin* pin) { this->output_gdo_pin_ = pin; }
|
void set_output_gdo_pin(InternalGPIOPin* pin) { this->output_gdo_pin_ = pin; }
|
||||||
void set_input_gdo_pin(InternalGPIOPin* pin) { this->input_gdo_pin_ = pin; }
|
void set_input_gdo_pin(InternalGPIOPin* pin) { this->input_gdo_pin_ = pin; }
|
||||||
void set_input_obst_pin(InternalGPIOPin* pin) { this->input_obst_pin_ = pin; }
|
void set_input_obst_pin(InternalGPIOPin* pin) { this->input_obst_pin_ = pin; }
|
||||||
void set_client_id(uint64_t client_id) { this->client_id_ = client_id & 0xffffff; } // not sure how large client_id can be, assuming not more than 24 bits
|
void set_client_id(uint64_t client_id) { this->client_id_ = client_id & 0xFFFFFFFF; }
|
||||||
|
|
||||||
void gdo_state_loop();
|
void gdo_state_loop();
|
||||||
uint16_t decode_packet(const WirePacket& packet);
|
uint16_t decode_packet(const WirePacket& packet);
|
||||||
|
|
Loading…
Reference in New Issue