From d4bf9a148625d771b6f0ae19fa61e72e8f5723db Mon Sep 17 00:00:00 2001 From: basty149 Date: Mon, 7 Sep 2020 18:21:27 +0200 Subject: [PATCH 01/15] Initial import before cleanup --- RFLink/Plugins/Plugin_083.c | 460 ++++++++++++++++++++++++++++++++++++ 1 file changed, 460 insertions(+) create mode 100755 RFLink/Plugins/Plugin_083.c diff --git a/RFLink/Plugins/Plugin_083.c b/RFLink/Plugins/Plugin_083.c new file mode 100755 index 00000000..a946a485 --- /dev/null +++ b/RFLink/Plugins/Plugin_083.c @@ -0,0 +1,460 @@ +//####################################################################################################### +//## This Plugin is only for use with the RFLink software package ## +//## Plugin-083: Brel Motor ## +//####################################################################################################### +/*********************************************************************************************\ + * This plugin takes care of decoding and encoding the Brel Motor / Dooya protocol (DC318/DC114) + * + * Author (present) : Sebastien LANGE + * Support (present) : https://github.com/couin3/RFLink + * Author (original) : Sebastien LANGE + * Support (original) : https://github.com/couin3/RFLink + * License : This code is free for use in any open source project when this header is included. + * Usage of any parts of this code in a commercial application is prohibited! + ********************************************************************************************* + * Changelog: v1.0 initial release + ********************************************************************************************* + * Technical Information: + * Decodes signals from a DOOYA receiver + * DOOYA protocol + * 1101 0110 1000 0000 1101 1111 1111 0000 + * AAAA AAAA AAAA AAAA AAAA AAAA BBBB CCCC + * + * A = Remote ID + * B = Remote channel + * C = Command (UP/STOP/DOWN/RESET) + * + * Sample: + * 20;XX;DEBUG;Pulses=82;Pulses(uSec)=4640,1504,192,640,192,640,512,320,192,608,512,320,192,640,480,320,480,352,160,640,512,320,192,640,160,640,192,640,160,640,160,640,192,640,512,320,480,320,160,640,160,640,480,320,160,640,160,640,160,672,160,640,192,640,192,640,192,640,192,640,192,640,192,640,512,352,160,640,160,640,160,640,512,320,512,320,512,320,480,320,160,4992; + \*********************************************************************************************/ +#define DOOYA_PLUGIN_ID 083 +#define PLUGIN_DESC_083 PSTR("DOOYA") +#define DOOYA_PULSECOUNT_1 82 +// #define DOOYA_PULSECOUNT_2 54 +// #define DOOYA_PULSECOUNT_3 60 +// #define DOOYA_PULSECOUNT_4 62 +// #define DOOYA_PULSECOUNT_5 68 +// #define DOOYA_PULSECOUNT_6 72 +// #define DOOYA_PULSECOUNT_6 84 + +#define DOOYA_MIDVALUE 384 / RAWSIGNAL_SAMPLE_RATE + +#define DOOYA_PULSEMIN 1600 / RAWSIGNAL_SAMPLE_RATE +#define DOOYA_PULSEMINMAX 2200 / RAWSIGNAL_SAMPLE_RATE +#define DOOYA_PULSEMAXMIN 3000 / RAWSIGNAL_SAMPLE_RATE + +#define DOOYA_NEAR_SYNC_START 36000 +#define DOOYA_EXACT_SYNC_END_1 0x1380 +// #define DOOYA_EXACT_SYNC_END_2 0x079C +// #define DOOYA_EXACT_SYNC_END_3 0x119C +// #define DOOYA_EXACT_SYNC_END_4 0x139C +// #define DOOYA_EXACT_SYNC_END_5 0x129C +// #define DOOYA_EXACT_SYNC_END_6 0x069C +// #define DOOYA_EXACT_SYNC_END_7 0x109C +// #define DOOYA_EXACT_SYNC_END_8 0x0e9C + +#define DOOYA_UP_COMMAND 0x11 // 0001 0001 +#define DOOYA_STOP_COMMAND 0x55 // 0101 0101 +#define DOOYA_DOWN_COMMAND 0x33 // 0011 0011 +#define DOOYA_SETUP_COMMAND 0xcc // 1100 1100 + + +#ifdef PLUGIN_083 +#include "../4_Display.h" + +boolean Plugin_083(byte function, char *string) +{ + // if ((RawSignal.Number != DOOYA_PULSECOUNT_1) + // && (RawSignal.Number != DOOYA_PULSECOUNT_2) + // && (RawSignal.Number != DOOYA_PULSECOUNT_3) + // && (RawSignal.Number != DOOYA_PULSECOUNT_4) + // && (RawSignal.Number != DOOYA_PULSECOUNT_5) + // && (RawSignal.Number != DOOYA_PULSECOUNT_6)) + // return false; + + int i; + + int last_byte = RawSignal.Pulses[RawSignal.Number-1]*0x100 + RawSignal.Pulses[RawSignal.Number]; + char dbuffer[64]; + + if (RawSignal.Number == DOOYA_PULSECOUNT_1 + // && last_byte == DOOYA_EXACT_SYNC_END_1 + ) + { + byte bbuffer[128]; + + sprintf_P(dbuffer, PSTR("Pulses %04d Multiply %04d Delay %04d : "), + RawSignal.Number, RawSignal.Multiply, RawSignal.Delay); + Serial.print(dbuffer); + + int j; + int buffer_index=0; + + // // Skip start and end sequence + for (j = 3; j < RawSignal.Number-1; j+=8) + { + byte short_bitstream=0; + + for (i = 0; i < 8; i+=2) + { + short_bitstream <<= 1; // Always shift + + // if (RawSignal.Pulses[j+i] < RawSignal.Pulses[j+i+1]) + if (RawSignal.Pulses[j+i] < DOOYA_MIDVALUE) + { + short_bitstream |= 0x0; // long bit = 0 + } + else + { + short_bitstream |= 0x1; // long bit = 1 + } + } + + bbuffer[buffer_index++]=short_bitstream; + sprintf(dbuffer, "0x%x ", short_bitstream); + Serial.print(dbuffer); + } + sprintf_P(dbuffer, PSTR("END %02x%02x"), RawSignal.Pulses[RawSignal.Number-1], RawSignal.Pulses[RawSignal.Number]); + Serial.print(dbuffer); + + Serial.print(F(";\r\n")); + /** + * bbuffer : + * [0-5] : ID + * [6] + * [7] : Channel + * [8-9] : COMMAND + **/ + + long address = bbuffer[0]*0x100000 + +bbuffer[1]*0x10000 + +bbuffer[2]*0x1000 + +bbuffer[3]*0x100 + +bbuffer[4]*0x10 + +bbuffer[5]; + + display_Header(); + display_Name(PSTR("BrelMotor")); + display_IDn(address, 6); + display_SWITCH(bbuffer[7]); + + int command = bbuffer[8]*0x10+bbuffer[9]; + + switch (command) + { + case DOOYA_UP_COMMAND: + display_Name(PSTR("CMD=UP")); + break; + case DOOYA_DOWN_COMMAND: + display_Name(PSTR("CMD=DOWN")); + break; + case DOOYA_STOP_COMMAND: + display_Name(PSTR("CMD=STOP")); + break; + case DOOYA_SETUP_COMMAND: + display_Name(PSTR("CMD=SETUP")); + break; + } + display_Footer(); + } + else + { + sprintf_P(dbuffer, PSTR("Pulses %04d END %02x%02x"), RawSignal.Number, RawSignal.Pulses[RawSignal.Number-1], RawSignal.Pulses[RawSignal.Number]); + Serial.println(dbuffer); + return false; + } + + RawSignal.Repeats = true; // suppress repeats of the same RF packet + RawSignal.Number = 0; + return true; +} +#endif // PLUGIN_0083 + +#ifdef PLUGIN_TX_083 +#include "../1_Radio.h" +#include "../2_Signal.h" +#include "../3_Serial.h" +#include + +#define DOOYA_RFSTART_0 4512 +#define DOOYA_RFSTART_1 1472 +#define DOOYA_RFEND_0 4992 +#define DOOYA_RFLOW 192 +#define DOOYA_RFHIGH 608 + +// void addLowHighSignalPulses(unsigned long low, unsigned long high, +// unsigned long value, int size, int *currrentPulses) { +// for (byte x = (*currrentPulses + size*2); x >= *currrentPulses; x = x - 2) +// { +// if ((value & 1) == 1) +// { +// RawSignal.Pulses[x] = low / RawSignal.Multiply; +// RawSignal.Pulses[x - 1] = high / RawSignal.Multiply; +// } +// else +// { +// RawSignal.Pulses[x] = high / RawSignal.Multiply; +// RawSignal.Pulses[x - 1] = low / RawSignal.Multiply; +// } +// value = value >> 1; +// } +// *currrentPulses+=size*2; +// } + +byte nibble2c(char c) +{ + if ((c>='0') && (c<='9')) + return c-'0' ; + if ((c>='A') && (c<='F')) + return c+10-'A' ; + if ((c>='a') && (c<='f')) + return c+10-'a' ; + return -1 ; +} + +void addLowHighSignalPulses(unsigned long low, unsigned long high, + char * hexvalue, int size, int *currrentPulses) { + // for (byte x = *currrentPulses; x <= (*currrentPulses + size*2); x = x + 2) + int i=0; + while (*(hexvalue+i) != '\0') + { + Serial.print(*(hexvalue+i)); + Serial.print("("); + + byte value = nibble2c(*(hexvalue+i)); + for (int x=0; x < 4; x++) + { + if ((value & B1000) == B1000) + { + Serial.print("1"); + RawSignal.Pulses[(*currrentPulses)++] = high / RawSignal.Multiply; + RawSignal.Pulses[(*currrentPulses)++] = low / RawSignal.Multiply; + } + else + { + Serial.print("0"); + RawSignal.Pulses[(*currrentPulses)++] = low / RawSignal.Multiply; + RawSignal.Pulses[(*currrentPulses)++] = high / RawSignal.Multiply; + } + value = value << 1; + } + Serial.print(")"); + i++; + } +} + +void debugRawSignal(int size) +{ + char dbuffer[64]; + + sprintf_P(dbuffer, PSTR("Pulses %04d Multiply %04d: "), + RawSignal.Number, RawSignal.Multiply, RawSignal.Time); + Serial.print(dbuffer); + + for (int i=0; i>= 1; +// } +// // Send sync +// digitalWrite(PIN_RF_TX_DATA, LOW); +// delayMicroseconds(periodSync); +// digitalWrite(PIN_RF_TX_DATA, HIGH); +// delayMicroseconds(period); +// } +// digitalWrite(PIN_RF_TX_DATA, LOW); +// } + +#endif // PLUGIN_083 + From 129c3aa80f894e84f54d835fc4602ffd4d72bd10 Mon Sep 17 00:00:00 2001 From: basty149 Date: Mon, 7 Sep 2020 23:22:36 +0200 Subject: [PATCH 02/15] Cleanup code --- RFLink/Plugins/Plugin_083.c | 176 +++++++++++------------------------- 1 file changed, 55 insertions(+), 121 deletions(-) diff --git a/RFLink/Plugins/Plugin_083.c b/RFLink/Plugins/Plugin_083.c index a946a485..5fc6f611 100755 --- a/RFLink/Plugins/Plugin_083.c +++ b/RFLink/Plugins/Plugin_083.c @@ -39,12 +39,12 @@ #define DOOYA_MIDVALUE 384 / RAWSIGNAL_SAMPLE_RATE -#define DOOYA_PULSEMIN 1600 / RAWSIGNAL_SAMPLE_RATE -#define DOOYA_PULSEMINMAX 2200 / RAWSIGNAL_SAMPLE_RATE -#define DOOYA_PULSEMAXMIN 3000 / RAWSIGNAL_SAMPLE_RATE +// #define DOOYA_PULSEMIN 1600 / RAWSIGNAL_SAMPLE_RATE +// #define DOOYA_PULSEMINMAX 2200 / RAWSIGNAL_SAMPLE_RATE +// #define DOOYA_PULSEMAXMIN 3000 / RAWSIGNAL_SAMPLE_RATE -#define DOOYA_NEAR_SYNC_START 36000 -#define DOOYA_EXACT_SYNC_END_1 0x1380 +// #define DOOYA_NEAR_SYNC_START 36000 +// #define DOOYA_EXACT_SYNC_END_1 0x1380 // #define DOOYA_EXACT_SYNC_END_2 0x079C // #define DOOYA_EXACT_SYNC_END_3 0x119C // #define DOOYA_EXACT_SYNC_END_4 0x139C @@ -74,7 +74,7 @@ boolean Plugin_083(byte function, char *string) int i; - int last_byte = RawSignal.Pulses[RawSignal.Number-1]*0x100 + RawSignal.Pulses[RawSignal.Number]; + // int last_byte = RawSignal.Pulses[RawSignal.Number-1]*0x100 + RawSignal.Pulses[RawSignal.Number]; char dbuffer[64]; if (RawSignal.Number == DOOYA_PULSECOUNT_1 @@ -83,14 +83,16 @@ boolean Plugin_083(byte function, char *string) { byte bbuffer[128]; +#ifdef PLUGIN_083_DEBUG sprintf_P(dbuffer, PSTR("Pulses %04d Multiply %04d Delay %04d : "), RawSignal.Number, RawSignal.Multiply, RawSignal.Delay); Serial.print(dbuffer); +#endif int j; int buffer_index=0; - // // Skip start and end sequence + // // Skip start [1] & [2] and end sequence for (j = 3; j < RawSignal.Number-1; j+=8) { byte short_bitstream=0; @@ -111,18 +113,21 @@ boolean Plugin_083(byte function, char *string) } bbuffer[buffer_index++]=short_bitstream; +#ifdef PLUGIN_083_DEBUG sprintf(dbuffer, "0x%x ", short_bitstream); Serial.print(dbuffer); +#endif } + +#ifdef PLUGIN_083_DEBUG sprintf_P(dbuffer, PSTR("END %02x%02x"), RawSignal.Pulses[RawSignal.Number-1], RawSignal.Pulses[RawSignal.Number]); Serial.print(dbuffer); - Serial.print(F(";\r\n")); +#endif /** * bbuffer : * [0-5] : ID - * [6] - * [7] : Channel + * [6-7] : Channel * [8-9] : COMMAND **/ @@ -159,8 +164,10 @@ boolean Plugin_083(byte function, char *string) } else { +#ifdef PLUGIN_083_DEBUG sprintf_P(dbuffer, PSTR("Pulses %04d END %02x%02x"), RawSignal.Number, RawSignal.Pulses[RawSignal.Number-1], RawSignal.Pulses[RawSignal.Number]); Serial.println(dbuffer); +#endif return false; } @@ -182,25 +189,9 @@ boolean Plugin_083(byte function, char *string) #define DOOYA_RFLOW 192 #define DOOYA_RFHIGH 608 -// void addLowHighSignalPulses(unsigned long low, unsigned long high, -// unsigned long value, int size, int *currrentPulses) { -// for (byte x = (*currrentPulses + size*2); x >= *currrentPulses; x = x - 2) -// { -// if ((value & 1) == 1) -// { -// RawSignal.Pulses[x] = low / RawSignal.Multiply; -// RawSignal.Pulses[x - 1] = high / RawSignal.Multiply; -// } -// else -// { -// RawSignal.Pulses[x] = high / RawSignal.Multiply; -// RawSignal.Pulses[x - 1] = low / RawSignal.Multiply; -// } -// value = value >> 1; -// } -// *currrentPulses+=size*2; -// } - +/** + * Convert Hex character to Hex value + **/ byte nibble2c(char c) { if ((c>='0') && (c<='9')) @@ -212,33 +203,47 @@ byte nibble2c(char c) return -1 ; } -void addLowHighSignalPulses(unsigned long low, unsigned long high, - char * hexvalue, int size, int *currrentPulses) { - // for (byte x = *currrentPulses; x <= (*currrentPulses + size*2); x = x + 2) +/* + * Add High et Low signal pulses to pulses array. + * Each bit from hex string will be encoded as High pulse and Low pulse + * hexvalue : Hex String to encode. + */ +void addHighLowSignalPulses(unsigned long high, unsigned long low, + char * hexvalue, int *currrentPulses) { + int i=0; while (*(hexvalue+i) != '\0') { +#ifdef PLUGIN_083_DEBUG Serial.print(*(hexvalue+i)); Serial.print("("); +#endif byte value = nibble2c(*(hexvalue+i)); for (int x=0; x < 4; x++) { if ((value & B1000) == B1000) { +#ifdef PLUGIN_083_DEBUG Serial.print("1"); +#endif RawSignal.Pulses[(*currrentPulses)++] = high / RawSignal.Multiply; RawSignal.Pulses[(*currrentPulses)++] = low / RawSignal.Multiply; } else { +#ifdef PLUGIN_083_DEBUG Serial.print("0"); +#endif RawSignal.Pulses[(*currrentPulses)++] = low / RawSignal.Multiply; RawSignal.Pulses[(*currrentPulses)++] = high / RawSignal.Multiply; } value = value << 1; } +#ifdef PLUGIN_083_DEBUG Serial.print(")"); +#endif + i++; } } @@ -259,6 +264,7 @@ void debugRawSignal(int size) Serial.println(); } + void sendRF(int currentPulses) { noInterrupts(); @@ -283,14 +289,18 @@ void addSinglePulse(unsigned long value, int *currrentPulses) boolean PluginTX_083(byte function, char *string) { +#ifdef PLUGIN_083_DEBUG Serial.println(F("PluginTX_083")); +#endif - char dbuffer[30] ; boolean success = false; unsigned long bitstream = 0L; +#ifdef PLUGIN_083_DEBUG + char dbuffer[30] ; sprintf_P(dbuffer, PSTR("%s"), string); Serial.println(dbuffer); +#endif //20;XX;DEBUG;Pulses=82;Pulses(uSec)=4704,1472,192,608,192,608,512,288,192,608,512,288,192,608,512,288,512,320,192,608,512,288,192,608,192,608,192,608,192,608,192,608,192,640,512,288,512,320,192,640,192,640,512,288,192,640,192,608,192,640,192,640,192,608,192,640,192,640,512,320,512,320,512,320,512,352,160,640,192,640,192,640,512,320,512,320,512,320,512,320,192,4992; @@ -304,16 +314,11 @@ boolean PluginTX_083(byte function, char *string) if (strncasecmp(string + 3, "BrelMotor;", 10) == 0) { - // // Override with 0x to conform strtoul base 16 - // string[11]='0'; - // string[12]='x'; - // sprintf_P(dbuffer, PSTR("%s"), string); - // Serial.println(dbuffer); - int command; char *strings[10]; char *ptr = NULL; + // Tokenize input string byte index = 0; ptr = strtok(string, ";"); // takes a list of delimiters while(ptr != NULL) @@ -327,8 +332,10 @@ boolean PluginTX_083(byte function, char *string) char * subaddress = strings[3]; char * commandstring = strings[4]; +#ifdef PLUGIN_083_DEBUG sprintf_P(dbuffer, PSTR("Send BrelMotor %s %s"), address, subaddress); Serial.println(dbuffer); +#endif if (strncasecmp(commandstring, "on", 2) == 0) command = DOOYA_UP_COMMAND; @@ -347,12 +354,13 @@ boolean PluginTX_083(byte function, char *string) if (command == 0) return false; +#ifdef PLUGIN_083_DEBUG sprintf_P(dbuffer, PSTR("Send BrelMotor %s %s %s"), address, subaddress, command); Serial.println(dbuffer); +#endif RawSignal.Repeats = 5; RawSignal.Multiply = 32; - // AC_Send(ADDRESS << 2 && SWITCH, command); int currentPulses=0; @@ -360,10 +368,11 @@ boolean PluginTX_083(byte function, char *string) addSinglePulse(DOOYA_RFSTART_0, ¤tPulses); addSinglePulse(DOOYA_RFSTART_1, ¤tPulses); // add Body - addLowHighSignalPulses(DOOYA_RFLOW, DOOYA_RFHIGH, address, 6*8, ¤tPulses); - addLowHighSignalPulses(DOOYA_RFLOW, DOOYA_RFHIGH, subaddress, 2*8, ¤tPulses); - sprintf_P(dbuffer, PSTR("%x"), command); - addLowHighSignalPulses(DOOYA_RFLOW, DOOYA_RFHIGH, dbuffer, 2*8, ¤tPulses); + addHighLowSignalPulses(DOOYA_RFHIGH, DOOYA_RFLOW, address, ¤tPulses); + addHighLowSignalPulses(DOOYA_RFHIGH, DOOYA_RFLOW, subaddress, ¤tPulses); + char buffercommand[3]; + sprintf_P(buffercommand, PSTR("%2x"), command); + addHighLowSignalPulses(DOOYA_RFHIGH, DOOYA_RFLOW, buffercommand, ¤tPulses); // add Footer addSinglePulse(0, ¤tPulses); addSinglePulse(DOOYA_RFEND_0, ¤tPulses); @@ -371,90 +380,15 @@ boolean PluginTX_083(byte function, char *string) RawSignal.Number = currentPulses; debugRawSignal(currentPulses); + // Amplify signal length from 32 (receipt) to 38 (emission) RawSignal.Multiply = 38; sendRF(currentPulses); return true; - //----------------------------------------------- - RawSignal.Multiply = 50; - RawSignal.Repeats = 10; - RawSignal.Delay = 20; - RawSignal.Pulses[currentPulses++] = DOOYA_RFLOW / RawSignal.Multiply; - RawSignal.Pulses[currentPulses++] = DOOYA_RFLOW / RawSignal.Multiply; - - // addLowHighSignalPulses(DOOYA_RFLOW, DOOYA_RFHIGH, ADDRESS, &currrentPulses, 6*8); - - // addLowHighSignalPulses(DOOYA_RFLOW, DOOYA_RFHIGH, SWITCH, &currrentPulses, 2*8); - - // addLowHighSignalPulses(DOOYA_RFLOW, DOOYA_RFHIGH, command, &currrentPulses, 2*8); - - RawSignal.Number = currentPulses; - - sprintf_P(dbuffer, PSTR("Pulses %04d END %02x%02x"), RawSignal.Number, RawSignal.Pulses[RawSignal.Number-1], RawSignal.Pulses[RawSignal.Number]); - Serial.println(dbuffer); - - return true; - - // RawSendRF(); - success = true; - //----------------------------------------------- } - return success; + return false; } -// void Deltronic_Send(unsigned long address) -// { -// byte repeatTimes = 16; -// byte repeat, index; -// int periodLong, periodSync; -// unsigned long bitmask; -// int period = 640; - -// periodLong = 2 * period; -// periodSync = 36 * period; - -// // Send seperator -// digitalWrite(PIN_RF_TX_DATA, HIGH); -// delayMicroseconds(period); - -// // Send sync -// digitalWrite(PIN_RF_TX_DATA, LOW); -// delayMicroseconds(periodSync); -// digitalWrite(PIN_RF_TX_DATA, HIGH); -// delayMicroseconds(period); - -// for (repeat = 0; repeat < repeatTimes; repeat++) -// { -// bitmask = 0x00000800L; -// for (index = 0; index < 12; index++) -// { -// if (address & bitmask) -// { -// // Send 1 -// digitalWrite(PIN_RF_TX_DATA, LOW); -// delayMicroseconds(periodLong); -// digitalWrite(PIN_RF_TX_DATA, HIGH); -// delayMicroseconds(period); -// } -// else -// { -// // Send 0 -// digitalWrite(PIN_RF_TX_DATA, LOW); -// delayMicroseconds(period); -// digitalWrite(PIN_RF_TX_DATA, HIGH); -// delayMicroseconds(periodLong); -// } -// bitmask >>= 1; -// } -// // Send sync -// digitalWrite(PIN_RF_TX_DATA, LOW); -// delayMicroseconds(periodSync); -// digitalWrite(PIN_RF_TX_DATA, HIGH); -// delayMicroseconds(period); -// } -// digitalWrite(PIN_RF_TX_DATA, LOW); -// } - #endif // PLUGIN_083 From 554f0e432352ca3e46f280c26f847e720a954058 Mon Sep 17 00:00:00 2001 From: basty149 Date: Tue, 8 Sep 2020 20:44:25 +0200 Subject: [PATCH 03/15] =?UTF-8?q?Optimisation=20m=C3=A9moire=20pour=20ARDU?= =?UTF-8?q?INO=20UNO=20(RAM=20limit=20to=202048=20bytes)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RFLink/5_Plugin.cpp | 383 +++++++++++++++++++++++++++++++++++++++++++- RFLink/5_Plugin.h | 6 +- 2 files changed, 386 insertions(+), 3 deletions(-) diff --git a/RFLink/5_Plugin.cpp b/RFLink/5_Plugin.cpp index 152215f3..ac953d27 100644 --- a/RFLink/5_Plugin.cpp +++ b/RFLink/5_Plugin.cpp @@ -24,7 +24,9 @@ boolean (*Plugin_ptr[PLUGIN_MAX])(byte, char *); // Receive plugins byte Plugin_id[PLUGIN_MAX]; byte Plugin_State[PLUGIN_MAX]; +#ifndef ARDUINO_AVR_UNO // Optimize memory limite to 2048 bytes on arduino uno String Plugin_Description[PLUGIN_MAX]; +#endif boolean (*PluginTX_ptr[PLUGIN_TX_MAX])(byte, char *); // Trasmit plugins byte PluginTX_id[PLUGIN_TX_MAX]; @@ -370,6 +372,7 @@ boolean QRFUDebug = QRFUDebug_0; // debug RF signals with plugin 254 but no mult #endif #ifdef PLUGIN_083 +//#define PLUGIN_083_DEBUG #include "./Plugins/Plugin_083.c" #endif @@ -554,764 +557,1142 @@ void PluginInit(void) { Plugin_ptr[x] = 0; Plugin_id[x] = 0; - Plugin_State[x] = P_Enabled; + Plugin_State[x] = P_Disabled; } x = 0; #ifdef PLUGIN_001 Plugin_id[x] = 1; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_001; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_001; #endif #ifdef PLUGIN_002 Plugin_id[x] = 2; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_002; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_002; #endif #ifdef PLUGIN_003 Plugin_id[x] = 3; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_003; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_003; #endif #ifdef PLUGIN_004 Plugin_id[x] = 4; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_004; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_004; #endif #ifdef PLUGIN_005 Plugin_id[x] = 5; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_005; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_005; #endif #ifdef PLUGIN_006 Plugin_id[x] = 6; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_006; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_006; #endif #ifdef PLUGIN_007 Plugin_id[x] = 7; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_007; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_007; #endif #ifdef PLUGIN_008 Plugin_id[x] = 8; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_008; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_008; #endif #ifdef PLUGIN_009 Plugin_id[x] = 9; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_009; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_009; #endif #ifdef PLUGIN_010 Plugin_id[x] = 10; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_010; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_010; #endif #ifdef PLUGIN_011 Plugin_id[x] = 11; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_011; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_011; #endif #ifdef PLUGIN_012 Plugin_id[x] = 12; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_012; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_012; #endif #ifdef PLUGIN_013 Plugin_id[x] = 13; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_013; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_013; #endif #ifdef PLUGIN_014 Plugin_id[x] = 14; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_014; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_014; #endif #ifdef PLUGIN_015 Plugin_id[x] = 15; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_015; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_015; #endif #ifdef PLUGIN_016 Plugin_id[x] = 16; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_016; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_016; #endif #ifdef PLUGIN_017 Plugin_id[x] = 17; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_017; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_017; #endif #ifdef PLUGIN_018 Plugin_id[x] = 18; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_018; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_018; #endif #ifdef PLUGIN_019 Plugin_id[x] = 19; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_019; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_019; #endif #ifdef PLUGIN_020 Plugin_id[x] = 20; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_020; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_020; #endif #ifdef PLUGIN_021 Plugin_id[x] = 21; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_021; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_021; #endif #ifdef PLUGIN_022 Plugin_id[x] = 22; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_022; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_022; #endif #ifdef PLUGIN_023 Plugin_id[x] = 23; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_023; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_023; #endif #ifdef PLUGIN_024 Plugin_id[x] = 24; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_024; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_024; #endif #ifdef PLUGIN_025 Plugin_id[x] = 25; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_025; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_025; #endif #ifdef PLUGIN_026 Plugin_id[x] = 26; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_026; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_026; #endif #ifdef PLUGIN_027 Plugin_id[x] = 27; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_027; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_027; #endif #ifdef PLUGIN_028 Plugin_id[x] = 28; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_028; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_028; #endif #ifdef PLUGIN_029 Plugin_id[x] = 29; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_029; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_029; #endif #ifdef PLUGIN_030 Plugin_id[x] = 30; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_030; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_030; #endif #ifdef PLUGIN_031 Plugin_id[x] = 31; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_031; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_031; #endif #ifdef PLUGIN_032 Plugin_id[x] = 32; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_032; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_032; #endif #ifdef PLUGIN_033 Plugin_id[x] = 33; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_033; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_033; #endif #ifdef PLUGIN_034 Plugin_id[x] = 34; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_034; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_034; #endif #ifdef PLUGIN_035 Plugin_id[x] = 35; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_035; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_035; #endif #ifdef PLUGIN_036 Plugin_id[x] = 36; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_036; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_036; #endif #ifdef PLUGIN_037 Plugin_id[x] = 37; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_037; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_037; #endif #ifdef PLUGIN_038 Plugin_id[x] = 38; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_038; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_038; #endif #ifdef PLUGIN_039 Plugin_id[x] = 39; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_039; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_039; #endif #ifdef PLUGIN_040 Plugin_id[x] = 40; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_040; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_040; #endif #ifdef PLUGIN_041 Plugin_id[x] = 41; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_041; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_041; #endif #ifdef PLUGIN_042 Plugin_id[x] = 42; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_042; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_042; #endif #ifdef PLUGIN_043 Plugin_id[x] = 43; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_043; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_043; #endif #ifdef PLUGIN_044 Plugin_id[x] = 44; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_044; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_044; #endif #ifdef PLUGIN_045 Plugin_id[x] = 45; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_045; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_045; #endif #ifdef PLUGIN_046 Plugin_id[x] = 46; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_046; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_046; #endif #ifdef PLUGIN_047 Plugin_id[x] = 47; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_047; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_047; #endif #ifdef PLUGIN_048 Plugin_id[x] = 48; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_048; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_048; #endif #ifdef PLUGIN_049 Plugin_id[x] = 49; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_049; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_049; #endif #ifdef PLUGIN_050 Plugin_id[x] = 50; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_050; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_050; #endif #ifdef PLUGIN_051 Plugin_id[x] = 51; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_051; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_051; #endif #ifdef PLUGIN_052 Plugin_id[x] = 52; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_052; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_052; #endif #ifdef PLUGIN_053 Plugin_id[x] = 53; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_053; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_053; #endif #ifdef PLUGIN_054 Plugin_id[x] = 54; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_054; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_054; #endif #ifdef PLUGIN_055 Plugin_id[x] = 55; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_055; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_055; #endif #ifdef PLUGIN_056 Plugin_id[x] = 56; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_056; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_056; #endif #ifdef PLUGIN_057 Plugin_id[x] = 57; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_057; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_057; #endif #ifdef PLUGIN_058 Plugin_id[x] = 58; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_058; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_058; #endif #ifdef PLUGIN_059 Plugin_id[x] = 59; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_059; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_059; #endif #ifdef PLUGIN_060 Plugin_id[x] = 60; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_060; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_060; #endif #ifdef PLUGIN_061 Plugin_id[x] = 61; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_061; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_061; #endif #ifdef PLUGIN_062 Plugin_id[x] = 62; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_062; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_062; #endif #ifdef PLUGIN_063 Plugin_id[x] = 63; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_063; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_063; #endif #ifdef PLUGIN_064 Plugin_id[x] = 64; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_064; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_064; #endif #ifdef PLUGIN_065 Plugin_id[x] = 65; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_065; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_065; #endif #ifdef PLUGIN_066 Plugin_id[x] = 66; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_066; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_066; #endif #ifdef PLUGIN_067 Plugin_id[x] = 67; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_067; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_067; #endif #ifdef PLUGIN_068 Plugin_id[x] = 68; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_068; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_068; #endif #ifdef PLUGIN_069 Plugin_id[x] = 69; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_069; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_069; #endif #ifdef PLUGIN_070 Plugin_id[x] = 70; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_070; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_070; #endif #ifdef PLUGIN_071 Plugin_id[x] = 71; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_071; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_071; #endif #ifdef PLUGIN_072 Plugin_id[x] = 72; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_072; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_072; #endif #ifdef PLUGIN_073 Plugin_id[x] = 73; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_073; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_073; #endif #ifdef PLUGIN_074 Plugin_id[x] = 74; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_074; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_074; #endif #ifdef PLUGIN_075 Plugin_id[x] = 75; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_075; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_075; #endif #ifdef PLUGIN_076 Plugin_id[x] = 76; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_076; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_076; #endif #ifdef PLUGIN_077 Plugin_id[x] = 77; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_077; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_077; #endif #ifdef PLUGIN_078 Plugin_id[x] = 78; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_078; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_078; #endif #ifdef PLUGIN_079 Plugin_id[x] = 79; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_079; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_079; #endif #ifdef PLUGIN_080 Plugin_id[x] = 80; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_080; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_080; #endif #ifdef PLUGIN_081 Plugin_id[x] = 81; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_081; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_081; #endif #ifdef PLUGIN_082 Plugin_id[x] = 82; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_082; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_082; #endif #ifdef PLUGIN_083 Plugin_id[x] = 83; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_083; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_083; #endif #ifdef PLUGIN_084 Plugin_id[x] = 84; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_084; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_084; #endif #ifdef PLUGIN_085 Plugin_id[x] = 85; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_085; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_085; #endif #ifdef PLUGIN_086 Plugin_id[x] = 86; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_086; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_086; #endif #ifdef PLUGIN_087 Plugin_id[x] = 87; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_087; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_087; #endif #ifdef PLUGIN_088 Plugin_id[x] = 88; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_088; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_088; #endif #ifdef PLUGIN_089 Plugin_id[x] = 89; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_089; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_089; #endif #ifdef PLUGIN_090 Plugin_id[x] = 90; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_090; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_090; #endif #ifdef PLUGIN_091 Plugin_id[x] = 91; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_091; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_091; #endif #ifdef PLUGIN_092 Plugin_id[x] = 92; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_092; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_092; #endif #ifdef PLUGIN_093 Plugin_id[x] = 93; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_093; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_093; #endif #ifdef PLUGIN_094 Plugin_id[x] = 94; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_094; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_094; #endif #ifdef PLUGIN_095 Plugin_id[x] = 95; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_095; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_095; #endif #ifdef PLUGIN_096 Plugin_id[x] = 96; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_096; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_096; #endif #ifdef PLUGIN_097 Plugin_id[x] = 97; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_097; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_097; #endif #ifdef PLUGIN_098 Plugin_id[x] = 98; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_098; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_098; #endif #ifdef PLUGIN_099 Plugin_id[x] = 99; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_099; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_099; #endif #ifdef PLUGIN_100 Plugin_id[x] = 100; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_100; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_100; #endif #ifdef PLUGIN_101 Plugin_id[x] = 101; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_101; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_101; #endif #ifdef PLUGIN_102 Plugin_id[x] = 102; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_102; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_102; #endif #ifdef PLUGIN_103 Plugin_id[x] = 103; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_103; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_103; #endif #ifdef PLUGIN_104 Plugin_id[x] = 104; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_104; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_104; #endif #ifdef PLUGIN_105 Plugin_id[x] = 105; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_105; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_105; #endif #ifdef PLUGIN_106 Plugin_id[x] = 106; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_106; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_106; #endif #ifdef PLUGIN_107 Plugin_id[x] = 107; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_107; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_107; #endif #ifdef PLUGIN_108 Plugin_id[x] = 108; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_108; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_108; #endif #ifdef PLUGIN_109 Plugin_id[x] = 109; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_109; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_109; #endif #ifdef PLUGIN_110 Plugin_id[x] = 110; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_110; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_110; #endif #ifdef PLUGIN_111 Plugin_id[x] = 111; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_111; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_111; #endif #ifdef PLUGIN_112 Plugin_id[x] = 112; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_112; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_112; #endif #ifdef PLUGIN_113 Plugin_id[x] = 113; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_113; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_113; #endif #ifdef PLUGIN_114 Plugin_id[x] = 114; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_114; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_114; #endif #ifdef PLUGIN_115 Plugin_id[x] = 115; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_115; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_115; #endif #ifdef PLUGIN_116 Plugin_id[x] = 116; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_116; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_116; #endif #ifdef PLUGIN_117 Plugin_id[x] = 117; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_117; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_117; #endif #ifdef PLUGIN_118 Plugin_id[x] = 118; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_118; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_118; #endif #ifdef PLUGIN_119 Plugin_id[x] = 119; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_119; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_119; #endif #ifdef PLUGIN_120 Plugin_id[x] = 120; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_120; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_120; #endif #ifdef PLUGIN_250 Plugin_id[x] = 250; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_250; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_250; #endif #ifdef PLUGIN_251 Plugin_id[x] = 251; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_251; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_251; #endif #ifdef PLUGIN_252 Plugin_id[x] = 252; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_252; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_252; #endif #ifdef PLUGIN_253 Plugin_id[x] = 253; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_253; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_253; #endif #ifdef PLUGIN_254 Plugin_id[x] = 254; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_254; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_254; #endif #ifdef PLUGIN_255 Plugin_id[x] = 255; +#ifndef ARDUINO_AVR_UNO Plugin_Description[x] = PLUGIN_DESC_255; +#endif + Plugin_State[x] = P_Enabled; Plugin_ptr[x++] = &Plugin_255; #endif diff --git a/RFLink/5_Plugin.h b/RFLink/5_Plugin.h index 6f50e0f6..a864dfc9 100644 --- a/RFLink/5_Plugin.h +++ b/RFLink/5_Plugin.h @@ -10,8 +10,8 @@ #include -#define PLUGIN_MAX 55 // 55 // Maximum number of Receive plugins -#define PLUGIN_TX_MAX 5 // 26 // Maximum number of Transmit plugins +#define PLUGIN_MAX 84 // Maximum number of Receive plugins +#define PLUGIN_TX_MAX 84 // Maximum number of Transmit plugins enum PState { @@ -24,7 +24,9 @@ enum PState extern boolean (*Plugin_ptr[PLUGIN_MAX])(byte, char *); // Receive plugins extern byte Plugin_id[PLUGIN_MAX]; extern byte Plugin_State[PLUGIN_MAX]; +#ifndef ARDUINO_AVR_UNO // Optimize memory limite to 2048 bytes on arduino uno extern String Plugin_Description[PLUGIN_MAX]; +#endif extern boolean (*PluginTX_ptr[PLUGIN_TX_MAX])(byte, char *); // Transmit plugins extern byte PluginTX_id[PLUGIN_TX_MAX]; From 60f4d3c9cf8a5130e9864f06af07f98917d057f8 Mon Sep 17 00:00:00 2001 From: basty149 Date: Tue, 8 Sep 2020 20:45:13 +0200 Subject: [PATCH 04/15] Cleanup code --- RFLink/Plugins/Plugin_083.c | 68 +++++++++++-------------------------- 1 file changed, 19 insertions(+), 49 deletions(-) diff --git a/RFLink/Plugins/Plugin_083.c b/RFLink/Plugins/Plugin_083.c index 5fc6f611..552438dc 100755 --- a/RFLink/Plugins/Plugin_083.c +++ b/RFLink/Plugins/Plugin_083.c @@ -6,9 +6,9 @@ * This plugin takes care of decoding and encoding the Brel Motor / Dooya protocol (DC318/DC114) * * Author (present) : Sebastien LANGE - * Support (present) : https://github.com/couin3/RFLink + * Support (present) : https://github.com/basty149/RFLink * Author (original) : Sebastien LANGE - * Support (original) : https://github.com/couin3/RFLink + * Support (original) : https://github.com/basty149/RFLink * License : This code is free for use in any open source project when this header is included. * Usage of any parts of this code in a commercial application is prohibited! ********************************************************************************************* @@ -28,31 +28,11 @@ * 20;XX;DEBUG;Pulses=82;Pulses(uSec)=4640,1504,192,640,192,640,512,320,192,608,512,320,192,640,480,320,480,352,160,640,512,320,192,640,160,640,192,640,160,640,160,640,192,640,512,320,480,320,160,640,160,640,480,320,160,640,160,640,160,672,160,640,192,640,192,640,192,640,192,640,192,640,192,640,512,352,160,640,160,640,160,640,512,320,512,320,512,320,480,320,160,4992; \*********************************************************************************************/ #define DOOYA_PLUGIN_ID 083 -#define PLUGIN_DESC_083 PSTR("DOOYA") +#define PLUGIN_DESC_083 PSTR("BRELMOTOR") #define DOOYA_PULSECOUNT_1 82 -// #define DOOYA_PULSECOUNT_2 54 -// #define DOOYA_PULSECOUNT_3 60 -// #define DOOYA_PULSECOUNT_4 62 -// #define DOOYA_PULSECOUNT_5 68 -// #define DOOYA_PULSECOUNT_6 72 -// #define DOOYA_PULSECOUNT_6 84 #define DOOYA_MIDVALUE 384 / RAWSIGNAL_SAMPLE_RATE -// #define DOOYA_PULSEMIN 1600 / RAWSIGNAL_SAMPLE_RATE -// #define DOOYA_PULSEMINMAX 2200 / RAWSIGNAL_SAMPLE_RATE -// #define DOOYA_PULSEMAXMIN 3000 / RAWSIGNAL_SAMPLE_RATE - -// #define DOOYA_NEAR_SYNC_START 36000 -// #define DOOYA_EXACT_SYNC_END_1 0x1380 -// #define DOOYA_EXACT_SYNC_END_2 0x079C -// #define DOOYA_EXACT_SYNC_END_3 0x119C -// #define DOOYA_EXACT_SYNC_END_4 0x139C -// #define DOOYA_EXACT_SYNC_END_5 0x129C -// #define DOOYA_EXACT_SYNC_END_6 0x069C -// #define DOOYA_EXACT_SYNC_END_7 0x109C -// #define DOOYA_EXACT_SYNC_END_8 0x0e9C - #define DOOYA_UP_COMMAND 0x11 // 0001 0001 #define DOOYA_STOP_COMMAND 0x55 // 0101 0101 #define DOOYA_DOWN_COMMAND 0x33 // 0011 0011 @@ -64,22 +44,9 @@ boolean Plugin_083(byte function, char *string) { - // if ((RawSignal.Number != DOOYA_PULSECOUNT_1) - // && (RawSignal.Number != DOOYA_PULSECOUNT_2) - // && (RawSignal.Number != DOOYA_PULSECOUNT_3) - // && (RawSignal.Number != DOOYA_PULSECOUNT_4) - // && (RawSignal.Number != DOOYA_PULSECOUNT_5) - // && (RawSignal.Number != DOOYA_PULSECOUNT_6)) - // return false; - - int i; - - // int last_byte = RawSignal.Pulses[RawSignal.Number-1]*0x100 + RawSignal.Pulses[RawSignal.Number]; char dbuffer[64]; - if (RawSignal.Number == DOOYA_PULSECOUNT_1 - // && last_byte == DOOYA_EXACT_SYNC_END_1 - ) + if ( RawSignal.Number == DOOYA_PULSECOUNT_1 ) { byte bbuffer[128]; @@ -89,15 +56,14 @@ boolean Plugin_083(byte function, char *string) Serial.print(dbuffer); #endif - int j; int buffer_index=0; // // Skip start [1] & [2] and end sequence - for (j = 3; j < RawSignal.Number-1; j+=8) + for (int j = 3; j < RawSignal.Number-1; j+=8) { byte short_bitstream=0; - for (i = 0; i < 8; i+=2) + for (int i = 0; i < 8; i+=2) { short_bitstream <<= 1; // Always shift @@ -113,6 +79,7 @@ boolean Plugin_083(byte function, char *string) } bbuffer[buffer_index++]=short_bitstream; + #ifdef PLUGIN_083_DEBUG sprintf(dbuffer, "0x%x ", short_bitstream); Serial.print(dbuffer); @@ -138,11 +105,6 @@ boolean Plugin_083(byte function, char *string) +bbuffer[4]*0x10 +bbuffer[5]; - display_Header(); - display_Name(PSTR("BrelMotor")); - display_IDn(address, 6); - display_SWITCH(bbuffer[7]); - int command = bbuffer[8]*0x10+bbuffer[9]; switch (command) @@ -159,7 +121,14 @@ boolean Plugin_083(byte function, char *string) case DOOYA_SETUP_COMMAND: display_Name(PSTR("CMD=SETUP")); break; + default : + return false; } + + display_Header(); + display_Name(PSTR("BrelMotor")); + display_IDn(address, 6); + display_SWITCH(bbuffer[7]); display_Footer(); } else @@ -192,7 +161,7 @@ boolean Plugin_083(byte function, char *string) /** * Convert Hex character to Hex value **/ -byte nibble2c(char c) +byte hexchar2hexvalue(char c) { if ((c>='0') && (c<='9')) return c-'0' ; @@ -219,7 +188,7 @@ void addHighLowSignalPulses(unsigned long high, unsigned long low, Serial.print("("); #endif - byte value = nibble2c(*(hexvalue+i)); + byte value = hexchar2hexvalue(*(hexvalue+i)); for (int x=0; x < 4; x++) { if ((value & B1000) == B1000) @@ -323,8 +292,7 @@ boolean PluginTX_083(byte function, char *string) ptr = strtok(string, ";"); // takes a list of delimiters while(ptr != NULL) { - strings[index] = ptr; - index++; + strings[index++] = ptr; ptr = strtok(NULL, ";"); // takes a list of delimiters } @@ -378,7 +346,9 @@ boolean PluginTX_083(byte function, char *string) addSinglePulse(DOOYA_RFEND_0, ¤tPulses); RawSignal.Number = currentPulses; +#ifdef PLUGIN_083_DEBUG debugRawSignal(currentPulses); +#endif // Amplify signal length from 32 (receipt) to 38 (emission) RawSignal.Multiply = 38; From 0b148d2eb987146e445ad650567cd937298777bd Mon Sep 17 00:00:00 2001 From: basty149 Date: Tue, 8 Sep 2020 21:09:25 +0200 Subject: [PATCH 05/15] =?UTF-8?q?Correction=20sur=20la=20longueur=20du=20s?= =?UTF-8?q?ignal=20et=20l'affichage=20en=20r=C3=A9ception?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RFLink/Plugins/Plugin_083.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/RFLink/Plugins/Plugin_083.c b/RFLink/Plugins/Plugin_083.c index 552438dc..c0ff1b97 100755 --- a/RFLink/Plugins/Plugin_083.c +++ b/RFLink/Plugins/Plugin_083.c @@ -106,20 +106,21 @@ boolean Plugin_083(byte function, char *string) +bbuffer[5]; int command = bbuffer[8]*0x10+bbuffer[9]; + char * commandstring; switch (command) { case DOOYA_UP_COMMAND: - display_Name(PSTR("CMD=UP")); + commandstring = PSTR("CMD=UP"); break; case DOOYA_DOWN_COMMAND: - display_Name(PSTR("CMD=DOWN")); + commandstring = PSTR("CMD=DOWN"); break; case DOOYA_STOP_COMMAND: - display_Name(PSTR("CMD=STOP")); + commandstring = PSTR("CMD=STOP"); break; case DOOYA_SETUP_COMMAND: - display_Name(PSTR("CMD=SETUP")); + commandstring = PSTR("CMD=SETUP"); break; default : return false; @@ -129,6 +130,7 @@ boolean Plugin_083(byte function, char *string) display_Name(PSTR("BrelMotor")); display_IDn(address, 6); display_SWITCH(bbuffer[7]); + display_Name(commandstring); display_Footer(); } else @@ -350,8 +352,8 @@ boolean PluginTX_083(byte function, char *string) debugRawSignal(currentPulses); #endif - // Amplify signal length from 32 (receipt) to 38 (emission) - RawSignal.Multiply = 38; + // Amplify signal length from 32 (receipt) to 42 (emission) + RawSignal.Multiply = 42; sendRF(currentPulses); return true; From 8b369c4669d85e9038af0233a90e38715241bfdc Mon Sep 17 00:00:00 2001 From: basty149 Date: Sun, 24 Jan 2021 12:35:35 +0100 Subject: [PATCH 06/15] Correction baudrate for Arduino --- RFLink/3_Serial.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RFLink/3_Serial.h b/RFLink/3_Serial.h index ffcec581..91a6270e 100644 --- a/RFLink/3_Serial.h +++ b/RFLink/3_Serial.h @@ -10,7 +10,11 @@ #include +#if (defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)) +#define BAUD 57600 // Baudrate for Arduino Uno +#else #define BAUD 921600 // 57600 // Baudrate for serial communication. +#endif #define INPUT_COMMAND_SIZE 60 // 60 // Maximum number of characters that a command via serial can be. #define FOCUS_TIME_MS 50 // 50 // Duration in mSec. that, after receiving serial data from USB only the serial port is checked. From 1f7b55d4032b2bb6ad5dfb5871261b243fd084a5 Mon Sep 17 00:00:00 2001 From: basty149 Date: Sun, 24 Jan 2021 12:42:16 +0100 Subject: [PATCH 07/15] Add new display features --- RFLink/4_Display.cpp | 24 +++++++++++++++++++++++- RFLink/4_Display.h | 3 +++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/RFLink/4_Display.cpp b/RFLink/4_Display.cpp index 46aa5aea..d8a36f78 100644 --- a/RFLink/4_Display.cpp +++ b/RFLink/4_Display.cpp @@ -19,7 +19,7 @@ char pbuffer[PRINT_BUFFER_SIZE]; // Buffer for complete message data // ------------------- // #if (defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)) -#error "For AVR plaforms, in all sprintf_P above, please replace %s with %S" +//#error "For AVR plaforms, in all sprintf_P above, please replace %s with %S" #endif // Common Header @@ -202,6 +202,13 @@ void display_RAIN(unsigned int input) strcat(pbuffer, dbuffer); } +// RAINTOT=1234 => Total rain in mm. (hexadecimal) 0x8d = 141 decimal = 14.1 mm (needs division by 10) +void display_RAINTOT(unsigned int input) +{ + sprintf_P(dbuffer, PSTR("%s%04x"), PSTR(";RAINTOT="), input); + strcat(pbuffer, dbuffer); +} + // RAINRATE=1234 => Rain rate in mm. (hexadecimal) 0x8d = 141 decimal = 14.1 mm (needs division by 10) void display_RAINRATE(unsigned int input) { @@ -341,6 +348,21 @@ void display_RGBW(unsigned int input) strcat(pbuffer, dbuffer); } +// DEBUG=..... => provide DEBUG Data +void display_DEBUG(byte data[], unsigned int size) +{ + sprintf_P(dbuffer, PSTR("%s"), PSTR(";DEBUG=")); + strcat(pbuffer, dbuffer); + + char buffer[size*2 + 1]; + for (unsigned int i = 0; i < size; i++) + { + sprintf_P(buffer+i*2, PSTR("%02x"), data[i]); + } + + strcat(pbuffer, buffer); +} + // --------------------- // // get label shared func // // --------------------- // diff --git a/RFLink/4_Display.h b/RFLink/4_Display.h index a6a62910..414cefe3 100644 --- a/RFLink/4_Display.h +++ b/RFLink/4_Display.h @@ -52,6 +52,7 @@ void display_UV(unsigned int); void display_LUX(unsigned int); void display_BAT(boolean); void display_RAIN(unsigned int); +void display_RAINTOT(unsigned int); void display_RAINRATE(unsigned int); void display_WINSP(unsigned int); void display_AWINSP(unsigned int); @@ -82,6 +83,8 @@ void display_METER(unsigned int); void display_VOLT(unsigned int); void display_RGBW(unsigned int); +void display_DEBUG(byte data[], unsigned int size); + void retrieve_Init(); boolean retrieve_Name(const char *); boolean retrieve_ID(unsigned long &); From ac5052b053587ea6d86b21b4f7f5155310771156 Mon Sep 17 00:00:00 2001 From: basty149 Date: Sun, 24 Jan 2021 12:43:14 +0100 Subject: [PATCH 08/15] Add new display features --- RFLink/4_Display.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RFLink/4_Display.cpp b/RFLink/4_Display.cpp index d8a36f78..3994e3f2 100644 --- a/RFLink/4_Display.cpp +++ b/RFLink/4_Display.cpp @@ -19,7 +19,7 @@ char pbuffer[PRINT_BUFFER_SIZE]; // Buffer for complete message data // ------------------- // #if (defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)) -//#error "For AVR plaforms, in all sprintf_P above, please replace %s with %S" +#error "For AVR plaforms, in all sprintf_P above, please replace %s with %S" #endif // Common Header From 69509482017c37c5903585a7260a765caaef9335 Mon Sep 17 00:00:00 2001 From: basty149 Date: Sun, 24 Jan 2021 12:46:34 +0100 Subject: [PATCH 09/15] Restore PLUGIN_048 features --- RFLink/Plugins/Plugin_048.c | 1059 +++++++++++++++++++++++++++++++++++ 1 file changed, 1059 insertions(+) create mode 100644 RFLink/Plugins/Plugin_048.c diff --git a/RFLink/Plugins/Plugin_048.c b/RFLink/Plugins/Plugin_048.c new file mode 100644 index 00000000..a58f49fd --- /dev/null +++ b/RFLink/Plugins/Plugin_048.c @@ -0,0 +1,1059 @@ +//####################################################################################################### +//## This Plugin is only for use with the RFLink software package ## +//## Plugin-48: Oregon V1/2/3 ## +//####################################################################################################### +/*********************************************************************************************\ + * This protocol takes care of receiving Oregon Scientific outdoor sensors that use the V1, V2 and V3 protocol + * + * models: THC238, THC268, THN132N, THWR288A, THRN122N, THN122N, AW129, AW131, THGR268, THGR122X, + * THGN122N, THGN123N, THGR122NX, THGR228N, THGR238, WTGR800, THGR918, THGRN228NX, THGN500, + * THGR810, RTGR328N, THGR328N, Huger BTHR918, BTHR918N, BTHR968, RGR126, RGR682, RGR918, PCR122 + * THWR800, THR128, THR138, THC138, OWL CM119, cent-a-meter, OWL CM113, Electrisave, RGR928 + * UVN128, UV138, UVN800, Huger-STR918, WGR918, WGR800, PCR800, WGTR800, RGR126, BTHG968 + * + * Author (present) : StormTeam 2018..2020 - Marc RIVES (aka Couin3) + * Support (present) : https://github.com/couin3/RFLink + * Author (update) : Sebastien LANGE + * Support (update) : https://github.com/basty149/RFLink + * Author (original) : StuntTeam 2015..2016 + * Support (original) : http://sourceforge.net/projects/rflink/ + * License : This code is free for use in any open source project when this header is included. + * Usage of any parts of this code in a commercial application is prohibited! + ********************************************************************************************* + * Changelog: v0.1 beta + ********************************************************************************************* + * Technical information: + * Supports Oregon V1, V2 and V3 protocol messages + * Core code from https://github.com/Cactusbone/ookDecoder/blob/master/ookDecoder.ino + * Copyright (c) 2014 Charly Koza cactusbone@free.fr Copyright (c) 2012 Olivier Lebrun olivier.lebrun@connectingstuff.net + * Copyright (c) 2012 Dominique Pierre (zzdomi) Copyright (c) 2010 Jean-Claude Wippler jcw@equi4.com + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software + * is furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + \*********************************************************************************************/ +#define OSV3_PLUGIN_ID 048 +#define PLUGIN_DESC_048 "Oregon V1/2/3" + +#define OSV3_PULSECOUNT_MIN 50 // 126 +#define OSV3_PULSECOUNT_MAX 290 // make sure to check the max length in plugin 1 as well..! + +#ifdef PLUGIN_048 +#include "../4_Display.h" + +void debugRawSignal(int size); +/* + * Many devices use 160 bits, known exceptions: + * 0xEA4c 136 bits // TH132N + * 0xEA7c 240 bits // UV138 + * 0x5A5D / 1A99 176 bits // THGR918 / WTGR800 + * 0x5A6D 192 bits // BTHR918N + * 0x8AEC 192 bits // RTGR328N + * 0x9AEC 208 bits // RTGR328N + * 0xDA78 144 bits // UVN800 + * 0x2A19 184 bits // RCR800 + * 0x2A1d 168 bits // WGR918 + */ +// ===================================================================================================== +class DecodeOOK +{ +protected: + byte total_bits, bits, flip, state, pos, data[25]; + virtual char decode(word width) = 0; + +public: + enum + { + UNKNOWN, + T0, + T1, + T2, + T3, + OK, + DONE + }; + // ------------------------------------- + DecodeOOK() { resetDecoder(); } + // ------------------------------------- + bool nextPulse(word width) + { + if (state != DONE) + + switch (decode(width)) + { + case -1: + resetDecoder(); + break; + case 1: + done(); + break; + } + return isDone(); + } + // ------------------------------------- + bool isDone() const { return state == DONE; } + // ------------------------------------- + const byte *getData(byte &count) const + { + count = pos; + return data; + } + // ------------------------------------- + void resetDecoder() + { + total_bits = bits = pos = flip = 0; + state = UNKNOWN; + } + // ------------------------------------- + // add one bit to the packet data buffer + // ------------------------------------- + virtual void gotBit(char value) + { + total_bits++; + byte *ptr = data + pos; + *ptr = (*ptr >> 1) | (value << 7); + + if (++bits >= 8) + { + bits = 0; + if (++pos >= sizeof data) + { + resetDecoder(); + return; + } + } + state = OK; + } + // ------------------------------------- + // store a bit using Manchester encoding + // ------------------------------------- + void manchester(char value) + { + flip ^= value; // manchester code, long pulse flips the bit + gotBit(flip); + } + // ------------------------------------- + // move bits to the front so that all the bits are aligned to the end + // ------------------------------------- + void alignTail(byte max = 0) + { + // align bits + if (bits != 0) + { + data[pos] >>= 8 - bits; + for (byte i = 0; i < pos; ++i) + data[i] = (data[i] >> bits) | (data[i + 1] << (8 - bits)); + bits = 0; + } + // optionally shift bytes down if there are too many of 'em + if (max > 0 && pos > max) + { + byte n = pos - max; + pos = max; + for (byte i = 0; i < pos; ++i) + data[i] = data[i + n]; + } + } + // ------------------------------------- + void reverseBits() + { + for (byte i = 0; i < pos; ++i) + { + byte b = data[i]; + for (byte j = 0; j < 8; ++j) + { + data[i] = (data[i] << 1) | (b & 1); + b >>= 1; + } + } + } + // ------------------------------------- + void reverseNibbles() + { + for (byte i = 0; i < pos; ++i) + data[i] = (data[i] << 4) | (data[i] >> 4); + } + // ------------------------------------- + void done() + { + while (bits) + gotBit(0); // padding + state = DONE; + } +}; + +/* +class OregonDecoderV1_org : public DecodeOOK { + public: + OregonDecoderV1_org() {} + virtual char decode(word width) { + if (200 <= width && width < 1200) { + byte w = width >= 700; + switch (state) { + case UNKNOWN: + if (w == 0) + ++flip; + else if (10 <= flip && flip <= 50) { + flip = 1; + manchester(1); + } + else + return -1; + break; + case OK: + if (w == 0) + state = T0; + else + manchester(1); + break; + case T0: + if (w == 0) + manchester(0); + else + return -1; + break; + } + return 0; + } + if (width >= 2500 && pos >= 9) + return 1; + return -1; + } +}; +*/ +class OregonDecoderV1 : public DecodeOOK +{ +public: + OregonDecoderV1() {} + virtual char decode(word width) + { + if (900 <= width && width < 3400) + { + byte w = width >= 2000; + switch (state) + { + case UNKNOWN: // Detect preamble + if (w == 0) + ++flip; + else + return -1; + break; + case OK: + if (w == 0) + state = T0; + else + manchester(1); + break; + case T0: + if (w == 0) + manchester(0); + else + return -1; + break; + default: // Unexpected state + return -1; + } + return (pos == 4) ? 1 : 0; // Messages are fixed-size + } + if (width >= 3400) + { + if (flip < 10 || flip > 50) + return -1; // No preamble + switch (state) + { + case UNKNOWN: + // First sync pulse, lowering edge + state = T1; + break; + case T1: + // Second sync pulse, lowering edge + state = T2; + break; + case T2: + // Last sync pulse, determines the first bit! + if (width <= 5900) + { + state = T0; + flip = 1; + } + else + { + state = OK; + flip = 0; + manchester(0); + } + break; + } + return 0; + } + return -1; + } +}; + +class OregonDecoderV2 : public DecodeOOK +{ +public: + OregonDecoderV2() {} + + // ------------------------------------- + // add one bit to the packet data buffer + // ------------------------------------- + virtual void gotBit(char value) + { + if (!(total_bits & 0x01)) + { + data[pos] = (data[pos] >> 1) | (value ? 0x80 : 00); + } + total_bits++; + pos = total_bits >> 4; + if (pos >= sizeof data) + { + resetDecoder(); + return; + } + state = OK; + } + // ------------------------------------- + virtual char decode(word width) + { + //if (200 <= width && width < 1200) { + // byte w = width >= 675; + if (150 <= width && width < 1200) + { + byte w = width >= 600; + switch (state) + { + case UNKNOWN: + if (w != 0) + { + // Long pulse + ++flip; + } + else if (w == 0 && 24 <= flip) + { + // Short pulse, start bit + flip = 0; + state = T0; + } + else + { + // Reset decoder + return -1; + } + break; + case OK: + if (w == 0) + { + // Short pulse + state = T0; + } + else + { + // Long pulse + manchester(1); + } + break; + case T0: + if (w == 0) + { + // Second short pulse + manchester(0); + } + else + { + // Reset decoder + return -1; + } + break; + } + } + else if (width >= 2500 && pos >= 8) + { + return 1; + } + else + { + return -1; + } + return total_bits == 160 ? 1 : 0; + } +}; + +class OregonDecoderV3 : public DecodeOOK +{ +public: + OregonDecoderV3() {} + // ------------------------------------- + // add one bit to the packet data buffer + // ------------------------------------- + virtual void gotBit(char value) + { + data[pos] = (data[pos] >> 1) | (value ? 0x80 : 00); + total_bits++; + pos = total_bits >> 3; + if (pos >= sizeof data) + { + resetDecoder(); + return; + } + state = OK; + } + // ------------------------------------- + virtual char decode(word width) + { + if (200 <= width && width < 1200) + { + byte w = width >= 675; + switch (state) + { + case UNKNOWN: + if (w == 0) + ++flip; + else if (32 <= flip) + { + flip = 1; + manchester(1); + } + else + return -1; + break; + case OK: + if (w == 0) + state = T0; + else + manchester(1); + break; + case T0: + if (w == 0) + manchester(0); + else + return -1; + break; + } + } + else + { + return -1; + } + return total_bits == 80 ? 1 : 0; + } +}; + +OregonDecoderV1 orscV1; +OregonDecoderV2 orscV2; +OregonDecoderV3 orscV3; + +volatile word pulse; +// ===================================================================================================== +// ===================================================================================================== +byte osdata[13]; + +void reportSerial(class DecodeOOK &decoder) +{ + byte pos; + const byte *data = decoder.getData(pos); + for (byte i = 0; i < pos; ++i) + { + if (i < 13) + osdata[i] = data[i]; + } + decoder.resetDecoder(); +} +// ===================================================================================================== +// calculate a packet checksum by performing a +byte checksum(byte type, int count, byte check) +{ + byte calc = 0; + // type 1, add all nibbles, deduct 10 + if (type == 1) + { + for (byte i = 0; i < count; i++) + { + calc += (osdata[i] & 0xF0) >> 4; + calc += (osdata[i] & 0xF); + } + calc = calc - 10; + } + else + // type 2, add all nibbles up to count, add the 13th nibble , deduct 10 + if (type == 2) + { + for (byte i = 0; i < count; i++) + { + calc += (osdata[i] & 0xF0) >> 4; + calc += (osdata[i] & 0xF); + } + calc += (osdata[6] & 0xF); + calc = calc - 10; + } + else + // type 3, add all nibbles up to count, subtract 10 only use the low 4 bits for the compare + if (type == 3) + { + for (byte i = 0; i < count; i++) + { + calc += (osdata[i] & 0xF0) >> 4; + calc += (osdata[i] & 0xF); + } + calc = calc - 10; + calc = (calc & 0x0f); + } + else if (type == 4) + { + for (byte i = 0; i < count; i++) + { + calc += (osdata[i] & 0xF0) >> 4; + calc += (osdata[i] & 0xF); + } + calc = calc - 10; + } + if (check == calc) + return 0; + return 1; +} + +void PrintHexByte(byte value) +{ + char buffer[3]; + sprintf_P(buffer, "%2x", value); + printf(buffer); +} + +void PrintHex8(byte data[], unsigned int size) +{ + char buffer[size+1]; + for (unsigned int i=0; i OSV3_PULSECOUNT_MAX)) + return false; + + byte rc = 0; + byte found = 0; + + int temp = 0; + byte hum = 0; + int comfort = 0; + int baro = 0; + int forecast = 0; + int uv = 0; + int wdir = 0; + int wspeed = 0; + int awspeed = 0; + int rain = 0; + int raintot = 0; + + word p = pulse; + // ================================================================================== + for (int x = 1; x < RawSignal.Number; x++) + { + //for (int x = 0; x < RawSignal.Number; x++) { + p = RawSignal.Pulses[x] * RawSignal.Multiply; + if (p != 0) + { + if (orscV1.nextPulse(p)) + { + reportSerial(orscV1); + found = 1; + } + if (orscV2.nextPulse(p)) + { + reportSerial(orscV2); + found = 2; + } + if (orscV3.nextPulse(p)) + { + reportSerial(orscV3); + found = 3; + } + } + } + if (found == 0) + return false; + + // ================================================================================== + // Protocol and device info: + // ================================================================================== + // debugRawSignal(RawSignal.Number); + // Serial.print("Oregon V"); + // Serial.print(found); + // Serial.print(": "); + // for(byte x=0; x<13;x++) { + // Serial.print( osdata[x],HEX ); + // Serial.print((" ")); + // } + // Serial.println(); + // Serial.print("Oregon ID="); + unsigned int id = (osdata[0] << 8) + (osdata[1]); + rc = osdata[0]; + // Serial.println(id,HEX); + + // ================================================================================== + // Process the various device types: + // ================================================================================== + // Oregon V1 packet structure + // SL-109H, AcuRite 09955 + // TEMP + CRC + // ================================================================================== + // 8487101C + // 84+87+10=11B > 1B+1 = 1C + if (found == 1) + { // OSV1 + int sum = osdata[0] + osdata[1] + osdata[2]; // max. value is 0x2FD + sum = (sum & 0xff) + (sum >> 8); // add overflow to low byte + if (osdata[3] != (sum & 0xff)) + { + //Serial.println("CRC Error"); + return false; + } + // ------------- + //temp = ((osdata[2]>>4) * 100) + ((osdata[1] & 0x0F) * 10) + ((osdata[1] >> 4)); + //if ((osdata[2] & 0x02) == 2) temp=temp | 0x8000; // bit 1 set when temp is negative, set highest bit on temp valua + temp = ((osdata[2] & 0x0F) * 100) + ((osdata[1] >> 4) * 10) + ((osdata[1] & 0x0F)); + if ((osdata[2] & 0x20) == 0x20) + temp = temp | 0x8000; // bit 1 set when temp is negative, set highest bit on temp valua + // ---------------------------------- + // Output + // ---------------------------------- + display_Header(); + display_Name(PSTR("OregonV1")); + //sprintf(pbuffer, "ID=00%02x;", rc & 0xCF); + // rolling code + channel + display_IDn((0x0000 | (rc)&0xcf), 4); + display_TEMP(temp); + display_HUM(hum, HUM_BCD); + boolean batOK=!(osdata[2] & 0x80); + display_BAT(batOK); + display_Footer(); + } + // ================================================================================== + // ea4c Outside (Water) Temperature: THC238, THC268, THN132N, THWR288A, THRN122N, THN122N, AW129, AW131 + // TEMP + BAT + CRC + // ca48 Pool (Water) Temperature: THWR800 + // 0a4d Indoor Temperature: THR128, THR138, THC138 + // ================================================================================== + // OSV2 EA4C20725C21D083 // THN132N + // OSV2 EA4C101360193023 // THN132N + // OSV2 EA4C40F85C21D0D4 // THN132N + // OSV2 EA4C20809822D013 + // 0123456789012345 + // 0 1 2 3 4 5 6 7 + if (id == 0xea4c || id == 0xca48 || id == 0x0a4d) + { + byte sum = (osdata[7] & 0x0f) << 4; + sum = sum + (osdata[6] >> 4); + if (checksum(2, 6, sum) != 0) + { // checksum = all nibbles 0-11+13 results is nibbles 15 <<4 + 12 + //Serial.println("CRC Error"); + return false; + } + // ------------- + temp = ((osdata[5] >> 4) * 100) + ((osdata[5] & 0x0F) * 10) + ((osdata[4] >> 4)); + if ((osdata[6] & 0x0F) >= 8) + temp = temp | 0x8000; + // ---------------------------------- + // Output + // ---------------------------------- + display_Header(); + display_Name(PSTR("Oregon Temp")); + display_IDn(osdata[3] << 8 | osdata[2], 4); + display_TEMP(temp); + boolean batOK=!((osdata[4] & 0x0c) >= 4); + display_BAT(batOK); + display_Footer(); + } + else + // ================================================================================== + // 1a2d Indoor Temp/Hygro: THGN122N, THGN123N, THGR122NX, THGR228N, THGR238, THGR268, THGR122X + // 1a3d Outside Temp/Hygro: THGR918, THGRN228NX, THGN500 + // fa28 Indoor Temp/Hygro: THGR810 + // *aac Outside Temp/Hygro: RTGR328N + // ca2c Outside Temp/Hygro: THGR328N + // fab8 Outside Temp/Hygro: WTGR800 + // TEMP + HUM sensor + BAT + CRC + // ================================================================================== + // OSV2 AACC13783419008250AD[RTGR328N,...] Id:78 ,Channel:0 ,temp:19.30 ,hum:20 ,bat:10 + // OSV2 1A2D40C4512170463EE6[THGR228N,...] Id:C4 ,Channel:3 ,temp:21.50 ,hum:67 ,bat:90 + // OSV2 1A2D1072512080E73F2C[THGR228N,...] Id:72 ,Channel:1 ,temp:20.50 ,hum:78 ,bat:90 + // OSV2 1A2D103742197005378E // THGR228N + // OSV3 FA28A428202290834B46 // + // OSV3 FA2814A93022304443BE // THGR810 + // OSV2 1A2D1002 02060552A4C + // 1A3D10D91C273083.. + // 1A3D10D90C284083.. + // 01234567890123456789 + // 0 1 2 3 4 5 + // F+A+2+8+1+4+A+9+3+0+2+2+3+0+4+4=4d-a=43 + if (id == 0xfa28 || id == 0x1a2d || id == 0x1a3d || (id & 0xfff) == 0xACC || id == 0xca2c || id == 0xfab8) + { + if (checksum(1, 8, osdata[8]) != 0) + return false; // checksum = all nibbles 0-15 results is nibbles 16.17 + // ------------- + temp = ((osdata[5] >> 4) * 100) + ((osdata[5] & 0x0F) * 10) + ((osdata[4] >> 4)); + if ((osdata[6] & 0x0F) >= 8) + temp = temp | 0x8000; + // ------------- + hum = ((osdata[7] & 0x0F) * 16) + (osdata[6] >> 4); + // ---------------------------------- + // Output + // ---------------------------------- + display_Header(); + display_Name(PSTR("Oregon TempHygro")); + display_IDn((osdata[1] << 8 | osdata[3]), 4); + display_TEMP(temp); + display_HUM(hum, HUM_BCD); + boolean batOK=!((osdata[4] & 0x0F) >= 4); + display_BAT(batOK); + display_Footer(); + } + else + // ================================================================================== + // 5a5d Indoor Temp/Hygro/Baro: Huger - BTHR918 + // 5a6d Indoor Temp/Hygro/Baro: BTHR918N, BTHR968. BTHG968 + // TEMP + HUM + BARO + FORECAST + BAT + // NO CRC YET + // ================================================================================== + // 5A 6D 00 7A 10 23 30 83 86 31 + // 5+a+6+d+7+a+1+2+3+3+8+3=47 -a=3d +8=4f +8+6=55 + // 5+a+6+d+7+a+1+2+3+3=3c-a=32 + // 5+a+6+d+7+a+1+2+3+3+0+8+3+8+6=55 -a =4b +3=4e !=1 + // 0 1 2 3 4 5 6 7 8 9 + if (id == 0x5a6d || id == 0x5a5d || id == 0x5d60) + { + // ------------- + temp = ((osdata[5] >> 4) * 100) + ((osdata[5] & 0x0F) * 10) + ((osdata[4] >> 4)); + if ((osdata[6] & 0x0F) >= 8) + temp = temp | 0x8000; + // ------------- + hum = ((osdata[7] & 0x0F) * 10) + (osdata[6] >> 4); + + //0: normal, 4: comfortable, 8: dry, C: wet + int tmp_comfort = osdata[7] >> 4; + if (tmp_comfort == 0x00) + comfort = 0; + else if (tmp_comfort == 0x04) + comfort = 1; + else if (tmp_comfort == 0x08) + comfort = 2; + else if (tmp_comfort == 0x0C) + comfort = 3; + + // ------------- + baro = (osdata[8] + 856); // max value = 1111 / 0x457 + + //2: cloudy, 3: rainy, 6: partly cloudy, C: sunny + int tmp_forecast = osdata[9] >> 4; + if (tmp_forecast == 0x02) + forecast = 3; + else if (tmp_forecast == 0x03) + forecast = 4; + else if (tmp_forecast == 0x06) + forecast = 2; + else if (tmp_forecast == 0x0C) + forecast = 1; + + // ---------------------------------- + // Output + // ---------------------------------- + display_Header(); + display_Name(PSTR("Oregon BTHR")); + display_IDn((rc << 8 | osdata[2]), 4); + display_TEMP(temp); + display_HUM(hum, HUM_BCD); + display_HSTATUS(comfort); + display_BARO(baro); + display_BFORECAST(forecast); + //below is not correct, and for now discarded + //if (((osdata[3] & 0x0F) & 0x04) != 0) { + // Serial.print("BAT=LOW;"); + //} else { + // Serial.print("BAT=OK;"); + //} + // boolean batOK=!((osdata[4] & 0x0F) >= 4); + // display_BAT(batOK); + display_Footer(); + } + else + // ================================================================================== + // 2914 Rain Gauge: + // 2d10 Rain Gauge: + // 2a1d Rain Gauge: RGR126, RGR682, RGR918, RGR928, PCR122 + // 2A1D0065502735102063 + // 2+A+1+D+0+0+6+5+5+0+2+7+3+5+1+0+2+0=3e-a=34 != 63 + // 2+A+1+D+0+0+6+5+5+0+2+7+3+5+1+0+2+0+6=44-a=3A + // ================================================================================== + if (id == 0x2a1d || id == 0x2d10 || id == 0x2914) + { // Rain sensor + //Checksum - add all nibbles from 0 to 8, subtract 9 and compare + /* + int cs = 0; + for (byte i = 0; i < pos-2; ++i) { //all but last byte + cs += data[i] >> 4; + cs += data[i] & 0x0F; + } + int csc = (data[8] >> 4) + ((data[9] & 0x0F)*16); + cs -= 9; //my version as A fails? + Serial.print(csc); + Serial.print(" vs "); + Serial.println(cs); + */ + rain = ((osdata[5] >> 4) * 100) + ((osdata[5] & 0x0F) * 10) + (osdata[4] >> 4); + raintot = ((osdata[7] >> 4) * 10) + (osdata[6] >> 4); + // ---------------------------------- + // Output + // ---------------------------------- + display_Header(); + display_Name(PSTR("Oregon Rain")); + display_IDn((rc << 8 | osdata[3]), 4); + display_RAIN(rain); + display_RAINTOT(raintot); + boolean batOK=!((osdata[3] & 0x0F) >= 4); + display_BAT(batOK); + display_Footer(); + } + else + // ================================================================================== + // 2a19 Rain Gauge: PCR800 + // RAIN + BAT + CRC + // ================================================================================== + // OSV3 2A19048E399393250010 + // 01234567890123456789 + // 0 1 2 3 4 5 6 7 8 9 + // 2+A+1+9+0+4+8+E+3+9+9+3+9+3+2+5=5b-A=51 => 10 + if (id == 0x2a19) + { // Rain sensor + int sum = (osdata[9] >> 4); + if (checksum(3, 9, sum) != 0) + { // checksum = all nibbles 0-17 result is nibble 18 + //Serial.print("CRC Error, "); + return false; + } + rain = ((osdata[5] >> 4) * 100) + ((osdata[5] & 0x0F) * 10) + (osdata[4] >> 4); + //Serial.print(" RainTotal="); + //raintot = ((osdata[7] >> 4) * 10) + (osdata[6]>>4); + //Serial.print(raintot); + // ---------------------------------- + // Output + // ---------------------------------- + display_Header(); + display_Name(PSTR("Oregon Rain2")); + display_IDn((rc << 8 | osdata[3]), 4); + display_RAIN(rain); + display_RAINTOT(raintot); + boolean batOK=!((osdata[3] & 0x0F) >= 4); + display_BAT(batOK); + display_Footer(); + } + else + // ================================================================================== + // 1a89 Anemometer: WGR800 + // WIND DIR + SPEED + AV SPEED + CRC + // ================================================================================== + // OSV3 1A89048800C026400543 + // OSV3 1A89048800C00431103B + // OSV3 1a89048848c00000003e W + // OSV3 1a890488c0c00000003e E + // 1A89042CB0C047000147 + // 0 1 2 3 4 5 6 7 8 9 + // 1+A+8+9+0+4+8+8+0+0+C+0+0+4+3+1+1+0=45-a=3b + if (id == 0x1a89) + { // Wind sensor + if (checksum(1, 9, osdata[9]) != 0) + return false; + wdir = ((osdata[4] >> 4) & 0x0f); + // ------------- + wspeed = (osdata[6] >> 4) * 10; + wspeed = wspeed + (osdata[6] & 0x0f) * 100; + wspeed = wspeed + (osdata[5] & 0x0f); + // ------------- + awspeed = (osdata[8] >> 4) * 100; + awspeed = awspeed + (osdata[7] & 0x0f) * 10; + awspeed = awspeed + (osdata[7] >> 4); + // ---------------------------------- + // Output + // ---------------------------------- + display_Header(); + display_Name(PSTR("Oregon Wind")); + display_IDn((rc << 8 | osdata[2]), 4); + display_WINDIR(wdir); + display_WINSP(wspeed); + display_AWINSP(awspeed); + boolean batOK=!((osdata[3] & 0x0F) >= 4); + display_BAT(batOK); + display_Footer(); + } + else + // ================================================================================== + // 3a0d Anemometer: Huger-STR918, WGR918 + // 1984 Anemometer: + // 1994 Anemometer: + // WIND DIR + SPEED + AV SPEED + BAT + CRC + // 3A0D006F400800000031 + // ================================================================================== + if (id == 0x3A0D || id == 0x1984 || id == 0x1994) + { + if (checksum(1, 9, osdata[9]) != 0) + { + //Serial.print("CRC Error, "); + return false; + } + wdir = ((osdata[5] >> 4) * 100) + ((osdata[5] & 0x0F * 10)) + (osdata[4] >> 4); + wdir = wdir / 22.5; + wspeed = ((osdata[7] & 0x0F) * 100) + ((osdata[6] >> 4) * 10) + ((osdata[6] & 0x0F)); + awspeed = ((osdata[8] >> 4) * 100) + ((osdata[8] & 0x0F) * 10) + ((osdata[7] >> 4)); + // ---------------------------------- + // Output + // ---------------------------------- + display_Header(); + display_Name(PSTR("Oregon Wind2")); + display_IDn((rc << 8 | osdata[2]), 4); + display_WINDIR(wdir); + display_WINSP(wspeed); + display_AWINSP(awspeed); + boolean batOK=!((osdata[3] & 0x0F) >= 4); + display_BAT(batOK); + display_Footer(); + } + else + // ================================================================================== + // ea7c UV Sensor: UVN128, UV138 + // UV + BAT + // NO CRC YET + // ================================================================================== + if (id == 0xea7c) + { + uv = ((osdata[5] & 0x0F) * 10) + (osdata[4] >> 4); + // Serial.print(uv); + // ---------------------------------- + // Output + // ---------------------------------- + display_Header(); + display_Name(PSTR("Oregon UVN128/138")); + display_IDn((rc << 8 | osdata[2]), 4); + display_UV(uv); + boolean batOK=!((osdata[3] & 0x0F) >= 4); + display_BAT(batOK); + display_Footer(); + } + else + // ================================================================================== + // da78 UV Sensor: UVN800 + // UV + // NO CRC YET + // ================================================================================== + if (id == 0xda78) + { + uv = (osdata[6] & 0xf0) + (osdata[5] & 0x0f); + // ---------------------------------- + // Output + // ---------------------------------- + display_Header(); + display_Name(PSTR("Oregon UVN800")); + display_IDn((rc << 8 | osdata[2]), 4); + display_UV(uv); + boolean batOK=!((osdata[3] & 0x0F) >= 4); + display_BAT(batOK); + display_Footer(); + } + else + // ================================================================================== + // *aec Date&Time: RTGR328N + // 8A EC 13 FC 60 81 43 91 11 30 0 0 0 ; + // 8+A+E+C+1+3+F+C+6+0+8+1+4+3+9+1=6B -A=61 != 30 + // 8+A+E+C+1+3+F+C+6+0+8+1+4+3+9=6a-A=60 0=0 + // NO CRC YET + //20;06;Oregon Unknown;DEBUG=8A EC 13 FC 60 81 43 91 11 30 0 0 0 ; + //20;20;Oregon Unknown;DEBUG=8A EC 13 FC 40 33 44 91 11 30 0 0 0 ; + + // OSV3 2A19048E399393250010 + // 01234567890123456789 + // 0 1 2 3 4 5 6 7 8 9 + // 2+A+1+9+0+4+8+E+3+9+9+3+9+3+2+5=5b-A=51 => 10 + + // ================================================================================== + // 8AEA1378077214924242C16CBD 21:49 29/04/2014 + // 0 1 2 3 4 5 6 7 8 9 0 1 2 + // 8+A+E+A+1+3+7+8+0+7+7+2+1+4+9+2+4+2+4+2+C+1+6+C=88 != BD + // Date & Time + // ================================================================================== + // eac0 Ampere meter: cent-a-meter, OWL CM113, Electrisave + // ================================================================================== + if (id == 0xeac0) + { + //Serial.println("UNKNOWN LAYOUT"); + // ---------------------------------- + // Output + // ---------------------------------- + display_Header(); + display_Name(PSTR("Oregon Unknown")); + display_DEBUG(osdata, 13); + display_Footer(); + } + else + // ================================================================================== + // 0x1a* / 0x2a* 0x3a** Power meter: OWL CM119 + // ================================================================================== + // 0x628* Power meter: OWL CM180 + // ================================================================================== + // OSV3 6284 3C 7801 D0 + // OSV3 6280 3C 2801 A0A8BA05 00 00 ?? ?? ?? + // ================================================================================== + // 1a99 Anemometer: WGTR800 + // WIND + TEMP + HUM + CRC + // ================================================================================== + if (id == 0x1a99) + { // Wind sensor + //Serial.println("UNKNOWN LAYOUT"); + // ---------------------------------- + // Output + // ---------------------------------- + display_Header(); + display_Name(PSTR("Oregon Unknown")); + display_DEBUG(osdata, 13); + display_Footer(); + } + else + // ================================================================================== + if ((id & 0xf00) == 0xA00) + { // Any Oregon sensor with id xAxx + // ---------------------------------- + // Output + // ---------------------------------- + display_Header(); + display_Name(PSTR("Oregon Unknown")); + display_DEBUG(osdata, 13); + display_Footer(); + } + // ================================================================================== + RawSignal.Repeats = true; // suppress repeats of the same RF packet + RawSignal.Number = 0; + return true; +} + +void debugRawSignal(int size) +{ + char dbuffer[64]; + + sprintf_P(dbuffer, PSTR("Pulses %04d Multiply %04d: "), + RawSignal.Number, RawSignal.Multiply, RawSignal.Time); + Serial.print(dbuffer); + + for (int i=0; i Date: Thu, 23 Sep 2021 21:46:36 +0200 Subject: [PATCH 10/15] Enable Plugin 048 (Oregon) and Plugin 083 (BrelMotor) --- RFLink/Plugins/Plugin_048.c | 18 ------------------ RFLink/Plugins/Plugin_083.c | 17 ----------------- RFLink/Plugins/_Plugin_Config_01.h | 4 ++++ 3 files changed, 4 insertions(+), 35 deletions(-) diff --git a/RFLink/Plugins/Plugin_048.c b/RFLink/Plugins/Plugin_048.c index a58f49fd..76bdce81 100644 --- a/RFLink/Plugins/Plugin_048.c +++ b/RFLink/Plugins/Plugin_048.c @@ -42,7 +42,6 @@ #ifdef PLUGIN_048 #include "../4_Display.h" -void debugRawSignal(int size); /* * Many devices use 160 bits, known exceptions: * 0xEA4c 136 bits // TH132N @@ -1039,21 +1038,4 @@ boolean Plugin_048(byte function, char *string) return true; } -void debugRawSignal(int size) -{ - char dbuffer[64]; - - sprintf_P(dbuffer, PSTR("Pulses %04d Multiply %04d: "), - RawSignal.Number, RawSignal.Multiply, RawSignal.Time); - Serial.print(dbuffer); - - for (int i=0; i Date: Thu, 23 Sep 2021 21:49:32 +0200 Subject: [PATCH 11/15] Enable debug function for plugins 048 & 083 --- RFLink/4_Display.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/RFLink/4_Display.cpp b/RFLink/4_Display.cpp index 8322d10b..afb9ed5b 100644 --- a/RFLink/4_Display.cpp +++ b/RFLink/4_Display.cpp @@ -7,6 +7,7 @@ #include #include "RFLink.h" +#include "2_Signal.h" #include "3_Serial.h" #include "4_Display.h" @@ -363,6 +364,23 @@ void display_DEBUG(byte data[], unsigned int size) strcat(pbuffer, buffer); } +void debugRawSignal(RawSignalStruct RawSignal, int size) +{ + char dbuffer[64]; + + sprintf_P(dbuffer, PSTR("Pulses %04d Multiply %04d: "), + RawSignal.Number, RawSignal.Multiply, RawSignal.Time); + Serial.print(dbuffer); + + for (int i=0; i Date: Fri, 1 Oct 2021 23:15:10 +0200 Subject: [PATCH 12/15] Enable DEBUG output and continue processing --- RFLink/Plugins/Plugin_001.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/RFLink/Plugins/Plugin_001.c b/RFLink/Plugins/Plugin_001.c index 976bae09..6f6bbbd7 100644 --- a/RFLink/Plugins/Plugin_001.c +++ b/RFLink/Plugins/Plugin_001.c @@ -233,8 +233,9 @@ boolean Plugin_001(byte function, char *string) } Serial.print(F(";\r\n")); // ---------------------------------- - RawSignal.Number = 0; // Last plugin, kill packet - return true; // stop processing + // RawSignal.Number = 0; // Last plugin, kill packet + pbuffer[0] = 0; // Reinit serial buffer + return false; // stop processing } #ifdef PLUGIN_061 From ef845e83606a8bc88506841d4e15290538cc3ea4 Mon Sep 17 00:00:00 2001 From: basty149 Date: Mon, 11 Jul 2022 22:43:54 +0200 Subject: [PATCH 13/15] Update Chuango AlarmSensors for Open Close sensor --- RFLink/Plugins/Plugin_062.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/RFLink/Plugins/Plugin_062.c b/RFLink/Plugins/Plugin_062.c index 0c5b53e2..ca2e96fb 100644 --- a/RFLink/Plugins/Plugin_062.c +++ b/RFLink/Plugins/Plugin_062.c @@ -22,6 +22,15 @@ * 20;03;DEBUG;Pulses=50;Pulses(uSec)=1620,420,1530,450,1560,390,510,1440,1560,420,1530,420,450,1530,1440,510,1440,540,360,1500,450,1470,480,1470,1560,390,510,1440,1530,420,1500,480,1470,570,330,1590,390,1530,450,1500,480,1470,1530,420,1530,420,1530,420,450,3360; * 101010011010011010010101100110101001010101101010 0 * 00010010 01110100 01111000 = 0x 12 74 78 + * + * Precision for Two-way Magnetic Sensor Wireless Door Window Open Close Detector Contact Alarm System For GSM Home Security + * https://www.aliexpress.com/item/32974739380.html + * + * 011110100000000001111010 => OPEN + * 011110100000000001111000 => CLOSE + * 123456789012345678901234 + * bit 23 = OPEN / CLOSE + * \*********************************************************************************************/ #define ALARMPIRV2_PLUGIN_ID 062 #define PLUGIN_DESC_062 "Chuango" @@ -88,9 +97,10 @@ boolean Plugin_062(byte function, char *string) // ---------------------------------- display_Header(); display_Name(PSTR("Chuango")); - display_IDn((bitstream & 0xFFFFFF), 6); // "%S%06lx" + display_IDn((bitstream & 0xFFFFF0), 6); // "%S%06lx" display_SWITCH(2); - display_CMD(CMD_Single, CMD_On); // #ALL #ON + boolean open = (bitstream >> 2) & 0x01; + display_CMD(CMD_Single, open ? CMD_On : CMD_Off); // #ALL #ON display_Footer(); //================================================================================== From 492ffbbe393b2aada9384eeb14bf557c799ff76d Mon Sep 17 00:00:00 2001 From: basty149 Date: Mon, 11 Jul 2022 22:54:04 +0200 Subject: [PATCH 14/15] Add RFLINK ECHO COMMAND --- RFLink/3_Serial.cpp | 23 +++++++++++++++++++++++ RFLink/4_Display.cpp | 28 +++++++++++++++++++++++++++- RFLink/4_Display.h | 6 ++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/RFLink/3_Serial.cpp b/RFLink/3_Serial.cpp index 70d7cd6a..d17e8dc8 100644 --- a/RFLink/3_Serial.cpp +++ b/RFLink/3_Serial.cpp @@ -216,7 +216,30 @@ boolean CheckCmd() set_Radio_mode(Radio_RX); } + } + // DOMOTICZ / RFLINK ECHO COMMAND + // Device creation using the Echo command (Node 11): + // https://www.rflink.nl/protref.php + else if ( strncmp(InputBuffer_Serial, "11;", 3) == 0 + && strlen(InputBuffer_Serial) > 9 ) { + // 11;20;0B;NewKaku;ID=000005;SWITCH=2;CMD=ON; => 11; is the required node info it can be followed by any custom data which will be echoed + // + // RFlink will reply with + // 20;D3;OK; => Notifying that the command has been received + // 20;D4;NewKaku;ID=000005;SWITCH=2;CMD=ON; => sending the data "as if" a remote control button was pressed. + + // Acknowledge + display_Header(); + display_Name(PSTR("OK")); + display_Footer(); + + // Cut input string but keep semi colon + strcpy(InputBuffer_Serial, InputBuffer_Serial+8); + display_Header(); + display_BUFFER(InputBuffer_Serial); + display_Footer(); } + } // if > 7 if (ValidCommand != 0) { diff --git a/RFLink/4_Display.cpp b/RFLink/4_Display.cpp index afb9ed5b..79023278 100644 --- a/RFLink/4_Display.cpp +++ b/RFLink/4_Display.cpp @@ -20,7 +20,7 @@ char pbuffer[PRINT_BUFFER_SIZE]; // Buffer for complete message data // ------------------- // #if (defined(__AVR_ATmega328P__) || defined(__AVR_ATmega2560__)) -#error "For AVR plaforms, in all sprintf_P above, please replace %s with %S" +#error "For AVR plaforms, in all sprintf_P above, please replace %s with %s" #endif // Common Header @@ -388,6 +388,12 @@ void display_CHAN(byte channel) strcat(pbuffer, dbuffer); } +// Add whatever you want to buffer +// for ECHO purpose +void display_BUFFER(const char *input) { + strcat(pbuffer, input); +} + // --------------------- // // get label shared func // // --------------------- // @@ -708,3 +714,23 @@ String GPIO2String(uint8_t uGPIO) return "NOT_A_PIN"; } #endif // ESP32 + +/** + * @see https://stackoverflow.com/questions/111928/is-there-a-printf-converter-to-print-in-binary-format + * Assumes little endian + */ +void printBits(size_t const size, void const * const ptr) +{ + unsigned char *b = (unsigned char*) ptr; + unsigned char byte; + int i, j; + char dbuffer[2]; + + for (i = size-1; i >= 0; i--) { + for (j = 7; j >= 0; j--) { + byte = (b[i] >> j) & 1; + Serial.print(byte); + } + } + Serial.println(); +} \ No newline at end of file diff --git a/RFLink/4_Display.h b/RFLink/4_Display.h index 81b860be..fa7c18a1 100644 --- a/RFLink/4_Display.h +++ b/RFLink/4_Display.h @@ -9,6 +9,7 @@ #define Misc_h #include +#include <2_Signal.h> #define PRINT_BUFFER_SIZE 90 // 90 // Maximum number of characters that a command should print in one go via the print buffer. @@ -86,6 +87,8 @@ void display_RGBW(unsigned int); void display_DEBUG(byte data[], unsigned int size); +void display_BUFFER(const char *input); + void retrieve_Init(); boolean retrieve_Name(const char *); boolean retrieve_ID(unsigned long &); @@ -115,3 +118,6 @@ String GPIO2String(uint8_t uGPIO); #endif // ESP8266 || ESP32 #endif + +void printBits(size_t const size, void const * const ptr); +void debugRawSignal(RawSignalStruct RawSignal, int size); From dabac9964e598516ad4afb2e5b0ac1c74486e365 Mon Sep 17 00:00:00 2001 From: basty149 Date: Mon, 11 Jul 2022 23:12:53 +0200 Subject: [PATCH 15/15] Correct DEVICE and SWITCH for TX --- RFLink/Plugins/Plugin_083.c | 18 ++++++++++++++++-- RFLink/Plugins/_Plugin_Config_01.h | 4 ++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/RFLink/Plugins/Plugin_083.c b/RFLink/Plugins/Plugin_083.c index c0ff1b97..bbaaec6e 100755 --- a/RFLink/Plugins/Plugin_083.c +++ b/RFLink/Plugins/Plugin_083.c @@ -302,6 +302,12 @@ boolean PluginTX_083(byte function, char *string) char * subaddress = strings[3]; char * commandstring = strings[4]; + // Keep only 6 DIGITS + int nbToCut = strlen(address)-6; + if ( nbToCut > 0 ) { + address+=nbToCut; + } + #ifdef PLUGIN_083_DEBUG sprintf_P(dbuffer, PSTR("Send BrelMotor %s %s"), address, subaddress); Serial.println(dbuffer); @@ -339,7 +345,15 @@ boolean PluginTX_083(byte function, char *string) addSinglePulse(DOOYA_RFSTART_1, ¤tPulses); // add Body addHighLowSignalPulses(DOOYA_RFHIGH, DOOYA_RFLOW, address, ¤tPulses); - addHighLowSignalPulses(DOOYA_RFHIGH, DOOYA_RFLOW, subaddress, ¤tPulses); + + // Pad subaddress on 2 DIGITS ZERO PADD + char buffersubaddress[3]; + sprintf_P(buffersubaddress, PSTR("%2s"), subaddress); + if (buffersubaddress[0] == ' ') { + buffersubaddress[0]='0'; + } + addHighLowSignalPulses(DOOYA_RFHIGH, DOOYA_RFLOW, buffersubaddress, ¤tPulses); + char buffercommand[3]; sprintf_P(buffercommand, PSTR("%2x"), command); addHighLowSignalPulses(DOOYA_RFHIGH, DOOYA_RFLOW, buffercommand, ¤tPulses); @@ -349,7 +363,7 @@ boolean PluginTX_083(byte function, char *string) RawSignal.Number = currentPulses; #ifdef PLUGIN_083_DEBUG - debugRawSignal(currentPulses); +// debugRawSignal(RawSignal, currentPulses); #endif // Amplify signal length from 32 (receipt) to 42 (emission) diff --git a/RFLink/Plugins/_Plugin_Config_01.h b/RFLink/Plugins/_Plugin_Config_01.h index ae93f453..e9c66631 100644 --- a/RFLink/Plugins/_Plugin_Config_01.h +++ b/RFLink/Plugins/_Plugin_Config_01.h @@ -53,6 +53,7 @@ #define PLUGIN_045 // Auriol #define PLUGIN_046 // Auriol v2 / Xiron #define PLUGIN_047 // Auriol v4 +#define PLUGIN_048 // Oregon V1/2/3 // ------------------- // Motion Sensors, include when needed // ------------------- @@ -77,6 +78,8 @@ #define PLUGIN_080 // Flamingo FA20 / KD101 smoke detector #define PLUGIN_081 // Mertik Maxitrol / Dru fireplace #define PLUGIN_082 // Mertik Maxitrol / Dru fireplace +#define PLUGIN_083 // BrelMotor + // ------------------- // Misc // ------------------- @@ -120,6 +123,7 @@ // ------------------- // #define PLUGIN_TX_080 // Flamingo FA20 / KD101 smoke detector // #define PLUGIN_TX_082 // Mertik Maxitrol / Dru fireplace +#define PLUGIN_TX_083 // BrelMotor // ------------------- // -=#=- // -------------------