button
This commit is contained in:
parent
1ac1c54841
commit
69b87e6318
|
@ -225,58 +225,59 @@ namespace ratgdo {
|
||||||
static uint16_t byteCount = 0;
|
static uint16_t byteCount = 0;
|
||||||
static bool isStatus = false;
|
static bool isStatus = false;
|
||||||
|
|
||||||
while (this->available()) {
|
if (!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;
|
return;
|
||||||
if (!this->read_byte(&serData)) {
|
}
|
||||||
ESP_LOGD(TAG, "Failed to read byte");
|
uint8_t serData;
|
||||||
|
if (!this->read_byte(&serData)) {
|
||||||
|
ESP_LOGD(TAG, "Failed to read byte");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!reading) {
|
||||||
|
// shift serial byte onto msg start
|
||||||
|
msgStart <<= 8;
|
||||||
|
msgStart |= serData;
|
||||||
|
|
||||||
|
// truncate to 3 bytes
|
||||||
|
msgStart &= 0x00FFFFFF;
|
||||||
|
|
||||||
|
// if we are at the start of a message, capture the next 16 bytes
|
||||||
|
if (msgStart == 0x550100) {
|
||||||
|
byteCount = 3;
|
||||||
|
rxRollingCode[0] = 0x55;
|
||||||
|
rxRollingCode[1] = 0x01;
|
||||||
|
rxRollingCode[2] = 0x00;
|
||||||
|
|
||||||
|
reading = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!reading) {
|
}
|
||||||
// shift serial byte onto msg start
|
if (reading) {
|
||||||
msgStart <<= 8;
|
this->rxRollingCode[byteCount] = serData;
|
||||||
msgStart |= serData;
|
byteCount++;
|
||||||
|
|
||||||
// truncate to 3 bytes
|
if (byteCount == CODE_LENGTH) {
|
||||||
msgStart &= 0x00FFFFFF;
|
reading = false;
|
||||||
|
msgStart = 0;
|
||||||
|
byteCount = 0;
|
||||||
|
isStatus = false;
|
||||||
|
|
||||||
// if we are at the start of a message, capture the next 16 bytes
|
readRollingCode(
|
||||||
if (msgStart == 0x550100) {
|
isStatus,
|
||||||
byteCount = 3;
|
this->doorState,
|
||||||
rxRollingCode[0] = 0x55;
|
this->lightState,
|
||||||
rxRollingCode[1] = 0x01;
|
this->lockState,
|
||||||
rxRollingCode[2] = 0x00;
|
this->motionState,
|
||||||
|
this->obstructionState,
|
||||||
reading = true;
|
this->motorState,
|
||||||
return;
|
this->openings,
|
||||||
}
|
this->buttonState);
|
||||||
}
|
if (isStatus && this->forceUpdate_) {
|
||||||
if (reading) {
|
this->forceUpdate_ = false;
|
||||||
this->rxRollingCode[byteCount] = serData;
|
this->previousDoorState = DoorState::DOOR_STATE_UNKNOWN;
|
||||||
byteCount++;
|
this->previousLightState = LightState::LIGHT_STATE_UNKNOWN;
|
||||||
|
this->previousLockState = LockState::LOCK_STATE_UNKNOWN;
|
||||||
if (byteCount == CODE_LENGTH) {
|
|
||||||
reading = false;
|
|
||||||
msgStart = 0;
|
|
||||||
byteCount = 0;
|
|
||||||
isStatus = false;
|
|
||||||
|
|
||||||
readRollingCode(
|
|
||||||
isStatus,
|
|
||||||
this->doorState,
|
|
||||||
this->lightState,
|
|
||||||
this->lockState,
|
|
||||||
this->motionState,
|
|
||||||
this->obstructionState,
|
|
||||||
this->motorState,
|
|
||||||
this->openings,
|
|
||||||
this->buttonState);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue