mirror of https://github.com/sebmillet/RF433any
Debug Serial renamed RF433Debug RF433Serial resp.
- Debug lib could clash with other lib users, and has been renamed into RF433Debug. Same with Serial, renamed into RF433Serial. - Some constants/classes used inside these libs, have also been renamed to have RF433 prefix.
This commit is contained in:
parent
bb935c7bd6
commit
e345c00fed
|
@ -1,4 +1,4 @@
|
|||
// Debug.cpp
|
||||
// RF433Debug.cpp
|
||||
|
||||
/*
|
||||
Provides some useful functions to output debug from Arduino on the serial
|
||||
|
@ -24,7 +24,7 @@
|
|||
<https://www.gnu.org/licenses>.
|
||||
*/
|
||||
|
||||
#include "Debug.h"
|
||||
#include "RF433Debug.h"
|
||||
#include <Arduino.h>
|
||||
#include <stdarg.h>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// Debug.h
|
||||
// RF433Debug.h
|
||||
|
||||
/*
|
||||
Copyright 2021 Sébastien Millet
|
||||
|
@ -18,8 +18,8 @@
|
|||
<https://www.gnu.org/licenses>.
|
||||
*/
|
||||
|
||||
#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
|
|
@ -22,12 +22,12 @@
|
|||
<https://www.gnu.org/licenses>.
|
||||
*/
|
||||
|
||||
#include "Serial.h"
|
||||
#include "RF433Serial.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
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))
|
||||
;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// Serial.h
|
||||
// RF433Serial.h
|
||||
|
||||
/*
|
||||
Copyright 2021 Sébastien Millet
|
||||
|
@ -18,23 +18,23 @@
|
|||
<https://www.gnu.org/licenses>.
|
||||
*/
|
||||
|
||||
#ifndef _SERIAL_H
|
||||
#define _SERIAL_H
|
||||
#ifndef _RF433SERIAL_H
|
||||
#define _RF433SERIAL_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#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
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -27,14 +27,14 @@
|
|||
#define PIN_RFINPUT 2
|
||||
|
||||
#include "RF433any.h"
|
||||
#include "Serial.h"
|
||||
#include "RF433Serial.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name=RF433any
|
||||
version=0.7.0
|
||||
version=0.7.1
|
||||
author=Sébastien Millet
|
||||
maintainer=Sébastien Millet <milletseb@laposte.net>
|
||||
sentence=A library to decode any protocol received on a 433 Mhz Radio Frequencies receiver
|
||||
|
|
Loading…
Reference in New Issue