diff --git a/components/ratgdo/number/ratgdo_number.cpp b/components/ratgdo/number/ratgdo_number.cpp index f78b93b..9fde5a0 100644 --- a/components/ratgdo/number/ratgdo_number.cpp +++ b/components/ratgdo/number/ratgdo_number.cpp @@ -27,7 +27,7 @@ namespace ratgdo { this->pref_ = global_preferences->make_preference(this->get_object_id_hash()); if (!this->pref_.load(&value)) { if (this->number_type_ == RATGDO_CLIENT_ID) { - value = random(0x1, 0xFFFF); + value = ((random_uint32() + 1) % 0xFFFF) << 12 | 0x539; } else { value = 0; } @@ -82,7 +82,7 @@ namespace ratgdo { } else if (this->number_type_ == RATGDO_CLIENT_ID) { this->parent_->set_client_id(value); } - this->pref_.save(&value); + this->update_state(value); } } // namespace ratgdo diff --git a/components/ratgdo/ratgdo.cpp b/components/ratgdo/ratgdo.cpp index 105af15..cd48835 100644 --- a/components/ratgdo/ratgdo.cpp +++ b/components/ratgdo/ratgdo.cpp @@ -101,7 +101,7 @@ namespace ratgdo { uint16_t cmd = ((fixed >> 24) & 0xf00) | (data & 0xff); 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); return static_cast(Command::UNKNOWN); } else { @@ -547,9 +547,7 @@ namespace ratgdo { return; } - // Sometimes the door doesn't always close when its fully open - // so we use ensure_door_command to make sure it closes - this->ensure_door_command(data::DOOR_CLOSE); + this->door_command(data::DOOR_CLOSE); } void RATGDOComponent::stop_door() diff --git a/components/ratgdo/ratgdo.h b/components/ratgdo/ratgdo.h index e629796..a42af7e 100644 --- a/components/ratgdo/ratgdo.h +++ b/components/ratgdo/ratgdo.h @@ -133,7 +133,7 @@ namespace ratgdo { 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_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(); uint16_t decode_packet(const WirePacket& packet);