@@ -313,6 +313,7 @@ void somfy_frame_t::encode80BitFrame(byte *frame, uint8_t repeat) {
313313}
314314void 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 ; }
435437bool somfy_frame_t::isRepeat (somfy_frame_t &frame) { return this ->remoteAddress == frame.remoteAddress && this ->cmd == frame.cmd && this ->rollingCode == frame.rollingCode ; }
436438void 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 ;
0 commit comments