|
|
Here, I'll walk you through the source code of the [Proprietary Lights](What-am-I-looking-at-here#proprietarylight0-2), running on ESP32 microcontrollers.
|
|
|
|
|
|
The discussed file can be found [here](https://gitlab.hrz.tu-chemnitz.de/s6869070--tu-dresden.de/vws-spielwiese/-/blob/b1802bdd98650bdb666f03483f1e13c7f99bf4b8/esp/ProprietaryLight/ProprietaryLight.ino)
|
|
|
The discussed file can be found [here](https://gitlab.hrz.tu-chemnitz.de/vws-demo/vws-spielwiese/-/blob/64e67bdaae14ef6945ab3e73b5a9c70c9c1ced67/esp/ProprietaryLight/ProprietaryLight.ino)
|
|
|
|
|
|
```
|
|
|
#define ID "ProprietaryLight0"
|
... | ... | @@ -12,7 +12,7 @@ This definition is used to identify the light inside the [Proprietary Protocol]( |
|
|
#define RED_LED 4
|
|
|
#define GREEN_LED 2
|
|
|
```
|
|
|
Here, the GPIO pins used for the red and green LEDs attached to the ESP32 Dev Board are defined. If you were to diverge from the [default wiring of the demo](TODO), you'll need to adjust the GPIO numbers here.
|
|
|
Here, the GPIO pins used for the red and green LEDs attached to the ESP32 Dev Board are defined. If you were to diverge from the [default wiring of the demo](setup/Wiring-of-the-demo), you'll need to adjust the GPIO numbers here.
|
|
|
|
|
|
```
|
|
|
#define TOPIC_PREFIX "proprietaryProtocol/" ID
|
... | ... | @@ -23,8 +23,8 @@ Here, the prefix for all MQTT topics used are defined. The string `proprietaryPr |
|
|
#include "EspMQTTClient.h"
|
|
|
#include <ESPmDNS.h>
|
|
|
```
|
|
|
Here we include both the EspMQTTClient library, required as per the [ESP32 setup guide](Setting-up-an-ESP32) and the ESPmDNS header, which comes as part of espressif's standard library for the ESP32.
|
|
|
EspMQTTClient is used for easy of use and stability of the MQTT connection, ESPmDNS is used to resolve the local address of the [ESP32 Controller](TODO) `esp-controller.local`.
|
|
|
Here we include both the EspMQTTClient library, required as per the [ESP32 setup guide](setup/Setting-up-an-ESP32) and the ESPmDNS header, which comes as part of espressif's standard library for the ESP32.
|
|
|
EspMQTTClient is used for easy of use and stability of the MQTT connection, ESPmDNS is used to resolve the local address of the [ESP32 Controller](What-am-I-looking-at-here#esp32-controller) `esp-controller.local`.
|
|
|
|
|
|
We also utilize the WiFi library, but this is included by the EspMQTTClient library, so we don't have to explicitly include that here.
|
|
|
|
... | ... | |