-
Notifications
You must be signed in to change notification settings - Fork 0
/
shelly1PM.ino
58 lines (41 loc) · 1.12 KB
/
shelly1PM.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
Firmware for Shelly 1PM: https://kb.shelly.cloud/knowledge-base/shelly-1pm
*/
#include "wifi.h"
#include "logging.h"
#include "mqtt.h"
#include "light.h"
#include "switches.h"
#include "LittleFS.h"
void setup()
{
// Setup serial
Serial.begin(115200);
// Mount the LittleFS
if (!LittleFS.begin())
logging::getLogStream().println("Failed to mounted file system");
// Setup for the switches and the light
switches::setup();
// Initialise the relay
light::setup();
// Fast blinking to show that the device is booting
switches::enableBuiltinLedBlinking(switches::LED_FAST_BLINKING);
// Setup telnet for logging and debugging, should be first
wifi::setup();
// LED on to show that the device is ready
switches::enableBuiltinLedBlinking(switches::LED_ON);
}
// the loop function runs over and over again forever
void loop()
{
wifi::handle();
// Process the telnet commands
// Interactive console for debugging
logging::handle();
// Process data for MQTT
mqtt::handle();
// Process serial data from the MCU
light::handle();
// Process the switches events
switches::handle();
}