Compare commits

...

5 Commits

  1. 25
      .gitlab-ci.yml
  2. 2
      src/AlarmClock.h
  3. 28
      src/main.cpp

25
.gitlab-ci.yml

@ -1,12 +1,19 @@
build:
image: eclipse/platformio
image: python:2.7
stages:
- test
before_script:
- "pip install -U platformio"
job:
stage: test
script:
# - platformio lib -g install 1
# - platformio ci --board=esp32thing
- platformio run
- cp /home/user/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader.bin .pioenvs/esp32thing/
- cp /home/user/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin .pioenvs/esp32thing/
# to flash: esptool.py --before default_reset --after hard_reset --chip esp32 --port "/dev/ttyUSB0" --baud 115200 write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x1000 "/home/user/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader.bin" 0x8000 ".pioenvs/esp32thing/partitions.bin" 0xe000 "/home/user/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin" 0x10000 .pioenvs/esp32thing/firmware.bin
- platformio ci --project-conf platformio.ini --board=heltec_wifi_lora_32
- cp /home/user/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader.bin .pioenvs/heltec_wifi_lora_32/
- cp /home/user/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin .pioenvs/heltec_wifi_lora_32/
# to flash: esptool.py --before default_reset --after hard_reset --chip esp32 --port "/dev/ttyUSB0" --baud 115200 write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x1000 "/home/user/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader.bin" 0x8000 ".pioenvs/esp32thing/partitions.bin" 0xe000 "/home/user/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin" 0x10000 .pioenvs/heltec_wifi_lora_32/firmware.bin
variables: {PLATFORMIO_CI_SRC: "src"}
artifacts:
paths:
- ".pioenvs/esp32thing/*.bin"
- ".pioenvs/heltec_wifi_lora_32/*.bin"

2
src/AlarmClock.h

@ -5,7 +5,7 @@
#include <time.h>
#include <sys/time.h>
#include "apps/sntp/sntp.h"
#include "lwip/apps/sntp.h"
#include "driver/rtc_io.h"

28
src/main.cpp

@ -264,28 +264,26 @@ void transmitStatus() {
pres = bme280.readPressure();
}
StaticJsonBuffer<200> jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
StaticJsonDocument<200> jsonDocument;
if (bme280.valid) {
root["temperature"] = temp;
root["humidity"] = humi;
root["pressure"] = pres;
jsonDocument["temperature"] = temp;
jsonDocument["humidity"] = humi;
jsonDocument["pressure"] = pres;
} else {
//root["temperature"] = internal_temp;
//jsonDocument["temperature"] = internal_temp;
}
char weatherBuf[root.measureLength()+1];
root.printTo(weatherBuf, sizeof(weatherBuf));
char weatherBuf[measureJson(jsonDocument)+1];
serialize(jsonDocument, weatherBuf, sizeof(weatherBuf));
uint16_t statusPacketIdSub;
statusPacketIdSub = iot.mqtt.publish(weatherTopic.c_str(), 0, false, weatherBuf);
StaticJsonBuffer<200> jsonBuffer2;
JsonObject& root2 = jsonBuffer2.createObject();
root2["voltage"] = rom_phy_get_vdd33();
root2["rssi"] = WiFi.RSSI();
root2["heap"] = ESP.getFreeHeap();
char statusBuf[root2.measureLength()+1];
root2.printTo(statusBuf, sizeof(statusBuf));
StaticJsonDocument<200> jsonDocument2;
jsonDocument2["voltage"] = rom_phy_get_vdd33();
jsonDocument2["rssi"] = WiFi.RSSI();
jsonDocument2["heap"] = ESP.getFreeHeap();
char statusBuf[measureJson(jsonDocument2)+1];
serialize(jsonDocument2, statusBuf, sizeof(statusBuf));
statusPacketIdSub = iot.mqtt.publish(statusTopic.c_str(), 0, false, statusBuf);
}

Loading…
Cancel
Save