Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activation des plugins 048 (Oregon Scientific) et 083 (BrelMotor) #77

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d4bf9a1
Initial import before cleanup
basty149 Sep 7, 2020
129c3aa
Cleanup code
basty149 Sep 7, 2020
554f0e4
Optimisation mémoire pour ARDUINO UNO (RAM limit to 2048 bytes)
basty149 Sep 8, 2020
60f4d3c
Cleanup code
basty149 Sep 8, 2020
0b148d2
Correction sur la longueur du signal et l'affichage en réception
basty149 Sep 8, 2020
02b6193
Merge pull request #1 from couin3/master
basty149 Sep 21, 2020
68f34a1
Merge pull request #2 from couin3/master
basty149 Sep 25, 2020
949bc4a
Merge pull request #3 from couin3/master
basty149 Jan 16, 2021
8b369c4
Correction baudrate for Arduino
basty149 Jan 24, 2021
1f7b55d
Add new display features
basty149 Jan 24, 2021
ac5052b
Add new display features
basty149 Jan 24, 2021
6950948
Restore PLUGIN_048 features
basty149 Jan 24, 2021
c37a336
Merge pull request #4 from couin3/master
basty149 Mar 12, 2021
701752f
Merge branch 'master' into feature-oregon
basty149 Sep 23, 2021
573d203
Merge pull request #5 from basty149/feature-oregon
basty149 Sep 23, 2021
fa325ca
Merge branch 'master' into feature-brel-motor
basty149 Sep 23, 2021
c167d74
Enable Plugin 048 (Oregon) and Plugin 083 (BrelMotor)
basty149 Sep 23, 2021
b96c7e5
Enable debug function for plugins 048 & 083
basty149 Sep 23, 2021
bc26820
Enable DEBUG output and continue processing
basty149 Oct 1, 2021
ef845e8
Update Chuango AlarmSensors for Open Close sensor
basty149 Jul 11, 2022
492ffbb
Add RFLINK ECHO COMMAND
basty149 Jul 11, 2022
dabac99
Correct DEVICE and SWITCH for TX
basty149 Jul 11, 2022
269639f
Merge branch 'feature-chuango'
basty149 Jul 11, 2022
e6ccf97
Merge branch 'feature-brel-motor'
basty149 Jul 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions RFLink/3_Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 4 additions & 0 deletions RFLink/3_Serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

#include <Arduino.h>

#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.

Expand Down
67 changes: 66 additions & 1 deletion RFLink/4_Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <Arduino.h>
#include "RFLink.h"
#include "2_Signal.h"
#include "3_Serial.h"
#include "4_Display.h"

Expand All @@ -19,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
Expand Down Expand Up @@ -202,6 +203,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)
{
Expand Down Expand Up @@ -341,6 +349,37 @@ 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);
}

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<size; i++)
{
sprintf_P(dbuffer, PSTR("%d "), RawSignal.Pulses[i]*RawSignal.Multiply);
Serial.print(dbuffer);
}

Serial.println();
}

// Channel
void display_CHAN(byte channel)
Expand All @@ -349,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 //
// --------------------- //
Expand Down Expand Up @@ -669,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();
}
9 changes: 9 additions & 0 deletions RFLink/4_Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define Misc_h

#include <Arduino.h>
#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.

Expand Down Expand Up @@ -53,6 +54,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);
Expand Down Expand Up @@ -83,6 +85,10 @@ void display_METER(unsigned int);
void display_VOLT(unsigned int);
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 &);
Expand Down Expand Up @@ -112,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);
5 changes: 3 additions & 2 deletions RFLink/Plugins/Plugin_001.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading