Initial import

This commit is contained in:
Jens True 2019-03-23 15:48:17 +01:00
commit fccbe2247e
6 changed files with 115 additions and 0 deletions

4
.gitignore vendored Normal file

@ -0,0 +1,4 @@
.pioenvs
.piolibdeps
data/homie/config.json
nbproject

4
README.md Normal file

@ -0,0 +1,4 @@
# README #
edit data/homie/config.json
platformio run -t upload
platformio run -t uploadfs

BIN
data/homie/ui_bundle.gz Normal file

Binary file not shown.

38
lib/readme.txt Normal file

@ -0,0 +1,38 @@
This directory is intended for the project specific (private) libraries.
PlatformIO will compile them to static libraries and link to executable file.
The source code of each library should be placed in separate directory, like
"lib/private_lib/[here are source files]".
For example, see how can be organised `Foo` and `Bar` libraries:
|--lib
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |- readme.txt --> THIS FILE
|- platformio.ini
|--src
|- main.c
Then in `src/main.c` you should use:
#include <Foo.h>
#include <Bar.h>
// rest H/C/CPP code
PlatformIO will find your libraries automatically, configure preprocessor's
include paths and build them.
See additional options for PlatformIO Library Dependency Finder `lib_*`:
http://docs.platformio.org/en/latest/projectconf.html#lib-install

27
platformio.ini Normal file

@ -0,0 +1,27 @@
#
# Project Configuration File
#
# A detailed documentation with the EXAMPLES is located here:
# http://docs.platformio.org/en/latest/projectconf.html
#
# A sign `#` at the beginning of the line indicates a comment
# Comment lines are ignored.
# Simple and base environment
# [env:mybaseenv]
# platform = %INSTALLED_PLATFORM_NAME_HERE%
# framework =
# board =
#
# Automatic targets - enable auto-uploading
# targets = upload
[env:nodemcu]
platform = espressif8266
framework = arduino
board = nodemcu
upload_speed=921600
build_flags = -D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
lib_deps = https://github.com/homieiot/homie-esp8266.git#develop

42
src/main.cpp Normal file

@ -0,0 +1,42 @@
#include <Homie.h>
const int PIN_RELAY = D1;
int timer = 0;
HomieNode powerNode("power", "switch");
bool powerOnHandler(const HomieRange& range, const String& value) {
if (value != "true" && value != "false") return false;
bool on = (value == "true");
digitalWrite(PIN_RELAY, on ? LOW : HIGH);
powerNode.setProperty("on").send(value);
Homie.getLogger() << "Power is " << (on ? "on" : "off") << endl;
return true;
}
void setupHandler() {
pinMode(PIN_RELAY, OUTPUT);
digitalWrite(PIN_RELAY, HIGH);
powerNode.setProperty("on").send("false");
}
void setup() {
Serial.begin(115200);
Serial << endl << endl;
Serial << "Firmware 0.0.1" << endl;
Serial << endl << endl;
Homie_setFirmware("deskcontrol", "1.0.0");
Homie_setBrand("FuryFire");
powerNode.advertise("on").settable(powerOnHandler);
Homie.setSetupFunction(setupHandler);
Homie.setup();
}
void loop() {
Homie.loop();
}