From 17102a1a7d954eee370ab510c839531572babd4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Mon, 29 May 2023 18:33:43 +0200 Subject: [PATCH] Somfy: improve status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Fernández Rojas --- Somfy.cpp | 2 +- Somfy.h | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Somfy.cpp b/Somfy.cpp index c3430d0..e59a6eb 100644 --- a/Somfy.cpp +++ b/Somfy.cpp @@ -177,7 +177,7 @@ void somfy_frame_t::decodeFrame(byte* frame) { break; case somfy_commands::Status: this->rollingCode = 0; - this->sun = !!(decoded[3] & STATUS_SUN); + this->status = decoded[3]; break; case somfy_commands::UnknownC: case somfy_commands::UnknownD: diff --git a/Somfy.h b/Somfy.h index a6d77ee..e64a565 100644 --- a/Somfy.h +++ b/Somfy.h @@ -52,12 +52,6 @@ somfy_commands translateSomfyCommand(const String& string); #define MAX_RX_BUFFER 3 #define MAX_TX_BUFFER 3 -#if !defined(BIT) -#define BIT(x) (1 << (x)) -#endif /* BIT */ - -#define STATUS_SUN BIT(1) - typedef enum { waiting_synchro = 0, receiving_data = 1, @@ -100,6 +94,11 @@ typedef struct somfy_tx_queue_t { bool pop(somfy_tx_t *tx); bool push(uint32_t await, somfy_commands cmd, uint8_t repeats); }; + +typedef enum { + no_sun = 0, + sun = 2 +} somfy_status_t; typedef struct somfy_frame_t { bool valid = false; bool processed = false; @@ -116,7 +115,7 @@ typedef struct somfy_frame_t { uint32_t await = 0; uint8_t bitLength = 56; uint16_t pulseCount = 0; - bool sun = false; + somfy_status_t status = no_sun; void print(); void encodeFrame(byte *frame); void decodeFrame(byte* frame);