From 981b4ed2584ff5d2e7996c3b8a5c77c8d0a48a69 Mon Sep 17 00:00:00 2001 From: Rop Gonggrijp Date: Tue, 13 Feb 2024 19:21:58 +0100 Subject: [PATCH] into the library manager * Added examples * Changed metadata for arduino library manager --- examples/minimal_demo/minimal_demo.ino | 15 +++++++++ .../receiving_packet/receiving_packet.ino | 33 +++++++++++++++++++ .../transmitting_packet.ino | 23 +++++++++++++ library.json | 2 +- library.properties | 5 +-- src/config.h | 2 +- 6 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 examples/minimal_demo/minimal_demo.ino create mode 100644 examples/receiving_packet/receiving_packet.ino create mode 100644 examples/transmitting_packet/transmitting_packet.ino diff --git a/examples/minimal_demo/minimal_demo.ino b/examples/minimal_demo/minimal_demo.ino new file mode 100644 index 0000000..403b229 --- /dev/null +++ b/examples/minimal_demo/minimal_demo.ino @@ -0,0 +1,15 @@ +/* + This will allow you to accs the Command Line Interpreter from the Serial + Monitor, letteing you set up a radio and receive and transmit packets. +*/ + +#include + +void setup() { + Serial.begin(115200); + OOKwiz::setup(); +} + +void loop() { + OOKwiz::loop(); +} diff --git a/examples/receiving_packet/receiving_packet.ino b/examples/receiving_packet/receiving_packet.ino new file mode 100644 index 0000000..60db49c --- /dev/null +++ b/examples/receiving_packet/receiving_packet.ino @@ -0,0 +1,33 @@ +/* + Prints payload of a very specific type of packet, ignores all else. + See README under "Meaning" +*/ + +#include + +void setup() { + Serial.begin(115200); + OOKwiz::setup(); + OOKwiz::onReceive(receive); +} + +void loop() { + OOKwiz::loop(); +} + +void receive(RawTimings raw, Pulsetrain train, Meaning meaning) { + if ( + meaning.elements.size() != 2 || + meaning.elements[0].type != PULSE || + !tools::between(meaning.elements[0].time1, 5800, 6000) || + meaning.elements[1].type != PWM || + !tools::between(meaning.elements[1].time1, 175, 205) || + !tools::between(meaning.elements[1].time2, 560, 590) || + meaning.elements[1].data_len != 24 + ) { + return; + } + // .data() on an std::vector gives a pointer to the first element + uint8_t *data = meaning.elements[1].data.data(); + Serial.printf("Data received 0:%02X 1:%02X 2:%02X", data[0], data[1], data[2]); +} diff --git a/examples/transmitting_packet/transmitting_packet.ino b/examples/transmitting_packet/transmitting_packet.ino new file mode 100644 index 0000000..79519b6 --- /dev/null +++ b/examples/transmitting_packet/transmitting_packet.ino @@ -0,0 +1,23 @@ +/* + Tranmits a specific type of packet. See README under "Meaning" +*/ + +#include + +void setup() { + Serial.begin(115200); + if (OOKwiz::setup()) { + Meaning newPacket; + newPacket.addPulse(5900); + uint8_t data[3] = {0x17, 0x72, 0xA4}; + // 190 and 575 are space and mark timings, 24 is data length in bits + newPacket.addPWM(190, 575, 24, data); + newPacket.repeats = 6; + newPacket.gap = 130; + OOKwiz::transmit(newPacket); + } +} + +void loop() { + OOKwiz::loop(); +} diff --git a/library.json b/library.json index 22913a3..cc50c4c 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "name": "Rop Gonggrijp", "url": "" }, - "version": "0.1.3", + "version": "0.1.4", "frameworks": "arduino", "platforms": "espressif32", "headers": "OOKwiz.h" diff --git a/library.properties b/library.properties index dae16c0..8a27dd0 100644 --- a/library.properties +++ b/library.properties @@ -1,10 +1,11 @@ name=OOKwiz -version=0.1.3 +version=0.1.4 author=Rop Gonggrijp maintainer=Rop Gonggrijp +url=https://github.com/ropg/OOKwiz sentence=Receiving/analysing/sending on-off-keying signals for radio remote controls 📱, weather stations 🌦️ and more. paragraph=OOKwiz is an ESP32 Arduino library for receiving, analysing, decoding, encoding and transmitting On/Off keyed signals using a number of radios via RadioLib as well as a generic type. Radio plugins easy to build. Not just a library, also a versatile rx/tx OOK Swiss army knife. Used in a sketch that only calls the library's `setup()` and `loop()` functions, it prints output like below for received signals and provides a command line interpreter to set radio type, GPIO-pins used, etc. Settings are stored in flash on the ESP32 using SPIFFS. OOKwiz tries to read the data from messages, example: `pulse(5906) + pwm(timing 190/575, 24 bits 0x1772A4)` (all time in µs). That same format is among those accepted by the CLI `transmit` function, so on-the-fly experimentation is super-easy: just copy the string, change a few bits and transmit it back out. -category=radio +category=Signal Input/Output architectures=esp32 includes=OOKwiz.h depends=RadioLib diff --git a/src/config.h b/src/config.h index c472853..54a6864 100644 --- a/src/config.h +++ b/src/config.h @@ -4,7 +4,7 @@ #define ARDUINO_LOOP_TASK_STACK_SIZE (16 * 1024) #define SERIAL_RX_BUFFER_SIZE 1024 -#define OOKWIZ_VERSION "0.1.3" +#define OOKWIZ_VERSION "0.1.4" #define SPIFFS_PREFIX /OOKwiz #define MAX_BINS 10