fix
This commit is contained in:
parent
aecee4306e
commit
a80317ac88
|
@ -81,7 +81,7 @@ namespace ratgdo {
|
||||||
ESP_LOGCONFIG(TAG, " Rolling Code Counter: %d", this->rollingCodeCounter);
|
ESP_LOGCONFIG(TAG, " Rolling Code Counter: %d", this->rollingCodeCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RATGDOComponent::readRollingCode(uint8_t& door, uint8_t& light, uint8_t& lock, uint8_t& motion, uint8_t& obstruction, uint8_t& motor)
|
void RATGDOComponent::readRollingCode(bool &isStatus, uint8_t& door, uint8_t& light, uint8_t& lock, uint8_t& motion, uint8_t& obstruction, uint8_t& motor)
|
||||||
{
|
{
|
||||||
uint32_t rolling = 0;
|
uint32_t rolling = 0;
|
||||||
uint64_t fixed = 0;
|
uint64_t fixed = 0;
|
||||||
|
@ -109,12 +109,7 @@ namespace ratgdo {
|
||||||
motor = 0; // when the status message is read, reset motor state to 0|off
|
motor = 0; // when the status message is read, reset motor state to 0|off
|
||||||
// obstruction = (byte1 >> 6) & 1; // unreliable due to the time it takes to register an obstruction
|
// obstruction = (byte1 >> 6) & 1; // unreliable due to the time it takes to register an obstruction
|
||||||
ESP_LOGD(TAG, "Door: %d Light: %d Lock: %d Motion: %d Obstruction: %d", door, light, lock, motion, obstruction);
|
ESP_LOGD(TAG, "Door: %d Light: %d Lock: %d Motion: %d Obstruction: %d", door, light, lock, motion, obstruction);
|
||||||
if (this->forceUpdate_) {
|
isStatus = true;
|
||||||
this->forceUpdate_ = false;
|
|
||||||
this->previousDoorState = DoorState::DOOR_STATE_UNKNOWN;
|
|
||||||
this->previousLightState = LightState::LIGHT_STATE_UNKNOWN;
|
|
||||||
this->previousLockState = LockState::LOCK_STATE_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (cmd == 0x281) {
|
} else if (cmd == 0x281) {
|
||||||
light ^= 1; // toggle bit
|
light ^= 1; // toggle bit
|
||||||
|
@ -287,6 +282,11 @@ namespace ratgdo {
|
||||||
|
|
||||||
void RATGDOComponent::gdoStateLoop()
|
void RATGDOComponent::gdoStateLoop()
|
||||||
{
|
{
|
||||||
|
static uint32_t msgStart;
|
||||||
|
static bool reading = false;
|
||||||
|
static uint16_t byteCount = 0;
|
||||||
|
static bool isStatus = false;
|
||||||
|
|
||||||
while (this->available()) {
|
while (this->available()) {
|
||||||
// ESP_LOGD(TAG, "No data available input:%d output:%d", this->input_gdo_pin_->get_pin(), this->output_gdo_pin_->get_pin());
|
// ESP_LOGD(TAG, "No data available input:%d output:%d", this->input_gdo_pin_->get_pin(), this->output_gdo_pin_->get_pin());
|
||||||
uint8_t serData;
|
uint8_t serData;
|
||||||
|
@ -294,11 +294,6 @@ namespace ratgdo {
|
||||||
ESP_LOGD(TAG, "Failed to read byte");
|
ESP_LOGD(TAG, "Failed to read byte");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t msgStart;
|
|
||||||
static bool reading = false;
|
|
||||||
static uint16_t byteCount = 0;
|
|
||||||
|
|
||||||
if (!reading) {
|
if (!reading) {
|
||||||
// shift serial byte onto msg start
|
// shift serial byte onto msg start
|
||||||
msgStart <<= 8;
|
msgStart <<= 8;
|
||||||
|
@ -317,9 +312,7 @@ namespace ratgdo {
|
||||||
reading = true;
|
reading = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (reading) {
|
|
||||||
this->rxRollingCode[byteCount] = serData;
|
this->rxRollingCode[byteCount] = serData;
|
||||||
byteCount++;
|
byteCount++;
|
||||||
|
|
||||||
|
@ -327,8 +320,14 @@ namespace ratgdo {
|
||||||
reading = false;
|
reading = false;
|
||||||
msgStart = 0;
|
msgStart = 0;
|
||||||
byteCount = 0;
|
byteCount = 0;
|
||||||
|
readRollingCode(isStatus, this->doorState, this->lightState, this->lockState, this->motionState, this->obstructionState, this->motorState);
|
||||||
readRollingCode(this->doorState, this->lightState, this->lockState, this->motionState, this->obstructionState, this->motorState);
|
if (isStatus && this->forceUpdate_) {
|
||||||
|
this->forceUpdate_ = false;
|
||||||
|
this->previousDoorState = DoorState::DOOR_STATE_UNKNOWN;
|
||||||
|
this->previousLightState = LightState::LIGHT_STATE_UNKNOWN;
|
||||||
|
this->previousLockState = LockState::LOCK_STATE_UNKNOWN;
|
||||||
|
}
|
||||||
|
isStatus = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ namespace ratgdo {
|
||||||
void getRollingCode(Commands command);
|
void getRollingCode(Commands command);
|
||||||
void gdoStateLoop();
|
void gdoStateLoop();
|
||||||
void statusUpdateLoop();
|
void statusUpdateLoop();
|
||||||
void readRollingCode(uint8_t& door, uint8_t& light, uint8_t& lock, uint8_t& motion, uint8_t& obstruction, uint8_t& motor);
|
void readRollingCode(bool &isStatus, uint8_t& door, uint8_t& light, uint8_t& lock, uint8_t& motion, uint8_t& obstruction, uint8_t& motor);
|
||||||
void incrementRollingCodeCounter();
|
void incrementRollingCodeCounter();
|
||||||
void sendRollingCodeChanged();
|
void sendRollingCodeChanged();
|
||||||
void setRollingCodeCounter(uint32_t counter);
|
void setRollingCodeCounter(uint32_t counter);
|
||||||
|
|
Loading…
Reference in New Issue