Update 'README.md'

This commit is contained in:
Nick Leeman 2021-03-30 14:43:03 +02:00
parent 1f065a561d
commit 19c57af28e

View File

@ -58,7 +58,7 @@ As you can see the packet starts and ends with ``< - >`` characters and the stag
`This means you can't use any of these characters as data in the packets!!` `This means you can't use any of these characters as data in the packets!!`
Include SSP and define a new device. Include SSP and define a new device.
```C++ ```c++
#include <SimpleSerialProtocol.h> #include <SimpleSerialProtocol.h>
// Define new device // Define new device
@ -68,7 +68,7 @@ SimpleSerialProtocol device;
Initialize the serial device and connection. Initialize the serial device and connection.
First parameter is the serial channel. For example; the mega 2560 has 4 serial channels (RX0/TX0 through RX3/TX3) First parameter is the serial channel. For example; the mega 2560 has 4 serial channels (RX0/TX0 through RX3/TX3)
Second parameter is the baud rate. Second parameter is the baud rate.
```C++ ```c++
void setup() { void setup() {
// Initialize serial device on index 0 with a baud rate of 115200 // Initialize serial device on index 0 with a baud rate of 115200
device.init(0, 115200); device.init(0, 115200);
@ -76,7 +76,7 @@ void setup() {
``` ```
Now create a method (with a packet parameter) which will be called when a packet is received. In the main loop call ``receivePackets`` with the callback function as parameter regularly. (more times the better) Now create a method (with a packet parameter) which will be called when a packet is received. In the main loop call ``receivePackets`` with the callback function as parameter regularly. (more times the better)
```C++ ```c++
void onPacket(Packet packet) { void onPacket(Packet packet) {
Serial.println("Received Packet!"); Serial.println("Received Packet!");
Serial.println(packet.id); Serial.println(packet.id);
@ -91,7 +91,7 @@ void loop() {
} }
``` ```
To send packets you can use the ``sendPacket`` method. To send packets you can use the ``sendPacket`` method.
```C++ ```c++
deviceOne.sendPacket("IDPacket", "Commandhere", "testtest"); deviceOne.sendPacket("IDPacket", "Commandhere", "testtest");
``` ```
## Contributing ## Contributing