Initial checkin.

This commit is contained in:
Pim van Pelt
2018-01-05 16:58:15 +01:00
commit 4679636fdc
42 changed files with 9600 additions and 0 deletions

32
include/main.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef __MAIN_H
#define __MAIN_H
#include "mgos.h"
#include "mgos_gpio.h"
#define CHANNEL_CHANGE_COOLDOWN_SECONDS 0.250
#define CHANNEL_MAX 16
#define GREEN_LED_GPIO 0
#define GPIO_INVALID 255
#define GPIO_MIN 0
#define GPIO_MAX 16
struct channel_t {
uint8_t button_gpio;
uint8_t led_gpio;
uint8_t relay_gpio;
bool relay_state;
double button_last_change;
};
void led_green_blink();
bool channel_init(const char *fn);
uint8_t channel_gpio_by_idx(int idx);
uint8_t channel_idx_by_gpio(int gpio);
void channel_set(int idx, bool state);
bool channel_get(int idx);
void channel_report(int idx, char *msg, int msg_len);
void channel_handler(int gpio, void *arg);
#endif // __MAIN_H

14
include/mqtt.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef __MQTT_H
#define __MQTT_H
#include "mgos.h"
#include "mgos_mqtt.h"
#define MQTT_TOPIC_PREFIX ""
#define MQTT_TOPIC_BROADCAST_CMD "/mongoose/broadcast"
#define MQTT_TOPIC_BROADCAST_STAT "/mongoose/broadcast/stat"
void mqtt_init();
void mqtt_publish_stat(const char *stat, const char *msg);
#endif // __MQTT_H

10
include/rpc.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef __RPC_H
#define __RPC_H
#include "mgos.h"
#include "mgos_rpc.h"
#include "common/mg_str.h"
void rpc_init();
#endif // __RPC_H