From fa9b73f017cbd492155a416271f61e4abcabf397 Mon Sep 17 00:00:00 2001 From: Quinn Date: Wed, 7 Aug 2024 09:17:41 -0400 Subject: [PATCH] updated the readme --- BluetoothSerialMessage.h | 13 ++++++------- README.md | 25 ++++++++++++++++++++++++- TelnetMessage.h | 8 +++++--- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/BluetoothSerialMessage.h b/BluetoothSerialMessage.h index cd148d3..4a4746f 100644 --- a/BluetoothSerialMessage.h +++ b/BluetoothSerialMessage.h @@ -10,11 +10,11 @@ class BluetoothSerialMessage : public SerialMessageInit();} + void Init(uint32_t baudRate) override{this->Init("BluetoothMessage");} /** * @brief Initialize the BluetoothSerialMessage object */ - void Init(); + void Init(const char * bluetoothName); /** * @brief prints the args array to the serial monitor @@ -30,6 +30,10 @@ class BluetoothSerialMessage : public SerialMessage +void BluetoothSerialMessage::Init(const char * bluetoothName){ + serial->begin(bluetoothName); +} template char BluetoothSerialMessage::getChar(){ @@ -46,11 +50,6 @@ BluetoothSerialMessage::BluetoothSerialMessage(Blu this->serial = serial; } -template -void BluetoothSerialMessage::Init(){ - serial->begin("MiniBot"); -} - template void BluetoothSerialMessage::PrintArgs(){ serial->print("Current number of args: "); diff --git a/README.md b/README.md index 8f2449d..a17173c 100644 --- a/README.md +++ b/README.md @@ -1 +1,24 @@ -TODO: Fill in this readme +# Welcome! + +The point of this library is to allow anyone to recieve and parse numerical data over a serial message. + +The format of an acceptable message is: +`!aaa...,bbb...,c...,...;` + +IE: `!128,4096,1;` +All arguments in the message must be an integer and can be no bigger than a 32-bit int. (Negative numbers are also accepted). + +All messages must also begin with an `!` and end with an `;`. + +Setting up a Message object is easy and all message objects are more or less interchangeable. (There are some caveats to this especially regarding TelnetMessage and its complexity) + +Simply create a message object like the SerialMessage one below: + +`SerialMessage<100, 5> message(&Serial);` + +Also be sure to call the Init() function for the corresponding Message object. This is **required** in order for the message object to function. + +For the `TelnetMessage` object you will need to provide a callback function. it is strongly reocmmended that you use this one: +`[](String data){wifiMessage.SetString(data.c_str());}` + +All message objects take in a `` as part of their definition. This allows you to choose how much memory you want to statically allocate to one of these objects at compile time. If you know that you are going to be sending huge messages with lots of arguments then you should increase the buffer size and number of arguments to something large. If either of these values are too small, then the values that the message object will recieve will be truncated and could result in invalid messages. \ No newline at end of file diff --git a/TelnetMessage.h b/TelnetMessage.h index 961453f..4658d63 100644 --- a/TelnetMessage.h +++ b/TelnetMessage.h @@ -15,12 +15,12 @@ class TelnetMessage : public Message{ TelnetMessage(ESPTelnet *telnet) : telnet(telnet){} - void Init(uint32_t baudRate) override{this->Init();} + void Init(uint32_t baudRate) override{Serial.println("Never call this without a parameter, this will not function properly without a callback function");} /** * @brief Initialize the TelnetMessage object * @pre The WiFi object must have a state of WL_CONNECTED */ - void Init(); + void Init(void (*callback)(String data)); /** * @brief prints the args array to the telnet monitor @@ -116,13 +116,15 @@ uint32_t TelnetMessage::dataAvailable(){ } template -void TelnetMessage::Init(){ +void TelnetMessage::Init(void (*callback)(String data)){ telnet->begin(23); // set all of our callbacks telnet->onConnect(TelnetMessage::onConnectCallback); telnet->onConnectionAttempt(TelnetMessage::onConnectionAttemptCallback); telnet->onReconnect(TelnetMessage::onReconnectCallback); telnet->onDisconnect(TelnetMessage::onDisconnectCallback); + + this->SetOnInputRecieved(callback); } template