diff --git a/README.md b/README.md index 192217a..ff74974 100644 --- a/README.md +++ b/README.md @@ -38,25 +38,21 @@ SimpleSerialProtocol has a very simple API so it should be very easy to implemen The protocol works as following, each packet has 3 seperate stages. ### ID -This could be the device or service you want to reach. +ID of packet (device) -### Command -This is the command you want to send to the device or service. +### Type +Type of packet (action) ### Data -This is the data you want to send to the device or service. +Data of packet (data) Of course you could change the use of any of these values to fit your needs. A complete packet would look like this: ``` - +ID - TYPE - DATA ``` -As you can see the packet starts and ends with ``< - >`` characters and the stages are seperated with `` : `` characters. - -`This means you can't use any of these characters as data in the packets!!` - Include SSP and define a new device. ```c++ #include @@ -80,7 +76,7 @@ Now create a method (with a packet parameter) which will be called when a packet void onPacket(Packet packet) { Serial.println("Received Packet!"); Serial.println(packet.id); - Serial.println(packet.command); + Serial.println(packet.type); Serial.println(packet.data); Serial.println("----------------"); } @@ -92,7 +88,7 @@ void loop() { ``` To send packets you can use the ``sendPacket`` method. ```c++ -deviceOne.sendPacket("IDPacket", "Commandhere", "testtest"); +deviceOne.sendPacket("IDPacket", "Typehere", "testtest"); ``` ## Contributing Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change. diff --git a/examples/ssp/ssp.ino b/examples/ssp/ssp.ino index 07e7bea..82fd8b3 100644 --- a/examples/ssp/ssp.ino +++ b/examples/ssp/ssp.ino @@ -8,12 +8,12 @@ SimpleSerialProtocol deviceOne; void onPacket(Packet packet) { Serial.println("Received Packet!"); Serial.println(packet.id); - Serial.println(packet.command); + Serial.println(packet.type); Serial.println(packet.data); Serial.println("----------------"); // To send a packet - deviceOne.sendPacket("IDPacket", "Commandhere", "testtest"); + deviceOne.sendPacket("IDPacket", "TypeHere", "testtest"); } void setup() { @@ -25,8 +25,5 @@ void loop() { // Call receive packets function (looping) to handle incoming serial packets. // If a complete packet has been received it will call the callback function (onPacket). deviceOne.receivePackets(onPacket); - - // Small delay to not over overwork CPU. - delay(1); }