diff --git a/Debug.cpp b/RF433Debug.cpp similarity index 97% rename from Debug.cpp rename to RF433Debug.cpp index c2ddd26..722d799 100644 --- a/Debug.cpp +++ b/RF433Debug.cpp @@ -1,4 +1,4 @@ -// Debug.cpp +// RF433Debug.cpp /* Provides some useful functions to output debug from Arduino on the serial @@ -24,7 +24,7 @@ . */ -#include "Debug.h" +#include "RF433Debug.h" #include #include diff --git a/Debug.h b/RF433Debug.h similarity index 93% rename from Debug.h rename to RF433Debug.h index b47e7b1..2d6feb1 100644 --- a/Debug.h +++ b/RF433Debug.h @@ -1,4 +1,4 @@ -// Debug.h +// RF433Debug.h /* Copyright 2021 Sébastien Millet @@ -18,8 +18,8 @@ . */ -#ifndef _DEBUG_H -#define _DEBUG_H +#ifndef _RF433DEBUG_H +#define _RF433DEBUG_H #define dbg(a) \ { static const char tmp[] PROGMEM = {a}; \ @@ -35,6 +35,6 @@ void dbgfunc(const char* file, long int line, const char *msg); void dbgffunc(const char* file, long int line, const char *format, ...) __attribute__((format(printf, 3, 4))); -#endif // _DEBUG_H +#endif // _RF433DEBUG_H // vim: ts=4:sw=4:tw=80:et diff --git a/Serial.cpp b/RF433Serial.cpp similarity index 81% rename from Serial.cpp rename to RF433Serial.cpp index 8b6372d..c77b35c 100644 --- a/Serial.cpp +++ b/RF433Serial.cpp @@ -22,12 +22,12 @@ . */ -#include "Serial.h" +#include "RF433Serial.h" #include -SerialLine::SerialLine():head(0),got_a_line(false) { }; +RF433SerialLine::RF433SerialLine():head(0),got_a_line(false) { }; -void SerialLine::do_events() { +void RF433SerialLine::do_events() { if (got_a_line) return; if (!Serial.available()) @@ -39,9 +39,10 @@ void SerialLine::do_events() { if (b == -1) break; buf[head++] = (char)b; - } while (head < SERIAL_LINE_BUF_LEN - 1 && b != '\n' && Serial.available()); + } while (head < RF433SERIAL_LINE_BUF_LEN - 1 + && b != '\n' && Serial.available()); - if (head < SERIAL_LINE_BUF_LEN - 1 && b != '\n') + if (head < RF433SERIAL_LINE_BUF_LEN - 1 && b != '\n') return; buf[head] = '\0'; @@ -57,12 +58,12 @@ void SerialLine::do_events() { got_a_line = true; } -bool SerialLine::is_line_available() { +bool RF433SerialLine::is_line_available() { do_events(); return got_a_line; } -void SerialLine::reset() { +void RF433SerialLine::reset() { head = 0; got_a_line = false; } @@ -74,8 +75,8 @@ void SerialLine::reset() { // (in which case, s is not updated). // The terminating newline character (or 2-character CR-LF sequence) is NOT part // of the string given to the caller. -// If the line length is above the buffer size (SERIAL_LINE_BUF_LEN), then it'll -// be cut into smaller pieces. +// If the line length is above the buffer size (RF433SERIAL_LINE_BUF_LEN), then +// it'll be cut into smaller pieces. // Because of the way the received buffer is parsed, and when using CR-LF as // end-of-line marker (default even under Linux), it can result in a empty // string seen after a first string with a length close to the limit. @@ -84,7 +85,7 @@ void SerialLine::reset() { // - Works fine with Unix new lines (\n), tested // - Supposed to work fine with Windows new lines (\r\n), NOT TESTED // - WON'T WORK WITH MAC-OS NEW LINES (\r) -bool SerialLine::get_line(char *s, size_t len) { +bool RF433SerialLine::get_line(char *s, size_t len) { do_events(); if (!got_a_line) return false; @@ -95,7 +96,7 @@ bool SerialLine::get_line(char *s, size_t len) { // Same as get_line, but with blocking I/O = // Wait without time limit, until a line comes in. -void SerialLine::get_line_blocking(char *s, size_t len) { +void RF433SerialLine::get_line_blocking(char *s, size_t len) { while (!get_line(s, len)) ; } diff --git a/Serial.h b/RF433Serial.h similarity index 76% rename from Serial.h rename to RF433Serial.h index caf9c32..f0afb26 100644 --- a/Serial.h +++ b/RF433Serial.h @@ -1,4 +1,4 @@ -// Serial.h +// RF433Serial.h /* Copyright 2021 Sébastien Millet @@ -18,23 +18,23 @@ . */ -#ifndef _SERIAL_H -#define _SERIAL_H +#ifndef _RF433SERIAL_H +#define _RF433SERIAL_H #include -#define SERIAL_LINE_BUF_LEN 19 +#define RF433SERIAL_LINE_BUF_LEN 19 -class SerialLine { +class RF433SerialLine { private: - char buf[SERIAL_LINE_BUF_LEN]; // 16-character strings (then CR+LF then - // NULL-terminating). + char buf[RF433SERIAL_LINE_BUF_LEN]; // 16-character strings (then CR+LF + // then NULL-terminating). size_t head; bool got_a_line; void reset(); public: - SerialLine(); + RF433SerialLine(); void do_events(); bool is_line_available(); @@ -43,6 +43,6 @@ class SerialLine { void split_s_into_func_args(char *s, char **func, char **args) const; }; -#endif // _SERIAL_H +#endif // _RF433SERIAL_H // vim: ts=4:sw=4:tw=80:et diff --git a/RF433any.cpp b/RF433any.cpp index c6663ef..3278b43 100644 --- a/RF433any.cpp +++ b/RF433any.cpp @@ -1101,8 +1101,8 @@ void DecoderManchester::dbg_decoder(byte disp_level, byte seq) const { // * ***** ******************************************************************** #ifdef RF433ANY_DBG_SIMULATE -SerialLine sl; -char buffer[SERIAL_LINE_BUF_LEN]; +RF433SerialLine sl; +char buffer[RF433SERIAL_LINE_BUF_LEN]; uint16_t sim_timings[SIM_TIMINGS_LEN]; diff --git a/RF433any.h b/RF433any.h index e9be1b0..bc4033e 100644 --- a/RF433any.h +++ b/RF433any.h @@ -79,13 +79,13 @@ #endif #ifdef RF433ANY_DBG_SIMULATE -#include "Serial.h" +#include "RF433Serial.h" #define SIM_TIMINGS_LEN 140 #endif #ifdef DEBUG -#include "Debug.h" +#include "RF433Debug.h" #else diff --git a/extras/testplan/test/test.ino b/extras/testplan/test/test.ino index aaf34d7..66b6f36 100644 --- a/extras/testplan/test/test.ino +++ b/extras/testplan/test/test.ino @@ -27,14 +27,14 @@ #define PIN_RFINPUT 2 #include "RF433any.h" -#include "Serial.h" +#include "RF433Serial.h" #include extern uint16_t sim_timings_count; extern unsigned int counter; extern unsigned int sim_int_count; -extern char buffer[SERIAL_LINE_BUF_LEN]; -extern SerialLine sl; +extern char buffer[RF433SERIAL_LINE_BUF_LEN]; +extern RF433SerialLine sl; extern uint16_t sim_timings[SIM_TIMINGS_LEN]; extern unsigned int sim_int_count_svg; diff --git a/library.properties b/library.properties index c7afbb3..85bb552 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=RF433any -version=0.7.0 +version=0.7.1 author=Sébastien Millet maintainer=Sébastien Millet sentence=A library to decode any protocol received on a 433 Mhz Radio Frequencies receiver