#include <Duck.h>
|
| Duck () |
| Construct a new Duck object. More...
|
|
| Duck (String id) |
| Construct a new Duck object. More...
|
|
| ~Duck () |
|
void | setupSerial (int baudRate=115200) |
| Setup serial connection. More...
|
|
void | setupRadio (float band=CDPCFG_RF_LORA_FREQ, int ss=CDPCFG_PIN_LORA_CS, int rst=CDPCFG_PIN_LORA_RST, int di0=CDPCFG_PIN_LORA_DIO0, int di1=CDPCFG_PIN_LORA_DIO1, int txPower=CDPCFG_RF_LORA_TXPOW) |
| Setup the radio component. More...
|
|
void | setupWifi (const char *ap="🆘 DUCK EMERGENCY PORTAL") |
| Setup WiFi access point. More...
|
|
int | setupDns () |
| Setup DNS. More...
|
|
void | setupWebServer (bool createCaptivePortal=false, String html="") |
| Setup web server. More...
|
|
void | setupInternet (String ssid, String password) |
| Setup internet access. More...
|
|
void | setupOTA () |
|
int | sendPayloadStandard (String msg="", String topic="", String senderId="", String messageId="", String path="") |
| Send a duck LoRa message. More...
|
|
bool | isWifiConnected () |
| Check wifi connection status. More...
|
|
bool | ssidAvailable (String ssid) |
| Check if the give access point is available. More...
|
|
String | getSsid () |
| Get the access point ssid. More...
|
|
String | getPassword () |
| Get the wifi access point password. More...
|
|
◆ Duck() [1/2]
Construct a new Duck object.
◆ Duck() [2/2]
Construct a new Duck object.
- Parameters
-
◆ ~Duck()
◆ getPassword()
String Duck::getPassword |
( |
| ) |
|
|
inline |
Get the wifi access point password.
- Returns
- the wifi access point password as a string.
◆ getReceiveFlag()
static bool Duck::getReceiveFlag |
( |
| ) |
|
|
inlinestaticprotected |
◆ getSsid()
Get the access point ssid.
- Returns
- the wifi access point as a string
◆ getType()
virtual int Duck::getType |
( |
| ) |
|
|
protectedpure virtual |
◆ handleOtaUpdate()
void Duck::handleOtaUpdate |
( |
| ) |
|
|
protected |
Handle over the air firmware update.
◆ imAlive()
bool Duck::imAlive |
( |
void * |
| ) |
|
|
staticprotected |
◆ isWifiConnected()
bool Duck::isWifiConnected |
( |
| ) |
|
|
inline |
Check wifi connection status.
- Returns
- true if device wifi is connected, false otherwise.
◆ onPacketReceived()
void Duck::onPacketReceived |
( |
void |
| ) |
|
|
staticprotected |
◆ processPortalRequest()
void Duck::processPortalRequest |
( |
| ) |
|
|
protected |
Handle request from emergency portal.
◆ reboot()
bool Duck::reboot |
( |
void * |
| ) |
|
|
staticprotected |
◆ reconnectWifi()
virtual int Duck::reconnectWifi |
( |
String |
ssid, |
|
|
String |
password |
|
) |
| |
|
inlineprotectedvirtual |
◆ run()
virtual void Duck::run |
( |
| ) |
|
|
protectedpure virtual |
Implement the duck's specific behavior.
This method must be implemented by the Duck's concrete classes such as DuckLink, MamaDuck,...
◆ sendPayloadStandard()
int Duck::sendPayloadStandard |
( |
String |
msg = "" , |
|
|
String |
topic = "" , |
|
|
String |
senderId = "" , |
|
|
String |
messageId = "" , |
|
|
String |
path = "" |
|
) |
| |
Send a duck LoRa message.
- Parameters
-
msg | the message payload (optional: if not provided, it will be set to an empty string) |
topic | the message topic (optional: if not provided, it will be set to "status") |
senderId | the sender id (optional: if not provided, it will be set to the duck device id) |
messageId | the message id (optional: if not provided, a unique id will be generated) |
path | the message path to append the device id to (optional: if not provided, the path will only contain the duck's device id) |
- Returns
- DUCK_ERR_NONE if success, an error code otherwise.
◆ setReceiveFlag()
static void Duck::setReceiveFlag |
( |
bool |
value | ) |
|
|
inlinestaticprotected |
◆ setupDns()
Setup DNS.
- Returns
- DUCK_ERROR_NONE if successful, an error code otherwise.
◆ setupInternet()
void Duck::setupInternet |
( |
String |
ssid, |
|
|
String |
password |
|
) |
| |
Setup internet access.
- Parameters
-
ssid | the ssid of the WiFi network |
password | password to join the network |
◆ setupOTA()
◆ setupRadio()
Setup the radio component.
- Parameters
-
band | radio frequency in Mhz (default: 915.0) |
ss | slave select pin (default CDPCFG_PIN_LORA_CS) |
rst | reset pin (default: CDPCFG_PIN_LORA_RST) |
di0 | dio0 interrupt pin (default: CDPCFG_PIN_LORA_DIO0) |
di1 | dio1 interrupt pin (default: CDPCFG_PIN_LORA_DIO1) |
txPower | transmit power (default: CDPCFG_RF_LORA_TXPOW) |
◆ setupSerial()
void Duck::setupSerial |
( |
int |
baudRate = 115200 | ) |
|
Setup serial connection.
- Parameters
-
◆ setupWebServer()
void Duck::setupWebServer |
( |
bool |
createCaptivePortal = false , |
|
|
String |
html = "" |
|
) |
| |
Setup web server.
The WebServer is used to communicate with the Duck over ad-hoc WiFi connection.
- Parameters
-
createCaptivePortal | set to true if Captive WiFi connection is needed. Defaults to false |
html | A string representing custom HTML code used for the portal. Default is an empty string Default portal web page is used if the string is empty |
◆ setupWifi()
void Duck::setupWifi |
( |
const char * |
ap = "🆘 DUCK EMERGENCY PORTAL" | ) |
|
Setup WiFi access point.
- Parameters
-
accessPoint | a string representing the access point. Default to "🆘 DUCK EMERGENCY PORTAL" |
◆ setupWithDefaults()
virtual void Duck::setupWithDefaults |
( |
String |
ssid, |
|
|
String |
password |
|
) |
| |
|
inlineprotectedvirtual |
Setup a duck with default settings.
The default implementation simply initializes the serial interface. It can be overriden by each concrete Duck class implementation.
◆ ssidAvailable()
bool Duck::ssidAvailable |
( |
String |
ssid | ) |
|
|
inline |
Check if the give access point is available.
- Parameters
-
ssid | access point to check |
- Returns
- true if the access point is available, false otherwise.
◆ startReceive()
int Duck::startReceive |
( |
| ) |
|
|
protected |
Tell the duck radio to start receiving packets from the mesh network.
- Returns
- DUCK_ERR_NONE if successful, an error code otherwise
◆ startTransmit()
int Duck::startTransmit |
( |
| ) |
|
|
protected |
Tell the duck radio to start receiving packets from the mesh network.
- Returns
- DUCK_ERR_NONE if successful, an error code otherwise
◆ toggleReceiveFlag()
static void Duck::toggleReceiveFlag |
( |
| ) |
|
|
inlinestaticprotected |
◆ deviceId
◆ duckLora
◆ duckNet
◆ receivedFlag
volatile bool Duck::receivedFlag = false |
|
staticprotected |
The documentation for this class was generated from the following files:
- /Users/timowielink/Documents/Arduino/libraries/ClusterDuck-Protocol/src/include/Duck.h
- /Users/timowielink/Documents/Arduino/libraries/ClusterDuck-Protocol/src/Ducks/Duck.cpp