Update 'README.md'
This commit is contained in:
parent
1f065a561d
commit
19c57af28e
@ -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!!`
|
||||
|
||||
Include SSP and define a new device.
|
||||
```C++
|
||||
```c++
|
||||
#include <SimpleSerialProtocol.h>
|
||||
|
||||
// Define new device
|
||||
@ -68,7 +68,7 @@ SimpleSerialProtocol device;
|
||||
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)
|
||||
Second parameter is the baud rate.
|
||||
```C++
|
||||
```c++
|
||||
void setup() {
|
||||
// Initialize serial device on index 0 with a baud rate of 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)
|
||||
```C++
|
||||
```c++
|
||||
void onPacket(Packet packet) {
|
||||
Serial.println("Received Packet!");
|
||||
Serial.println(packet.id);
|
||||
@ -91,7 +91,7 @@ void loop() {
|
||||
}
|
||||
```
|
||||
To send packets you can use the ``sendPacket`` method.
|
||||
```C++
|
||||
```c++
|
||||
deviceOne.sendPacket("IDPacket", "Commandhere", "testtest");
|
||||
```
|
||||
## Contributing
|
||||
|
Loading…
x
Reference in New Issue
Block a user