-
Notifications
You must be signed in to change notification settings - Fork 2
Home
uSWAP is a tiny C++ library for Arduinos and ESP8266 implementing SWAP (Simple Wireless Abstract Protocol). uSWAP has been specifically designed for compact SWAP-IP gateways and Arduino-based SWAP coordinators.
Unlike pyswap (Python) and the rest of SWAP libraries (Java, Perl), uSWAP does not use dynamic allocation of SWAP objects or self-incrementing endpoint tables. Instead, SWAP devices need to be declared in the code, which makes this library really compact and memory efficient. uSWAP does not either rely on external Device Definition Files so each supported device needs its own C++ class describing endpoints and data parsing.
uSWAP needs a SWAP modem (panStamp module) to be connected to the UART port of the Arduino so this is a dual-MCU architecture where the SWAP modem handles all the SWAP (wireless) data while the Arduino or ESP8266 can take care of the rest of tasks (MQTT, HTPP, network logics, etc.).
This is a basic sample code:
#include <uswap.h>
// SWAP devices
DEVTEMP tempSensor(0x1A); // Temperature sensor device with address 0x1A
DEVTEMPHUM tempHumSensor(0x09); // Temperature + Humidity sensor device with address 0x09
BINOUTS binOuts(0x11); // Output board with address 0x11
RGBDRIVER rgbDriver(0x45); // RGB driver with address 0x45
void setup()
{
// Start conversations with modem
swap.begin();
}
void loop()
{
// Process incoming wireless data
swap.process();
}