8 Commits

6 changed files with 59 additions and 14 deletions

6
.gitignore vendored
View File

@ -1 +1,7 @@
/Release/
libraries/includes/configuration.cpp
libraries/includes/configuration.h
sketch.esp8266.esp8266.nodemcu.bin
sketch.esp8266.esp8266.nodemcu.elf
sketch/sketch.esp8266.esp8266.nodemcu.bin
sketch/sketch.esp8266.esp8266.nodemcu.elf

View File

@ -4,7 +4,7 @@ stages:
build:
stage: build
image: registry.gitlab.com/wolutator/build-env-arduino:latest
image: registry.hottis.de/dockerized/build-env-arduino:latest
tags:
- hottis
- linux
@ -18,14 +18,12 @@ build:
except:
- tags
script:
- pushd $CI_PROJECT_DIR/libraries/esp8266boilerplate/ConfigGenerator && ./configGen.sh && popd
- env ARDUINO_SKETCHBOOK_DIR=$CI_PROJECT_DIR arduino-cli compile --fqbn=esp8266:esp8266:nodemcu $CI_PROJECT_DIR/sketch
- cp sketch/sketch.esp8266.esp8266.nodemcu.* .
- ./build.sh build $CI_PROJECT_DIR
release:
stage: release
image: registry.gitlab.com/wolutator/base-build-env
image: registry.hottis.de/dockerized/base-build-env
tags:
- hottis
- linux
@ -37,5 +35,5 @@ release:
- release
script:
- gitlabreleaseuploader.py -p $PRIVATE_TOKEN -i $CI_PROJECT_ID -u $CI_PROJECT_URL
-f sketch.esp8266.esp8266.nodemcu.bin -F releaseInfo.json -T $CI_COMMIT_REF_NAME
-f sketch.esp8266.esp8266.nodemcu.bin -F releaseInfo.json -T $CI_COMMIT_REF_NAME -c

36
build.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/bash
if [ "$1" == "" ]; then
echo "Give one of the targets: build, clean, upload"
echo "If you want to use a project directory different"
echo "than the current directory, give it as a second"
echo "argument."
exit 1
fi
if [ "$2" != "" ]; then
PROJECT_DIR=$2
else
PROJECT_DIR=$PWD
fi
if [ "$1" == "build" ]; then
pushd $PROJECT_DIR/libraries/esp8266boilerplate/ConfigGenerator && ./configGen.sh && popd
env ARDUINO_SKETCHBOOK_DIR=$PROJECT_DIR arduino-cli compile --fqbn=esp8266:esp8266:nodemcu $PROJECT_DIR/sketch
cp sketch/sketch.esp8266.esp8266.nodemcu.* .
elif [ "$1" == "clean" ]; then
for D in libraries/includes/configuration.h libraries/includes/configuration.cpp sketch/sketch.esp8266.esp8266.nodemcu.bin sketch/sketch.esp8266.esp8266.nodemcu.elf sketch.esp8266.esp8266.nodemcu.bin sketch.esp8266.esp8266.nodemcu.elf; do
echo -n "About to delete $D ... "
rm $PROJECT_DIR/$D && echo "done"
done
elif [ "$1" == "upload" ]; then
echo "About to upload to device"
esptool.py --port /dev/ttyUSB1 write_flash 0 sketch.esp8266.esp8266.nodemcu.bin
else
echo "Unknown subcommand '$1'"
exit 1
fi

View File

@ -8,7 +8,7 @@
#ifndef DEFINES_H_
#define DEFINES_H_
//#define DEBUG
// #define DEBUG
#define SLEEP
#define EEPROM_ADDR 0

View File

@ -1,6 +1,7 @@
{
"releaseTag": "v0.0.1",
"releaseTag": "v0.0.2",
"createReleaseTag": "true",
"createRelease": "true",
"releaseName": "initial",
"description": "initial automatic build"
}

View File

@ -75,25 +75,29 @@ void read_thermometer() {
}
void loopApplication() {
static uint32_t lastMillis = 0;
mqttLoop();
#ifndef SLEEP
static uint32_t lastMillis = 0;
uint32_t currentMillis = millis();
if (currentMillis - lastMillis > 1000) {
if (currentMillis - lastMillis > (configBlock.measurePeriod * 1000)) {
lastMillis = currentMillis;
#endif
read_thermometer();
#ifndef SLEEP
}
#endif
#ifdef SLEEP
#ifdef DEBUG
Serial.println("Sleeping");
Serial.println("Sleeping");
#endif
mqttClient.disconnect();
ESP.deepSleep(configBlock.measurePeriod * 1000000);
mqttClient.disconnect();
ESP.deepSleep(configBlock.measurePeriod * 1000000);
#endif
}
}