Added MQTT and WiFi support.

This commit is contained in:
2021-01-08 05:54:55 +01:00
parent fa888bcfab
commit bfc5f1dffe
9 changed files with 167 additions and 11 deletions

View File

@ -22,4 +22,16 @@
#define MAX_MILLIAMPS 1000
#define WIFI_SSID "..."
#define WIFI_PASS "..."
#define MQTT_CLIENT_ID "espleaf"
#define MQTT_USER "..."
#define MQTT_PASS "..."
#define MQTT_SERVER "..."
#define MQTT_SERVER_PORT 1883
#define MQTT_TOPIC_STATE "espleaf/state"
#define MQTT_TOPIC_STATE_LONG "espleaf/state_long"
#define MQTT_TOPIC_COMMANDS "esplead/cmnd"
//#define TEST_MODE

37
include/config.sample.h Normal file
View File

@ -0,0 +1,37 @@
#pragma once
#define CORNERS_PER_PART 3
#define LEDS_PER_CORNER 2
// Layout definition
// Every node has EDGES_PER_PART corners and edges.
// The edge the signal comes in is edge number 0.
// All other edges are numbered counter-clockwise.
// LAYOUT contains a list of edges the signal takes.
// First node is implied.
// Examples, assuming EDGES_PER_PART == 3:
// Example: Nodes arranged in a circle: {1, 2, 2, 2, 2}
// Example: Nodes arranged in a line: {1, 2, 1, 2, 1, 2}
#define NODE_COUNT 5
#define LAYOUT {2, 1, 1, 2}
#define LED_COUNT NODE_COUNT * CORNERS_PER_PART * LEDS_PER_CORNER
#define SPEEDUP 1
#define MAX_MILLIAMPS 1000
#define WIFI_SSID "..."
#define WIFI_PASS "..."
#define MQTT_CLIENT_ID "espleaf"
#define MQTT_USER "..."
#define MQTT_PASS "..."
#define MQTT_SERVER "..."
#define MQTT_SERVER_PORT 1883
#define MQTT_TOPIC_STATE "espleaf/state"
#define MQTT_TOPIC_STATE_LONG "espleaf/state_long"
#define MQTT_TOPIC_COMMANDS "esplead/cmnd"
//#define TEST_MODE

10
include/mqtt.h Normal file
View File

@ -0,0 +1,10 @@
#pragma once
#include "wifi.h"
#include "config.h"
#include <PubSubClient.h>
static PubSubClient mqtt(wifi);
void mqtt_setup();
void mqtt_loop();

View File

@ -20,4 +20,9 @@ enum AnimationMode {
AM_NODES,
AM_FIRST_NODE,
AM_FLASH
};
};
extern AnimationMode mode;
extern AnimationMode temp_mode;
extern unsigned long temp_mode_until;

8
include/wifi.h Normal file
View File

@ -0,0 +1,8 @@
#pragma once
#include <ESP8266WiFi.h>
#include "config.h"
static WiFiClient wifi;
void wifi_setup();