initial push
This commit is contained in:
32
examples/ssp/ssp.ino
Normal file
32
examples/ssp/ssp.ino
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <Arduino.h>
|
||||
#include <SSPDevice.h>
|
||||
|
||||
// Define new device
|
||||
SSPDevice deviceOne;
|
||||
|
||||
// Gets called when a complete packet has been received.
|
||||
void onPacket(Packet packet) {
|
||||
Serial.println("Received Packet!");
|
||||
Serial.println(packet.id);
|
||||
Serial.println(packet.command);
|
||||
Serial.println(packet.data);
|
||||
Serial.println("----------------");
|
||||
|
||||
// To send a packet
|
||||
deviceOne.sendPacket("IDPacket", "Commandhere", "testtest");
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// Initialize (deviceOne) serial device on index 0 with a baud rate of 115200.
|
||||
deviceOne.init(0, 115200);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user