Skip to content

Commit cf7a9b1

Browse files
author
Robert Strouse
committed
Fixes for TaHoma hub #393
1 parent 473307b commit cf7a9b1

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

Somfy.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ void somfy_frame_t::encode80BitFrame(byte *frame, uint8_t repeat) {
313313
}
314314
void somfy_frame_t::encodeFrame(byte *frame) {
315315
const byte btn = static_cast<byte>(cmd);
316+
this->valid = true;
316317
frame[0] = this->encKey; // Encryption key. Doesn't matter much
317318
frame[1] = (btn & 0x0F) << 4; // Which button did you press? The 4 LSB will be the checksum
318319
frame[2] = this->rollingCode >> 8; // Rolling code (big endian)
@@ -432,6 +433,7 @@ void somfy_frame_t::print() {
432433
Serial.print(" CS:");
433434
Serial.println(this->checksum);
434435
}
436+
bool somfy_frame_t::isSynonym(somfy_frame_t &frame) { return this->remoteAddress == frame.remoteAddress && this->cmd != frame.cmd && this->rollingCode == frame.rollingCode; }
435437
bool somfy_frame_t::isRepeat(somfy_frame_t &frame) { return this->remoteAddress == frame.remoteAddress && this->cmd == frame.cmd && this->rollingCode == frame.rollingCode; }
436438
void somfy_frame_t::copy(somfy_frame_t &frame) {
437439
if(this->isRepeat(frame)) {
@@ -440,8 +442,9 @@ void somfy_frame_t::copy(somfy_frame_t &frame) {
440442
this->lqi = frame.lqi;
441443
}
442444
else {
445+
this->synonym = this->isSynonym(frame);
443446
this->valid = frame.valid;
444-
this->processed = frame.processed;
447+
if(!this->synonym) this->processed = frame.processed;
445448
this->rssi = frame.rssi;
446449
this->lqi = frame.lqi;
447450
this->cmd = frame.cmd;
@@ -2398,6 +2401,7 @@ void SomfyShade::processFrame(somfy_frame_t &frame, bool internal) {
23982401
this->lastFrame.await = curTime + 500;
23992402
}
24002403
else {
2404+
if(this->lastFrame.processed) return;
24012405
Serial.println("Moving to My target");
24022406
this->lastFrame.processed = true;
24032407
if(this->myTiltPos >= 0.0f && this->myTiltPos <= 100.0f) this->p_tiltTarget(this->myTiltPos);
@@ -2406,6 +2410,7 @@ void SomfyShade::processFrame(somfy_frame_t &frame, bool internal) {
24062410
}
24072411
}
24082412
else {
2413+
if(this->lastFrame.processed) return;
24092414
this->lastFrame.processed = true;
24102415
if(!internal) {
24112416
if(this->tiltType != tilt_types::tiltonly) this->p_target(this->currentPos);
@@ -2511,8 +2516,10 @@ void SomfyShade::processFrame(somfy_frame_t &frame, bool internal) {
25112516
this->lastFrame.processed = true;
25122517
this->p_target(this->currentPos);
25132518
this->p_tiltTarget(this->currentTiltPos);
2519+
this->emitCommand(cmd, internal ? "internal" : "remote", frame.remoteAddress);
25142520
break;
25152521
case somfy_commands::Favorite:
2522+
if(this->lastFrame.processed) return;
25162523
this->lastFrame.processed = true;
25172524
if(this->simMy()) {
25182525
this->moveToMyPosition();
@@ -3895,6 +3902,7 @@ void SomfyRemote::sendCommand(somfy_commands cmd, uint8_t repeat, uint8_t stepSi
38953902
this->lastFrame.repeats = repeat;
38963903
this->lastFrame.bitLength = this->bitLength;
38973904
this->lastFrame.stepSize = stepSize;
3905+
this->lastFrame.valid = true;
38983906
// Match the encKey to the rolling code. These keys range from 160 to 175.
38993907
this->lastFrame.encKey = 0xA0 | static_cast<uint8_t>(this->lastFrame.rollingCode & 0x000F);
39003908
this->lastFrame.proto = this->proto;

Somfy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ struct somfy_relay_t {
171171
struct somfy_frame_t {
172172
bool valid = false;
173173
bool processed = false;
174+
bool synonym = false;
174175
radio_proto proto = radio_proto::RTS;
175176
int rssi = 0;
176177
byte lqi = 0x0;
@@ -192,6 +193,7 @@ struct somfy_frame_t {
192193
void decodeFrame(byte* frame);
193194
void decodeFrame(somfy_rx_t *rx);
194195
bool isRepeat(somfy_frame_t &f);
196+
bool isSynonym(somfy_frame_t &f);
195197
void copy(somfy_frame_t &f);
196198
};
197199

SomfyController.ino.esp32.bin

112 Bytes
Binary file not shown.

SomfyController.ino.esp32s3.bin

64 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)