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: python:2.7
image: eclipse/platformio
stages:
- test
before_script:
- "pip install -U platformio"
job:
stage: test
script: script:
# - platformio lib -g install 1 - platformio ci --project-conf platformio.ini --board=heltec_wifi_lora_32
# - platformio ci --board=esp32thing - cp /home/user/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader.bin .pioenvs/heltec_wifi_lora_32/
- platformio run - cp /home/user/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin .pioenvs/heltec_wifi_lora_32/
- cp /home/user/.platformio/packages/framework-arduinoespressif32/tools/sdk/bin/bootloader.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/heltec_wifi_lora_32/firmware.bin
- cp /home/user/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin .pioenvs/esp32thing/ variables: {PLATFORMIO_CI_SRC: "src"}
# 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
artifacts: artifacts:
paths: paths:
- ".pioenvs/esp32thing/*.bin" - ".pioenvs/heltec_wifi_lora_32/*.bin"

2
src/AlarmClock.h

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

28
src/main.cpp

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

Loading…
Cancel
Save