ClusterDuck Protocol
Public Member Functions | Protected Attributes | List of all members
ClusterDuck Class Reference

External APIs to build and control a duck device. More...

#include <ClusterDuck.h>

Public Member Functions

 ClusterDuck ()
 Construct a new Cluster Duck object.
 
String duckMac (boolean format)
 Get the Duck Mac Address. More...
 
String uuidCreator ()
 Create a uuid string. More...
 
volatile bool getInterrupt ()
 Get the interrupt state. More...
 
void flipFlag ()
 Toggle the flag that indicates a message is received.
 
void flipInterrupt ()
 Toggle the interrupt state flag.
 
int ping ()
 Transmit a ping message. More...
 
void setupDetect ()
 Shortcut to setup a Duck Detector. More...
 
int runDetect ()
 starts the Duck Detector run thread. More...
 
int handlePacket ()
 Handles a received LoRa packet. More...
 
String getPacketData (int pSize)
 Get the Packet data. More...
 
Packet getLastPacket ()
 Get the last received LoRa packet. More...
 
void couple (byte byteCode, String outgoing)
 Append a chunk to the packet. More...
 
bool idInPath (String path)
 Determine if a Duck device_id is present in the path. More...
 
volatile bool getFlag ()
 Get the packet receive flag status. More...
 
int startReceive ()
 Set the Duck to be ready to recieve LoRa packets. More...
 
int startTransmit ()
 Set the Duck to be ready to transmit LoRa packets. More...
 
int getRSSI ()
 Get the current RSSI value. More...
 
bool ssidAvailable (String val="")
 Checks if the given ssid is available. More...
 
void setSSID (String val)
 Set the WiFi network ssid. More...
 
void setPassword (String val)
 Set the WiFi password. More...
 
String getSSID ()
 Get the WiFi network ssid. More...
 
String getPassword ()
 Get the WiFi password ssid. More...
 
void setupOTA ()
 
void processPortalRequest ()
 
String * getPortalDataArray ()
 
String getPortalDataString ()
 
bool runCaptivePortal ()
 

Protected Attributes

String _deviceId = ""
 

Detailed Description

External APIs to build and control a duck device.

This class exposes all the necessary APIs to setup/build a duck as well as customizig the duck's behavior.

Member Function Documentation

◆ couple()

void ClusterDuck::couple ( byte  byteCode,
String  outgoing 
)

Append a chunk to the packet.

A chunk is part of the Duck LoRa packet and is formated as [tag][length][payload] where a tag is a single byte identifying the chunk. Currently supported tags:

sender_id
topic
message_id
payload
iamhere
Parameters
byteCodeidentifies the tag to append
outgoingthe payload for the tag to be appended to the LoRa packet

◆ duckMac()

String ClusterDuck::duckMac ( boolean  format)

Get the Duck Mac Address.

Parameters
formattrue if the mac address is formated as MM:MM:MM:SS:SS:SS
Returns
A string representing the duck mac address

◆ getFlag()

volatile bool ClusterDuck::getFlag ( )

Get the packet receive flag status.

Returns
true if a received packet is available, false otherwise.

◆ getInterrupt()

volatile bool ClusterDuck::getInterrupt ( )

Get the interrupt state.

Returns
true if interrupt is enabled, false otherwise.

◆ getLastPacket()

Packet ClusterDuck::getLastPacket ( )

Get the last received LoRa packet.

Returns
A Packet object containing the last received message.

◆ getPacketData()

String ClusterDuck::getPacketData ( int  pSize)

Get the Packet data.

Parameters
pSizethe length of the packet
Returns
A string representing the content of the packet

◆ getPassword()

String ClusterDuck::getPassword ( )

Get the WiFi password ssid.

Returns
a string representing the current network password

◆ getRSSI()

int ClusterDuck::getRSSI ( )

Get the current RSSI value.

Returns
An integer representing the rssi value.

◆ getSSID()

String ClusterDuck::getSSID ( )

Get the WiFi network ssid.

Returns
a string representing the current network ssid

◆ handlePacket()

int ClusterDuck::handlePacket ( )

Handles a received LoRa packet.

Returns
The packet length which should be > 0. An error code is returned if there was a failure to read the data from the LoRa driver.

◆ idInPath()

bool ClusterDuck::idInPath ( String  path)

Determine if a Duck device_id is present in the path.

Parameters
pathpath retrieved from the LoRa packet
Returns
true if the id is in the path, false otherwise.

◆ ping()

int ClusterDuck::ping ( )

Transmit a ping message.

Returns
0 if the message was sent sucessfully, an error code otherwise.

◆ runDetect()

int ClusterDuck::runDetect ( )

starts the Duck Detector run thread.

  • checks for "health" message received and returns the LoRa RSSI value
    Returns
    an integer value representing the LoRa RSSI value

◆ setPassword()

void ClusterDuck::setPassword ( String  val)

Set the WiFi password.

Parameters
valthe password string to set

◆ setSSID()

void ClusterDuck::setSSID ( String  val)

Set the WiFi network ssid.

Parameters
valthe ssid string to set

◆ setupDetect()

void ClusterDuck::setupDetect ( )

Shortcut to setup a Duck Detector.

This function will setup a Duck Detector and is equivalent to call these individual methods:

setupDisplay("Duck");
setupLoRa();
setupOTA()

It is assumed that the Duck Detector hardware has a display and a wifi component

◆ ssidAvailable()

bool ClusterDuck::ssidAvailable ( String  val = "")

Checks if the given ssid is available.

Parameters
valssid to check, default is an empty string and will use the internal default ssid
Returns
true if the ssid is available, false otherwise.

◆ startReceive()

int ClusterDuck::startReceive ( )

Set the Duck to be ready to recieve LoRa packets.

Returns
0 if the call was successful, an error code otherwise.

◆ startTransmit()

int ClusterDuck::startTransmit ( )

Set the Duck to be ready to transmit LoRa packets.

Returns
0 if the call was successful, an error code otherwise.

◆ uuidCreator()

String ClusterDuck::uuidCreator ( )

Create a uuid string.

Returns
A string representing a unique identifier.

The documentation for this class was generated from the following files:
ClusterDuck::ping
int ping()
Transmit a ping message.