updated the readme
This commit is contained in:
@@ -10,11 +10,11 @@ class BluetoothSerialMessage : public SerialMessage<SERIAL_BUFFER_SIZE, MAX_ARGS
|
|||||||
*/
|
*/
|
||||||
BluetoothSerialMessage(BluetoothSerial *serial);
|
BluetoothSerialMessage(BluetoothSerial *serial);
|
||||||
|
|
||||||
void Init(uint32_t baudRate) override{this->Init();}
|
void Init(uint32_t baudRate) override{this->Init("BluetoothMessage");}
|
||||||
/**
|
/**
|
||||||
* @brief Initialize the BluetoothSerialMessage object
|
* @brief Initialize the BluetoothSerialMessage object
|
||||||
*/
|
*/
|
||||||
void Init();
|
void Init(const char * bluetoothName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief prints the args array to the serial monitor
|
* @brief prints the args array to the serial monitor
|
||||||
@@ -30,6 +30,10 @@ class BluetoothSerialMessage : public SerialMessage<SERIAL_BUFFER_SIZE, MAX_ARGS
|
|||||||
|
|
||||||
BluetoothSerial *serial;
|
BluetoothSerial *serial;
|
||||||
};
|
};
|
||||||
|
template <uint32_t SERIAL_BUFFER_SIZE, uint32_t MAX_ARGS>
|
||||||
|
void BluetoothSerialMessage<SERIAL_BUFFER_SIZE, MAX_ARGS>::Init(const char * bluetoothName){
|
||||||
|
serial->begin(bluetoothName);
|
||||||
|
}
|
||||||
|
|
||||||
template <uint32_t SERIAL_BUFFER_SIZE, uint32_t MAX_ARGS>
|
template <uint32_t SERIAL_BUFFER_SIZE, uint32_t MAX_ARGS>
|
||||||
char BluetoothSerialMessage<SERIAL_BUFFER_SIZE, MAX_ARGS>::getChar(){
|
char BluetoothSerialMessage<SERIAL_BUFFER_SIZE, MAX_ARGS>::getChar(){
|
||||||
@@ -46,11 +50,6 @@ BluetoothSerialMessage<SERIAL_BUFFER_SIZE, MAX_ARGS>::BluetoothSerialMessage(Blu
|
|||||||
this->serial = serial;
|
this->serial = serial;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <uint32_t SERIAL_BUFFER_SIZE, uint32_t MAX_ARGS>
|
|
||||||
void BluetoothSerialMessage<SERIAL_BUFFER_SIZE, MAX_ARGS>::Init(){
|
|
||||||
serial->begin("MiniBot");
|
|
||||||
}
|
|
||||||
|
|
||||||
template <uint32_t SERIAL_BUFFER_SIZE, uint32_t MAX_ARGS>
|
template <uint32_t SERIAL_BUFFER_SIZE, uint32_t MAX_ARGS>
|
||||||
void BluetoothSerialMessage<SERIAL_BUFFER_SIZE, MAX_ARGS>::PrintArgs(){
|
void BluetoothSerialMessage<SERIAL_BUFFER_SIZE, MAX_ARGS>::PrintArgs(){
|
||||||
serial->print("Current number of args: ");
|
serial->print("Current number of args: ");
|
||||||
|
|||||||
25
README.md
25
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 `<MAX_BUFFER_SIZE, MAX_NUMBER_OF_ARGUMENTS>` 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.
|
||||||
@@ -15,12 +15,12 @@ class TelnetMessage : public Message<SERIAL_BUFFER_SIZE, MAX_ARGS>{
|
|||||||
TelnetMessage(ESPTelnet *telnet) :
|
TelnetMessage(ESPTelnet *telnet) :
|
||||||
telnet(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
|
* @brief Initialize the TelnetMessage object
|
||||||
* @pre The WiFi object must have a state of WL_CONNECTED
|
* @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
|
* @brief prints the args array to the telnet monitor
|
||||||
@@ -116,13 +116,15 @@ uint32_t TelnetMessage<SERIAL_BUFFER_SIZE, MAX_ARGS>::dataAvailable(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <uint32_t SERIAL_BUFFER_SIZE, uint32_t MAX_ARGS>
|
template <uint32_t SERIAL_BUFFER_SIZE, uint32_t MAX_ARGS>
|
||||||
void TelnetMessage<SERIAL_BUFFER_SIZE, MAX_ARGS>::Init(){
|
void TelnetMessage<SERIAL_BUFFER_SIZE, MAX_ARGS>::Init(void (*callback)(String data)){
|
||||||
telnet->begin(23);
|
telnet->begin(23);
|
||||||
// set all of our callbacks
|
// set all of our callbacks
|
||||||
telnet->onConnect(TelnetMessage::onConnectCallback);
|
telnet->onConnect(TelnetMessage::onConnectCallback);
|
||||||
telnet->onConnectionAttempt(TelnetMessage::onConnectionAttemptCallback);
|
telnet->onConnectionAttempt(TelnetMessage::onConnectionAttemptCallback);
|
||||||
telnet->onReconnect(TelnetMessage::onReconnectCallback);
|
telnet->onReconnect(TelnetMessage::onReconnectCallback);
|
||||||
telnet->onDisconnect(TelnetMessage::onDisconnectCallback);
|
telnet->onDisconnect(TelnetMessage::onDisconnectCallback);
|
||||||
|
|
||||||
|
this->SetOnInputRecieved(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <uint32_t SERIAL_BUFFER_SIZE, uint32_t MAX_ARGS>
|
template <uint32_t SERIAL_BUFFER_SIZE, uint32_t MAX_ARGS>
|
||||||
|
|||||||
Reference in New Issue
Block a user