Props to prop no plural
This commit is contained in:
+11
-11
@@ -1,8 +1,8 @@
|
||||
# Arduino Props for Escape Room 2.0
|
||||
|
||||
The *ArduinoProps library* for Arduino has been designed to build *escape room 2.0 props*.
|
||||
The *ArduinoProps library* for Arduino has been designed to build *escape room 2.0 prop*.
|
||||
|
||||
Specificities of props for escape rooms:
|
||||
Specificities of prop for escape rooms:
|
||||
- very high uptime (near 100%)
|
||||
- fast problem fixing
|
||||
- real-time (human scale) notification and control
|
||||
@@ -15,7 +15,7 @@ Benefits and specificities of the *ArduinoProps library*
|
||||
- constant sustaining of Arduino code (YUN)
|
||||
- real-time notification, monitoring and control (human scale)
|
||||
|
||||
# Escape room 2.0 constraints on props
|
||||
# Escape room 2.0 constraints on prop
|
||||
Escape game are opened 7 days a week and particularly booked during weekends and usually until midnight. Therefore their uptime must be close to 100% and incidents must be worked-around immediately by the game master (manual commands).
|
||||
|
||||
Escape Room Props operation and performance impact directly escape game customer experience. Therefore notifications must be processed in human-scale real-time, automatically or manually by a non-technological user (the game master).
|
||||
@@ -24,7 +24,7 @@ Escape Room Props TCO (Total Cost of Ownership) must be affordable by escape gam
|
||||
|
||||

|
||||
|
||||
IT professional 24/7 support must be avoided for cost reasons. Therefore props code must be the most reliable.
|
||||
IT professional 24/7 support must be avoided for cost reasons. Therefore prop code must be the most reliable.
|
||||
|
||||
|
||||
# *ArduinoProps library* for escape room 2.0
|
||||
@@ -39,10 +39,10 @@ IT professional 24/7 support must be avoided for cost reasons. Therefore props c
|
||||
|
||||
How does *ArduinoProps library* use MQTT efficiently in escape rooms:
|
||||
|
||||
- Every props has two MQTT topics assigned as inbox and outbox.
|
||||
- Every prop has two MQTT topics assigned as inbox and outbox.
|
||||
- More MQTT topics can be used to share game countdown, scenario or any common useful dynamic data for the escape game.
|
||||
- Notifying the props is done by publishing a message on its inbox topic.
|
||||
- Other props or software controllers can subscribe to the props outbox topic to receive all its notifications.
|
||||
- Notifying the prop is done by publishing a message on its inbox topic.
|
||||
- Other prop or software controllers can subscribe to the prop outbox topic to receive all its notifications.
|
||||
- *ArduinoProps library* includes a ping process at application level, in LAN network the round-trip-delay is around 50 milliseconds.
|
||||
- *ArduinoProps library* is defaulted to publish QoS 0 messages and to subscribe at QoS 1.
|
||||
|
||||
@@ -61,7 +61,7 @@ Arduino YUN can be rebooted or its MCU resetted remotely with simple SSH command
|
||||
|
||||
Moreover, SSH command can be used to remotely change the MQTT server IP address, *ArduinoProps library* read this address at sketch start.
|
||||
|
||||
Therefore, **Arduino YUN or YUN shield is the preferred solution for props with Arduino boards** because it will be very easy to sustain over time and greatly facilitates fallback plans to ensure maximum uptime:
|
||||
Therefore, **Arduino YUN or YUN shield is the preferred solution for prop with Arduino boards** because it will be very easy to sustain over time and greatly facilitates fallback plans to ensure maximum uptime:
|
||||
- **Arduino Yún**
|
||||
- **Arduino Yún Rev 2**
|
||||
- **Arduino Mega 2560 Rev3 + Dragino Yún Shield**
|
||||
@@ -71,7 +71,7 @@ Therefore, **Arduino YUN or YUN shield is the preferred solution for props with
|
||||
|
||||
|
||||
# Arduino Ethernet and Wifi
|
||||
Arduino with Ethernet or Wifi shield is suitable to build an Escape Room Props, however the sketch must be uploaded with an USB cable, so it is not convenient for props design and worse for props in production, which can lead to an unexpected significant increase in TCO.
|
||||
Arduino with Ethernet or Wifi shield is suitable to build an Escape Room Props, however the sketch must be uploaded with an USB cable, so it is not convenient for prop design and worse for prop in production, which can lead to an unexpected significant increase in TCO.
|
||||
|
||||
|
||||
# Compatible hardware
|
||||
@@ -85,9 +85,9 @@ Arduino with Ethernet or Wifi shield is suitable to build an Escape Room Props,
|
||||
- Arduino Ethernet
|
||||
- Arduino Ethernet Shield
|
||||
|
||||
For WiFi props, please update the WiFiNINA firmware: [WiFiNINA firmware update](WifiNinaFirmware.md).
|
||||
For WiFi prop, please update the WiFiNINA firmware: [WiFiNINA firmware update](WifiNinaFirmware.md).
|
||||
|
||||
To use other WiFi hardware compatible with any *<a href="https://github.com/knolleary/pubsubclient" target="_blank">Nick O'Leary PubSubClient</a>* library you have to fork `WifiProps.h` and `WifiProps.cpp` and to replace `WiFiNINA.h` whih appropriate WiFi library (`ESP8266WiFi.h` for example):
|
||||
To use other WiFi hardware compatible with any *<a href="https://github.com/knolleary/pubsubclient" target="_blank">Nick O'Leary PubSubClient</a>* library you have to fork `WifiProp.h` and `WifiProp.cpp` and to replace `WiFiNINA.h` whih appropriate WiFi library (`ESP8266WiFi.h` for example):
|
||||
- Arduino WiFi Shield
|
||||
- Sparkfun WiFly Shield – [library](https://github.com/dpslwk/WiFly)
|
||||
- TI CC3000 WiFi - [library](https://github.com/sparkfun/SFE_CC3000_Library)
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
# *Props* class reference
|
||||
# *Prop* class reference
|
||||
|
||||
*Props* is a base class for 3 connected props, depending on their network interface:
|
||||
* ***BridgeProps*** for Yun board and Yun shield
|
||||
* ***EthernetProps*** for Ethernet shield
|
||||
* ***WifiProps*** for WiFiNINA boards
|
||||
*Prop* is a base class for 3 connected prop, depending on their network interface:
|
||||
* ***BridgeProp*** for Yun board and Yun shield
|
||||
* ***EthernetProp*** for Ethernet shield
|
||||
* ***WifiProp*** for WiFiNINA boards
|
||||
|
||||
*Props* class reference:
|
||||
1. Define the *Props*
|
||||
* Defining a *BridgeProps*
|
||||
* Defining an *EthernetProps*
|
||||
* Defining a *WifiProps*
|
||||
2. Setup the *Props*
|
||||
*Prop* class reference:
|
||||
1. Define the *Prop*
|
||||
* Defining a *BridgeProp*
|
||||
* Defining an *EthernetProp*
|
||||
* Defining a *WifiProp*
|
||||
2. Setup the *Prop*
|
||||
* Change timings
|
||||
3. Call in sketch *loop()*
|
||||
4. Implement `InboxMessage::run()` callback
|
||||
5. Update broker address from SSH (*BridgeProps*)
|
||||
5. Update broker address from SSH (*BridgeProp*)
|
||||
6. Examples
|
||||
7. Compatible hardware
|
||||
|
||||
|
||||
## 1. Defines the *Props*
|
||||
Defining a Bridge (Yun), Ethernet or Wifi *Props* is slighlty different.
|
||||
## 1. Defines the *Prop*
|
||||
Defining a Bridge (Yun), Ethernet or Wifi *Prop* is slighlty different.
|
||||
|
||||
### Defining a *BridgeProps*
|
||||
### Defining a *BridgeProp*
|
||||
```csharp
|
||||
#include <Bridge.h>
|
||||
#include "ArduinoProps.h"
|
||||
@@ -31,23 +31,23 @@ Defining a Bridge (Yun), Ethernet or Wifi *Props* is slighlty different.
|
||||
// prpos inbox/outbox syntax Room/[escape room name]/Props/[propsname]/inbox|outbox
|
||||
// https://live-escape.net/go/room
|
||||
|
||||
BridgeProps props(u8"Arduino Contrôleur", // as MQTT client id, should be unique per client for given broker
|
||||
BridgeProp prop(u8"Arduino Contrôleur", // as MQTT client id, should be unique per client for given broker
|
||||
u8"Room/Demoniak/Props/Arduino Contrôleur/inbox",
|
||||
u8"Room/Demoniak/Props/Arduino Contrôleur/outbox",
|
||||
"192.168.1.42", // your MQTT server IP address
|
||||
1883); // your MQTT server port;
|
||||
|
||||
PropsDataLogical clignoter(u8"clignote", u8"oui", u8"non", true);
|
||||
PropsDataLogical led(u8"led");
|
||||
PropDataLogical clignoter(u8"clignote", u8"oui", u8"non", true);
|
||||
PropDataLogical led(u8"led");
|
||||
|
||||
void clignote(); // forward
|
||||
PropsAction clignoteAction = PropsAction(1000, clignote);
|
||||
PropAction clignoteAction = PropAction(1000, clignote);
|
||||
```
|
||||
Create *BridgeProps* instance with MQTT parameters, then create *PropsData* instances and *PropsActions*.
|
||||
Create *BridgeProp* instance with MQTT parameters, then create *PropData* instances and *PropsActions*.
|
||||
|
||||
The *Bridge* instance is created by `#include <Bridge.h>`.
|
||||
|
||||
### Defining an *EthernetProps*
|
||||
### Defining an *EthernetProp*
|
||||
```csharp
|
||||
#include <Ethernet.h>
|
||||
#include <IPAddress.h>
|
||||
@@ -64,25 +64,25 @@ String ip = "192.168.1.19"; //<<< ENTER YOUR IP ADDRESS HERE ("" for DHCP)
|
||||
// prpos inbox/outbox syntax Room/[escape room name]/Props/[propsname]/inbox|outbox
|
||||
// https://live-escape.net/go/room
|
||||
|
||||
EthernetProps props(u8"Arduino Contrôleur", // as MQTT client id, should be unique per client for given broker
|
||||
EthernetProp prop(u8"Arduino Contrôleur", // as MQTT client id, should be unique per client for given broker
|
||||
u8"Room/Demoniak/Props/Arduino Contrôleur/inbox",
|
||||
u8"Room/Demoniak/Props/Arduino Contrôleur/outbox",
|
||||
"192.168.1.42", // your MQTT server IP address
|
||||
1883); // your MQTT server port;
|
||||
|
||||
PropsDataLogical clignoter(u8"clignote", u8"oui", u8"non", true);
|
||||
PropsDataLogical led(u8"led");
|
||||
PropDataLogical clignoter(u8"clignote", u8"oui", u8"non", true);
|
||||
PropDataLogical led(u8"led");
|
||||
|
||||
void clignote(); // forward
|
||||
PropsAction clignoteAction = PropsAction(1000, clignote);
|
||||
PropAction clignoteAction = PropAction(1000, clignote);
|
||||
```
|
||||
Create MAC address (which must be unique, it's the hardware ID in the netwprk).
|
||||
|
||||
Create *EthernetProps* instance with MQTT parameters, then create *PropsData* instances and *PropsActions*.
|
||||
Create *EthernetProp* instance with MQTT parameters, then create *PropData* instances and *PropsActions*.
|
||||
|
||||
The *Ethernet* instance is created by `#include <Ethernet.h>`.
|
||||
|
||||
### Defining a *WifiProps*
|
||||
### Defining a *WifiProp*
|
||||
```csharp
|
||||
#include "ArduinoProps.h"
|
||||
|
||||
@@ -98,69 +98,69 @@ const char *passphrase = "";
|
||||
// prpos inbox/outbox syntax Room/[escape room name]/Props/[propsname]/inbox|outbox
|
||||
// https://live-escape.net/go/room
|
||||
|
||||
WifiProps props(u8"Arduino Contrôleur", // as MQTT client id, should be unique per client for given broker
|
||||
WifiProp prop(u8"Arduino Contrôleur", // as MQTT client id, should be unique per client for given broker
|
||||
u8"Room/Demoniak/Props/Arduino Contrôleur/inbox",
|
||||
u8"Room/Demoniak/Props/Arduino Contrôleur/outbox",
|
||||
"192.168.1.42", // your MQTT server IP address
|
||||
1883); // your MQTT server port;
|
||||
|
||||
PropsDataLogical clignoter(u8"clignote", u8"oui", u8"non", true);
|
||||
PropsDataLogical led(u8"led");
|
||||
PropDataLogical clignoter(u8"clignote", u8"oui", u8"non", true);
|
||||
PropDataLogical led(u8"led");
|
||||
|
||||
void clignote(); // forward
|
||||
PropsAction clignoteAction = PropsAction(1000, clignote);
|
||||
PropAction clignoteAction = PropAction(1000, clignote);
|
||||
```
|
||||
The *AduinoProps* library uses **<a href="https://github.com/arduino-libraries/WiFiNINA" target="_blank">WiFiNINA</a>** WiFi library for **Arduino Uno WiFi Rev 2**, **Arduino NANO 33 IoT**, **Arduino MKR WiFi 1010** and **Arduino MKR VIDOR 4000**.
|
||||
|
||||
Please update the WiFiNINA firmware: [WiFiNINA firmware update](WifiNinaFirmware.md).
|
||||
|
||||
Create *WifiProps* instance with MQTT parameters, then create *PropsData* instances and *PropsActions*.
|
||||
Create *WifiProp* instance with MQTT parameters, then create *PropData* instances and *PropsActions*.
|
||||
|
||||
#### MQTT topics
|
||||
The props listens to the *inbox* topic for command messages and send data and messages into the *outbox* topic.
|
||||
The prop listens to the *inbox* topic for command messages and send data and messages into the *outbox* topic.
|
||||
|
||||
If you're running Live Escape Room 2.0 control software, you have to respect *inbox*/*outbox* syntax:
|
||||
|
||||
Room 2.0 *inbox* topic:
|
||||
```csharp
|
||||
format: Room/[escape room name]/Props/[props name]/inbox
|
||||
format: Room/[escape room name]/Props/[prop name]/inbox
|
||||
example: u8"Room/Demoniak/Props/Arduino Contrôleur/inbox"
|
||||
```
|
||||
Room 2.0 *outbox* topic:
|
||||
```csharp
|
||||
format: Room/[escape room name]/Props/[props name]/outbox
|
||||
format: Room/[escape room name]/Props/[prop name]/outbox
|
||||
example: u8"Room/Demoniak/Props/Arduino Contrôleur/outbox"
|
||||
```
|
||||
See [README.md](../README.md): **4. Application protocol for escape room 2.0 props**.
|
||||
See [README.md](../README.md): **4. Application protocol for escape room 2.0 prop**.
|
||||
|
||||
#### *PropsData* instances
|
||||
*PropsData* provides a facility to monitor data sent into MQTT outbox.
|
||||
#### *PropData* instances
|
||||
*PropData* provides a facility to monitor data sent into MQTT outbox.
|
||||
|
||||
See [PropsData.md](PropsData.md) for *PropsData* reference.
|
||||
See [PropData.md](PropData.md) for *PropData* reference.
|
||||
|
||||
#### *PropsAction* instances
|
||||
To maintain a non-blocking asynchronous behavior of your props, use *PropsAction* objects to trigger action periodically.
|
||||
#### *PropAction* instances
|
||||
To maintain a non-blocking asynchronous behavior of your prop, use *PropAction* objects to trigger action periodically.
|
||||
|
||||
Reading I/O and simple computing (arithmetics) can be done at every sketch loop but long computing have to run periodically.
|
||||
|
||||
For example, to blink a led, don't block the skecth with a `delay(1000)` call to switch the output: instead, ***check if 1 second is elapsed to switch the output***.
|
||||
|
||||
See [PropsAction.md](PropsData.md) for *PropsAction* reference.
|
||||
See [PropAction.md](PropData.md) for *PropAction* reference.
|
||||
|
||||
|
||||
## 2. Setup the *Props*
|
||||
## 2. Setup the *Prop*
|
||||
`InboxMessage::run` is the callback executed when a message is received in the MQTT inbox.
|
||||
```csharp
|
||||
void setup()
|
||||
{
|
||||
// CODE TO BEGIN THE INTERNET CONNECTION
|
||||
... see below the different code for BridgeProps, EthenetProps and WifiProps
|
||||
... see below the different code for BridgeProp, EthenetProps and WifiProp
|
||||
|
||||
// SAME CODE FOR ALL PROPS
|
||||
props.addData(&clignoter);
|
||||
props.addData(&led);
|
||||
prop.addData(&clignoter);
|
||||
prop.addData(&led);
|
||||
|
||||
props.begin(InboxMessage::run);
|
||||
prop.begin(InboxMessage::run);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT); // initialize digital pin LED_BUILTIN as an output
|
||||
|
||||
@@ -169,20 +169,20 @@ void setup()
|
||||
|
||||
```
|
||||
|
||||
*BridgeProps*, *EthenetProps* and *WifiProps* has the exactly same setup:
|
||||
*BridgeProp*, *EthenetProps* and *WifiProp* has the exactly same setup:
|
||||
|
||||
- add *PropsData* references to the props
|
||||
- call `props.begin(InboxMessage::run)`
|
||||
- add *PropData* references to the prop
|
||||
- call `prop.begin(InboxMessage::run)`
|
||||
|
||||
The setup code is slighlty different to start the network client (bridge, ethernet of wifi):
|
||||
```csharp
|
||||
void setup()
|
||||
{
|
||||
#if defined(BRIDGEPROPS_H)
|
||||
#if defined(BRIDGEPROP_H)
|
||||
Bridge.begin();
|
||||
updateBrokerAdressFromFile("/root/broker", &props); // if you're running our Escape Room control software (Room 2.0)
|
||||
updateBrokerAdressFromFile("/root/broker", &prop); // if you're running our Escape Room control software (Room 2.0)
|
||||
|
||||
#elif defined(ETHERNETPROPS_H)
|
||||
#elif defined(ETHERNETPROP_H)
|
||||
// can do more static IP configuration
|
||||
//Ethernet.setSubnetMask(IPAddress());
|
||||
//Ethernet.setGatewayIP(IPAddress());
|
||||
@@ -201,7 +201,7 @@ void setup()
|
||||
}
|
||||
delay(1500); // time for shield stuff
|
||||
|
||||
#elif defined(WIFIPROPS_H)
|
||||
#elif defined(WIFIPROP_H)
|
||||
// can do more static IP configuration
|
||||
//WiFi.config(IPAddress(), IPAddress(), IPAddress());
|
||||
//WiFi.config(IPAddress(), IPAddress());
|
||||
@@ -221,11 +221,11 @@ void setup()
|
||||
### Change timings
|
||||
Default timings are:
|
||||
* check data changes every 400 milliseconds
|
||||
* *Props* remains silent for up to 30 seconds
|
||||
* *Prop* remains silent for up to 30 seconds
|
||||
|
||||
Timings can be changed anywhere in the code with `resetIntervals()`:
|
||||
```csharp
|
||||
props.resetIntervals(250, 15); // check data changes every 250 milliseconds, silent up to 15 seconds
|
||||
prop.resetIntervals(250, 15); // check data changes every 250 milliseconds, silent up to 15 seconds
|
||||
```
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ Timings can be changed anywhere in the code with `resetIntervals()`:
|
||||
```csharp
|
||||
void loop()
|
||||
{
|
||||
props.loop();
|
||||
prop.loop();
|
||||
|
||||
led.setValue(digitalRead(LED_BUILTIN)); // read I/O
|
||||
|
||||
@@ -243,7 +243,7 @@ void loop()
|
||||
```
|
||||
Couldn't be more simple!
|
||||
|
||||
Just call `props.loop()` when entering the sketch `loop()`, it will maintain MQTT broker connection and run callback when receiving MQTT messages.
|
||||
Just call `prop.loop()` when entering the sketch `loop()`, it will maintain MQTT broker connection and run callback when receiving MQTT messages.
|
||||
|
||||
|
||||
## 4. Implement `InboxMessage::run()` callback
|
||||
@@ -255,40 +255,40 @@ void InboxMessage::run(String a) {
|
||||
|
||||
if (a == u8"app:startup")
|
||||
{
|
||||
props.sendAllData();
|
||||
props.sendDone(a);
|
||||
prop.sendAllData();
|
||||
prop.sendDone(a);
|
||||
}
|
||||
else if (a == "clignoter:1")
|
||||
{
|
||||
clignoter.setValue(true);
|
||||
|
||||
props.sendAllData(); // all data change, we don't have to be selctive then
|
||||
props.sendDone(a); // acknowledge props command action
|
||||
prop.sendAllData(); // all data change, we don't have to be selctive then
|
||||
prop.sendDone(a); // acknowledge prop command action
|
||||
}
|
||||
else if (a == "clignoter:0")
|
||||
{
|
||||
clignoter.setValue(false);
|
||||
|
||||
props.sendAllData(); // all data change, we don't have to be selctive then
|
||||
props.sendDone(a); // acknowledge props command action
|
||||
prop.sendAllData(); // all data change, we don't have to be selctive then
|
||||
prop.sendDone(a); // acknowledge prop command action
|
||||
}
|
||||
else
|
||||
{
|
||||
// acknowledge omition of the props command
|
||||
props.sendOmit(a);
|
||||
// acknowledge omition of the prop command
|
||||
prop.sendOmit(a);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## 5. Update broker address from SSH (*BridgeProps*)
|
||||
## 5. Update broker address from SSH (*BridgeProp*)
|
||||
Room 2.0 use a SSH command to change remotely the broker IP address (in /root/broker file) and to relaunch to sketch:
|
||||
```bash
|
||||
ssh 'echo 192.168.1.14> /root/broker && reset-mcu'
|
||||
```
|
||||
On the *BridgeProps* you can read the broker IP address from Linino filesystem with this code:
|
||||
On the *BridgeProp* you can read the broker IP address from Linino filesystem with this code:
|
||||
```csharp
|
||||
void updateBrokerAdressFromFile(const char* broker_file, BridgeProps* props)
|
||||
void updateBrokerAdressFromFile(const char* broker_file, BridgeProp* prop)
|
||||
{
|
||||
// broker IP address is stored in Linino file systems and updated with ssh command by Room 2.0
|
||||
IPAddress ip;
|
||||
@@ -304,7 +304,7 @@ void updateBrokerAdressFromFile(const char* broker_file, BridgeProps* props)
|
||||
}
|
||||
b.trim();
|
||||
|
||||
if (ip.fromString(b.c_str())) props->setBrokerIpAddress(ip);
|
||||
if (ip.fromString(b.c_str())) prop->setBrokerIpAddress(ip);
|
||||
}
|
||||
```
|
||||
|
||||
@@ -312,12 +312,12 @@ void updateBrokerAdressFromFile(const char* broker_file, BridgeProps* props)
|
||||
## 6. Examples
|
||||
The library comes with a number of example sketches. See **File > Examples > ArduinoProps** within the Arduino IDE application.
|
||||
|
||||
See [EXAMPLES.md](../EXAMPLES.md) for an adaptation of the Blink example (https://www.arduino.cc/en/tutorial/blink) as a simple MQTT props:
|
||||
See [EXAMPLES.md](../EXAMPLES.md) for an adaptation of the Blink example (https://www.arduino.cc/en/tutorial/blink) as a simple MQTT prop:
|
||||
|
||||
1. **BlinkOnBridgeProps**: the Blink example on a Yun props with *ArduinoProps library*
|
||||
2. **BlinkOnEthernetProps**: the Blink example on an Ethernet props with *ArduinoProps library*
|
||||
3. **BlinkOnWifiProps**: the Blink example on a Wifi props with *ArduinoProps library*
|
||||
4. **BlinkOnBridgePubSub**: the Blink example on props using *PubSubClient* directly
|
||||
1. **BlinkOnBridgeProps**: the Blink example on a Yun prop with *ArduinoProps library*
|
||||
2. **BlinkOnEthernetProps**: the Blink example on an Ethernet prop with *ArduinoProps library*
|
||||
3. **BlinkOnWifiProps**: the Blink example on a Wifi prop with *ArduinoProps library*
|
||||
4. **BlinkOnBridgePubSub**: the Blink example on prop using *PubSubClient* directly
|
||||
|
||||
|
||||
## 7. Compatible hardware
|
||||
@@ -331,9 +331,9 @@ See [EXAMPLES.md](../EXAMPLES.md) for an adaptation of the Blink example (https:
|
||||
- Arduino Ethernet
|
||||
- Arduino Ethernet Shield
|
||||
|
||||
For WiFi props, please update the WiFiNINA firmware: [WiFiNINA firmware update](WifiNinaFirmware.md).
|
||||
For WiFi prop, please update the WiFiNINA firmware: [WiFiNINA firmware update](WifiNinaFirmware.md).
|
||||
|
||||
To use other WiFi hardware compatible with any *<a href="https://github.com/knolleary/pubsubclient" target="_blank">Nick O'Leary PubSubClient</a>* library you have to fork `WifiProps.h` and `WifiProps.cpp` and to replace `WiFiNINA.h` whih appropriate WiFi library (`ESP8266WiFi.h` for example):
|
||||
To use other WiFi hardware compatible with any *<a href="https://github.com/knolleary/pubsubclient" target="_blank">Nick O'Leary PubSubClient</a>* library you have to fork `WifiProp.h` and `WifiProp.cpp` and to replace `WiFiNINA.h` whih appropriate WiFi library (`ESP8266WiFi.h` for example):
|
||||
- Arduino WiFi Shield
|
||||
- Sparkfun WiFly Shield – [library](https://github.com/dpslwk/WiFly)
|
||||
- TI CC3000 WiFi - [library](https://github.com/sparkfun/SFE_CC3000_Library)
|
||||
@@ -1,11 +1,11 @@
|
||||
# *PropsAction* class reference
|
||||
# *PropAction* class reference
|
||||
|
||||
*PropsAction* brings asynchronous-like behavior to sketch `loop()`.
|
||||
*PropAction* brings asynchronous-like behavior to sketch `loop()`.
|
||||
|
||||
|
||||
## Constructors
|
||||
* `PropsAction()`
|
||||
* `PropsAction(unsigned long interval, void (*function)())`
|
||||
* `PropAction()`
|
||||
* `PropAction(unsigned long interval, void (*function)())`
|
||||
|
||||
`function` is the callback executed at every `interval` milliseconds.
|
||||
|
||||
@@ -30,9 +30,9 @@ void clignote()
|
||||
}
|
||||
```
|
||||
|
||||
### Create a *PropsAction* instance
|
||||
### Create a *PropAction* instance
|
||||
```csharp
|
||||
PropsAction clignoteAction = PropsAction(1000, clignote); // interval every 1000 milliseconds
|
||||
PropAction clignoteAction = PropAction(1000, clignote); // interval every 1000 milliseconds
|
||||
```
|
||||
|
||||
### Call the instance `check()` method ine the sketch `loop()`
|
||||
@@ -0,0 +1,76 @@
|
||||
# *PropData* reference
|
||||
|
||||
*PropData* tracks data changes and provides escape room 2.0 propocol `DATA` ready string format.
|
||||
|
||||
See **4. Application protocol for escape room 2.0 prop** in [README.md](../README.md).
|
||||
|
||||
*PropData* is an interface (base class) implemented by 4 classes:
|
||||
* ***PropDataDecimal***
|
||||
* ***PropDataInteger***
|
||||
* ***PropDataLogical***
|
||||
* ***PropDataText***
|
||||
|
||||
## Constructors
|
||||
* `PropDataDecimal(const char *, uint8_t digits = 2, double precision = 0.1, double initial = 0)`
|
||||
* `PropDataInteger(const char *, double precision = 0.1, long initial = 0)`
|
||||
* `PropDataLogical(const char *, const char *trueval = NULL, const char *falseval = NULL, bool initial = false)`
|
||||
* `PropDataText(const char *)`
|
||||
|
||||
By default for *PropDataLogical*, `trueval` is `"1"` band `falseval` is `"0"`.
|
||||
|
||||
For *PropDataDecimal*, `digits` is the number of decimal digits in the display string.
|
||||
|
||||
For *PropDataDecimal* and *PropDataInteger*, `precision` is the percentage threshold for deciding whether a change has occurred or not.
|
||||
|
||||
## Interface
|
||||
* `String fetch()`
|
||||
* `String fetchChange()`
|
||||
|
||||
*fetch()* always returns the `"var=value "` string ready to be sent in a `DATA` protocol message and update the `_previous` value.
|
||||
|
||||
*fetchChange()* checks whether a change has occurred or not. If a change occured, returns the `"var=value "` string ready to be sent in a `DATA` protocol message and update the `_previous` value. If no change occured, returns and empty string.
|
||||
|
||||
## Accessors and Mutators
|
||||
* `void setValue(const double|long|bool|String)`
|
||||
* `double|long|bool|String value() const`
|
||||
|
||||
Accessors and Mutators are typed according to *PropData* type.
|
||||
|
||||
## Usage
|
||||
|
||||
### Create a *PropData* instance
|
||||
```csharp
|
||||
PropDataLogical clignoter(u8"clignote", u8"oui", u8"non", true);
|
||||
```
|
||||
|
||||
### Add the *PropData* instance to managed data of the *Props*
|
||||
```csharp
|
||||
void setup()
|
||||
{
|
||||
...
|
||||
|
||||
Props::addManagedLogicalData(&clignoter);
|
||||
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### Use the *PropData* instance anywhere
|
||||
```csharp
|
||||
clignoter.setValue(true);
|
||||
|
||||
...
|
||||
|
||||
if (clignoter.value()) {
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
led.setValue(digitalRead(LED_BUILTIN));
|
||||
}
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
**Marie FAURE** (Oct 18th, 2019)
|
||||
* company: FAURE SYSTEMS SAS
|
||||
* mail: *dev at faure dot systems*
|
||||
* github: <a href="https://github.com/fauresystems?tab=repositories" target="_blank">fauresystems</a>
|
||||
* web: <a href="https://faure.systems/" target="_blank">Faure Systems</a>
|
||||
@@ -1,76 +0,0 @@
|
||||
# *PropsData* reference
|
||||
|
||||
*PropsData* tracks data changes and provides escape room 2.0 propocol `DATA` ready string format.
|
||||
|
||||
See **4. Application protocol for escape room 2.0 props** in [README.md](../README.md).
|
||||
|
||||
*PropsData* is an interface (base class) implemented by 4 classes:
|
||||
* ***PropsDataDecimal***
|
||||
* ***PropsDataInteger***
|
||||
* ***PropsDataLogical***
|
||||
* ***PropsDataText***
|
||||
|
||||
## Constructors
|
||||
* `PropsDataDecimal(const char *, uint8_t digits = 2, double precision = 0.1, double initial = 0)`
|
||||
* `PropsDataInteger(const char *, double precision = 0.1, long initial = 0)`
|
||||
* `PropsDataLogical(const char *, const char *trueval = NULL, const char *falseval = NULL, bool initial = false)`
|
||||
* `PropsDataText(const char *)`
|
||||
|
||||
By default for *PropsDataLogical*, `trueval` is `"1"` band `falseval` is `"0"`.
|
||||
|
||||
For *PropsDataDecimal*, `digits` is the number of decimal digits in the display string.
|
||||
|
||||
For *PropsDataDecimal* and *PropsDataInteger*, `precision` is the percentage threshold for deciding whether a change has occurred or not.
|
||||
|
||||
## Interface
|
||||
* `String fetch()`
|
||||
* `String fetchChange()`
|
||||
|
||||
*fetch()* always returns the `"var=value "` string ready to be sent in a `DATA` protocol message and update the `_previous` value.
|
||||
|
||||
*fetchChange()* checks whether a change has occurred or not. If a change occured, returns the `"var=value "` string ready to be sent in a `DATA` protocol message and update the `_previous` value. If no change occured, returns and empty string.
|
||||
|
||||
## Accessors and Mutators
|
||||
* `void setValue(const double|long|bool|String)`
|
||||
* `double|long|bool|String value() const`
|
||||
|
||||
Accessors and Mutators are typed according to *PropsData* type.
|
||||
|
||||
## Usage
|
||||
|
||||
### Create a *PropsData* instance
|
||||
```csharp
|
||||
PropsDataLogical clignoter(u8"clignote", u8"oui", u8"non", true);
|
||||
```
|
||||
|
||||
### Add the *PropsData* instance to managed data of the *Props*
|
||||
```csharp
|
||||
void setup()
|
||||
{
|
||||
...
|
||||
|
||||
Props::addManagedLogicalData(&clignoter);
|
||||
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
### Use the *PropsData* instance anywhere
|
||||
```csharp
|
||||
clignoter.setValue(true);
|
||||
|
||||
...
|
||||
|
||||
if (clignoter.value()) {
|
||||
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
|
||||
led.setValue(digitalRead(LED_BUILTIN));
|
||||
}
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
**Marie FAURE** (Oct 18th, 2019)
|
||||
* company: FAURE SYSTEMS SAS
|
||||
* mail: *dev at faure dot systems*
|
||||
* github: <a href="https://github.com/fauresystems?tab=repositories" target="_blank">fauresystems</a>
|
||||
* web: <a href="https://faure.systems/" target="_blank">Faure Systems</a>
|
||||
Reference in New Issue
Block a user