2021-03-29 23:48:38 +02:00

33 lines
877 B
C++

#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);
}