This commit is contained in:
Klaus K Wilting 2018-09-17 17:23:02 +02:00
parent 21621e54d5
commit bd724557c1
16 changed files with 274 additions and 208 deletions

View File

@ -142,6 +142,7 @@ Hereafter described is the default *plain* format, which uses MSB bit numbering.
byte 3-10: Uptime [seconds]
byte 11: CPU temperature [°C]
bytes 12-15: Free RAM [bytes]
bytes 16-17: Last CPU reset reason [core 0, core 1]
**Port #3:** Device configuration query result

View File

@ -1,4 +1,5 @@
/*
Parts of this file
Copyright (c) 2014-present PlatformIO <contact@platformio.org>
Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,4 +1,5 @@
/*
Parts of this file
Copyright (c) 2014-present PlatformIO <contact@platformio.org>
Licensed under the Apache License, Version 2.0 (the "License");
@ -94,7 +95,7 @@ String BintrayClient::requestHTTPContent(const String &url) const
}
else
{
Serial.printf("GET request failed, error: %s\n", http.errorToString(httpCode).c_str());
ESP_LOGE(TAG, "GET request failed, error: %s", http.errorToString(httpCode).c_str());
}
http.end();
@ -109,7 +110,7 @@ String BintrayClient::getLatestVersion() const
const size_t bufferSize = 1024;
if (jsonResult.length() > bufferSize)
{
Serial.println("Error: Could parse JSON. Input data is too big!");
ESP_LOGE(TAG, "Error: Firmware version data invalid.");
return version;
}
StaticJsonBuffer<bufferSize> jsonBuffer;
@ -118,7 +119,7 @@ String BintrayClient::getLatestVersion() const
// Check for errors in parsing
if (!root.success())
{
Serial.println("Error: Could not parse JSON!");
ESP_LOGE(TAG, "Error: Firmware version data not found.");
return version;
}
return root.get<String>("name");
@ -133,7 +134,7 @@ String BintrayClient::getBinaryPath(const String &version) const
const size_t bufferSize = 1024;
if (jsonResult.length() > bufferSize)
{
Serial.println("Error: Could parse JSON. Input data is too big!");
ESP_LOGE(TAG, "Error: Firmware download path data invalid.");
return path;
}
StaticJsonBuffer<bufferSize> jsonBuffer;
@ -142,7 +143,7 @@ String BintrayClient::getBinaryPath(const String &version) const
JsonObject &firstItem = root[0];
if (!root.success())
{ //Check for errors in parsing
Serial.println("Error: Could not parse JSON!");
ESP_LOGE(TAG, "Error: Firmware download path not found.");
return path;
}
return "/" + getUser() + "/" + getRepository() + "/" + firstItem.get<String>("path");

View File

@ -1,4 +1,5 @@
/*
Parts of this file
Copyright (c) 2014-present PlatformIO <contact@platformio.org>
Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -11,8 +11,9 @@
;env_default = heltec
;env_default = ttgov1
;env_default = ttgov2
env_default = ttgov21
;env_default = ttgobeam
;env_default = ttgov21old
;env_default = ttgov21new
env_default = ttgobeam
;env_default = lopy
;env_default = lopy4
;env_default = fipy
@ -25,14 +26,11 @@ description = Paxcounter is a proof-of-concept ESP32 device for metering passeng
[bintray]
user = cyberman54
repository = paxcounter-firmware
package = ttgov21_old
api_token = 2e10f923df5d47b9c7e25752510322a1d65ee997
[common]
release_version = 7
[ota]
; build configuration based on Bintray and Wi-Fi settings
;release_version = max. 9 chars total, using decimal format "a.b.c"
release_version = 1.4.32
wifi_ssid = testnet
wifi_password = test0815
build_flags =
@ -40,18 +38,24 @@ build_flags =
'-DWIFI_PASS="${ota.wifi_password}"'
'-DBINTRAY_USER="${bintray.user}"'
'-DBINTRAY_REPO="${bintray.repository}"'
'-DBINTRAY_PACKAGE="${bintray.package}"'
-DVERSION=${common.release_version}
lib_deps_ota =
https://github.com/platformio/bintray-secure-ota.git
'-DBINTRAY_PACKAGE="${PIOENV}"'
'-DPROGVERSION="${ota.release_version}"'
[common_env_data]
[common]
; DEBUG LEVEL
; For production run setto 0, otherwise device will leak RAM while running!
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
debug_level = 0
; UPLOAD MODE
; select esptool for USB/UART flashing, custom for OTA upload
upload_protocol = esptool
;upload_protocol = custom
extra_scripts = pre:publish_firmware.py
platform_espressif32 = espressif32@1.3.0
;platform_espressif32 = https://github.com/platformio/platform-espressif32.git#feature/stage
board_build.partitions = min_spiffs.csv
monitor_speed = 115200
lib_deps_all =
ArduinoJson@^5.13.1
; ArduinoJson${ota.lib_deps_ota}
lib_deps_display =
U8g2@>=2.23.16
lib_deps_rgbled =
@ -66,197 +70,220 @@ build_flags =
-include "src/hal/${PIOENV}.h"
${ota.build_flags}
-w
; ---> NOTE: For production run set DEBUG_LEVEL level to NONE! <---
; otherwise device may leak RAM
;
; None
; -DCORE_DEBUG_LEVEL=0
; Error
; -DCORE_DEBUG_LEVEL=1
; Warn
; -DCORE_DEBUG_LEVEL=2
; Info
-DCORE_DEBUG_LEVEL=3
; Debug
; -DCORE_DEBUG_LEVEL=4
; Verbose
; -DCORE_DEBUG_LEVEL=5
-DCORE_DEBUG_LEVEL=${common.debug_level}
[env:ebox]
platform = ${common_env_data.platform_espressif32}
platform = ${common.platform_espressif32}
framework = arduino
board = esp32dev
board_build.partitions = ${common_env_data.board_build.partitions}
board_build.partitions = ${common.board_build.partitions}
upload_speed = 115200
monitor_speed = 115200
lib_deps =
${common_env_data.lib_deps_all}
${common.lib_deps_all}
build_flags =
${common_env_data.build_flags}
${common.build_flags}
upload_protocol = ${common.upload_protocol}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
[env:heltec]
platform = ${common_env_data.platform_espressif32}
platform = ${common.platform_espressif32}
framework = arduino
board = heltec_wifi_lora_32
board_build.partitions = ${common_env_data.board_build.partitions}
board_build.partitions = ${common.board_build.partitions}
upload_speed = 115200
monitor_speed = 115200
lib_deps =
${common_env_data.lib_deps_all}
${common_env_data.lib_deps_display}
${common.lib_deps_all}
${common.lib_deps_display}
build_flags =
${common_env_data.build_flags}
${common.build_flags}
upload_protocol = ${common.upload_protocol}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
[env:ttgov1]
platform = ${common_env_data.platform_espressif32}
platform = ${common.platform_espressif32}
framework = arduino
board = esp32dev
board_build.partitions = ${common_env_data.board_build.partitions}
board_build.partitions = ${common.board_build.partitions}
upload_speed = 115200
monitor_speed = 115200
lib_deps =
${common_env_data.lib_deps_all}
${common_env_data.lib_deps_display}
${common.lib_deps_all}
${common.lib_deps_display}
build_flags =
${common_env_data.build_flags}
${common.build_flags}
upload_protocol = ${common.upload_protocol}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
[env:ttgov2]
platform = ${common_env_data.platform_espressif32}
platform = ${common.platform_espressif32}
framework = arduino
board = esp32dev
board_build.partitions = ${common_env_data.board_build.partitions}
board_build.partitions = ${common.board_build.partitions}
upload_speed = 921600
monitor_speed = 115200
lib_deps =
${common_env_data.lib_deps_all}
${common_env_data.lib_deps_display}
${common.lib_deps_all}
${common.lib_deps_display}
build_flags =
${common_env_data.build_flags}
${common.build_flags}
upload_protocol = ${common.upload_protocol}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
[env:ttgov21]
platform = ${common_env_data.platform_espressif32}
[env:ttgov21old]
platform = ${common.platform_espressif32}
framework = arduino
board = esp32dev
board_build.partitions = ${common_env_data.board_build.partitions}
board_build.partitions = ${common.board_build.partitions}
upload_speed = 921600
monitor_speed = 115200
lib_deps =
${common_env_data.lib_deps_all}
${common_env_data.lib_deps_display}
${common.lib_deps_all}
${common.lib_deps_display}
build_flags =
${common_env_data.build_flags}
;upload_protocol = custom
;extra_scripts = pre:publish_firmware.py
${common.build_flags}
upload_protocol = ${common.upload_protocol}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
[env:ttgov21new]
platform = ${common.platform_espressif32}
framework = arduino
board = esp32dev
board_build.partitions = ${common.board_build.partitions}
upload_speed = 921600
lib_deps =
${common.lib_deps_all}
${common.lib_deps_display}
build_flags =
${common.build_flags}
upload_protocol = ${common.upload_protocol}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
[env:ttgobeam]
platform = ${common_env_data.platform_espressif32}
platform = ${common.platform_espressif32}
framework = arduino
board = esp32dev
board_build.partitions = ${common_env_data.board_build.partitions}
board_build.partitions = ${common.board_build.partitions}
upload_speed = 921600
monitor_speed = 115200
lib_deps =
${common_env_data.lib_deps_all}
${common_env_data.lib_deps_gps}
${common.lib_deps_all}
${common.lib_deps_gps}
build_flags =
${common_env_data.build_flags}
${common.build_flags}
-mfix-esp32-psram-cache-issue
;upload_protocol = custom
;extra_scripts = pre:publish_firmware.py
upload_protocol = ${common.upload_protocol}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
[env:fipy]
platform = ${common_env_data.platform_espressif32}
platform = ${common.platform_espressif32}
framework = arduino
board = esp32dev
board_build.partitions = ${common_env_data.board_build.partitions}
board_build.partitions = ${common.board_build.partitions}
upload_speed = 921600
monitor_speed = 115200
lib_deps =
${common_env_data.lib_deps_all}
${common_env_data.lib_deps_rgbled}
${common.lib_deps_all}
${common.lib_deps_rgbled}
build_flags =
${common_env_data.build_flags}
${common.build_flags}
upload_protocol = ${common.upload_protocol}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
[env:lopy]
platform = ${common_env_data.platform_espressif32}
platform = ${common.platform_espressif32}
framework = arduino
board = esp32dev
board_build.partitions = ${common_env_data.board_build.partitions}
board_build.partitions = ${common.board_build.partitions}
upload_speed = 921600
monitor_speed = 115200
lib_deps =
${common_env_data.lib_deps_all}
${common_env_data.lib_deps_rgbled}
${common_env_data.lib_deps_gps}
${common.lib_deps_all}
${common.lib_deps_rgbled}
${common.lib_deps_gps}
build_flags =
${common_env_data.build_flags}
${common.build_flags}
upload_protocol = ${common.upload_protocol}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
[env:lopy4]
platform = ${common_env_data.platform_espressif32}
platform = ${common.platform_espressif32}
framework = arduino
board = esp32dev
board_build.partitions = ${common_env_data.board_build.partitions}
board_build.partitions = ${common.board_build.partitions}
upload_speed = 921600
monitor_speed = 115200
lib_deps =
${common_env_data.lib_deps_all}
${common_env_data.lib_deps_rgbled}
${common_env_data.lib_deps_gps}
${common.lib_deps_all}
${common.lib_deps_rgbled}
${common.lib_deps_gps}
build_flags =
${common_env_data.build_flags}
${common.build_flags}
-mfix-esp32-psram-cache-issue
upload_protocol = ${common.upload_protocol}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
[env:lolin32litelora]
platform = ${common_env_data.platform_espressif32}
platform = ${common.platform_espressif32}
framework = arduino
board = lolin32
board_build.partitions = ${common_env_data.board_build.partitions}
board_build.partitions = ${common.board_build.partitions}
upload_speed = 921600
monitor_speed = 115200
lib_deps =
${common_env_data.lib_deps_all}
${common_env_data.lib_deps_rgbled}
${common.lib_deps_all}
${common.lib_deps_rgbled}
build_flags =
${common_env_data.build_flags}
${common.build_flags}
upload_protocol = ${common.upload_protocol}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
[env:lolin32lora]
platform = ${common_env_data.platform_espressif32}
platform = ${common.platform_espressif32}
framework = arduino
board = lolin32
board_build.partitions = ${common_env_data.board_build.partitions}
board_build.partitions = ${common.board_build.partitions}
upload_speed = 921600
monitor_speed = 115200
lib_deps =
${common_env_data.lib_deps_all}
${common_env_data.lib_deps_rgbled}
${common.lib_deps_all}
${common.lib_deps_rgbled}
build_flags =
${common_env_data.build_flags}
${common.build_flags}
upload_protocol = ${common.upload_protocol}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
[env:lolin32lite]
platform = ${common_env_data.platform_espressif32}
platform = ${common.platform_espressif32}
framework = arduino
board = lolin32
board_build.partitions = ${common_env_data.board_build.partitions}
board_build.partitions = ${common.board_build.partitions}
upload_speed = 921600
monitor_speed = 115200
lib_deps =
${common_env_data.lib_deps_all}
${common_env_data.lib_deps_rgbled}
${common.lib_deps_all}
${common.lib_deps_rgbled}
build_flags =
${common_env_data.build_flags}
${common.build_flags}
upload_protocol = ${common.upload_protocol}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}
[env:generic]
platform = ${common_env_data.platform_espressif32}
platform = ${common.platform_espressif32}
framework = arduino
board = esp32dev
board_build.partitions = ${common_env_data.board_build.partitions}
board_build.partitions = ${common.board_build.partitions}
upload_speed = 921600
monitor_speed = 115200
lib_deps =
${common_env_data.lib_deps_all}
${common_env_data.lib_deps_rgbled}
${common_env_data.lib_deps_gps}
${common_env_data.lib_deps_display}
${common.lib_deps_all}
${common.lib_deps_rgbled}
${common.lib_deps_gps}
${common.lib_deps_display}
build_flags =
${common_env_data.build_flags}
${common.build_flags}
upload_protocol = ${common.upload_protocol}
extra_scripts = ${common.extra_scripts}
monitor_speed = ${common.monitor_speed}

View File

@ -16,31 +16,30 @@ import requests
from os.path import basename
from platformio import util
Import('env')
Import("env")
project_config = util.load_project_config()
bintray_config = {k: v for k, v in project_config.items("bintray")}
version = project_config.get("common", "release_version")
version = project_config.get("ota", "release_version")
package = env.get("PIOENV")
#
# Push new firmware to the Bintray storage using API
#
def publish_firmware(source, target, env):
def publish_bintray(source, target, env):
firmware_path = str(source[0])
firmware_name = basename(firmware_path)
print("Uploading {0} to Bintray. Version: {1}".format(
firmware_name, version))
print(firmware_path, firmware_name)
url = "/".join([
"https://api.bintray.com", "content",
bintray_config.get("user"),
bintray_config.get("repository"),
bintray_config.get("package"), version, firmware_name
package, version, firmware_name
])
print(url)
@ -65,7 +64,8 @@ def publish_firmware(source, target, env):
# Custom upload command and program name
env.Replace(
PROGNAME="firmware_v_%s" % version,
UPLOADCMD=publish_firmware
PROGNAME="firmware_" + package + "_v%s" % version,
UPLOADCMD=publish_bintray
)

View File

@ -59,16 +59,16 @@ void checkFirmwareUpdates() {
// Fetch the latest firmware version
ESP_LOGI(TAG, "OTA mode, checking latest firmware version on server...");
const String latest = bintray.getLatestVersion();
if (latest.length() == 0) {
ESP_LOGI(
TAG,
"Could not load info about the latest firmware. Rebooting to runmode.");
return;
} else if (atoi(latest.c_str()) <= VERSION) {
} else if (version_compare(latest, cfg.version) <= 0) {
ESP_LOGI(TAG, "Current firmware is up to date. Rebooting to runmode.");
return;
}
ESP_LOGI(TAG, "New firmware version v%s available. Downloading...",
latest.c_str());
processOTAUpdate(latest);
@ -219,3 +219,38 @@ void processOTAUpdate(const String &version) {
client.flush();
}
}
// helper function to compare two versions. Returns 1 if v2 is
// smaller, -1 if v1 is smaller, 0 if equal
int version_compare(const String v1, const String v2) {
// vnum stores each numeric part of version
int vnum1 = 0, vnum2 = 0;
// loop untill both string are processed
for (int i = 0, j = 0; (i < v1.length() || j < v2.length());) {
// storing numeric part of version 1 in vnum1
while (i < v1.length() && v1[i] != '.') {
vnum1 = vnum1 * 10 + (v1[i] - '0');
i++;
}
// storing numeric part of version 2 in vnum2
while (j < v2.length() && v2[j] != '.') {
vnum2 = vnum2 * 10 + (v2[j] - '0');
j++;
}
if (vnum1 > vnum2)
return 1;
if (vnum2 > vnum1)
return -1;
// if equal, reset variables and go for next numeric
// part
vnum1 = vnum2 = 0;
i++;
j++;
}
return 0;
}

View File

@ -1,6 +1,7 @@
#ifndef OTA_H
#define OTA_H
#include "globals.h"
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <Update.h>
@ -9,5 +10,6 @@
void checkFirmwareUpdates();
void processOTAUpdate(const String &version);
void start_ota_update();
int version_compare(const String v1, const String v2);
#endif // OTA_H

View File

@ -4,10 +4,6 @@
// The mother of all embedded development...
#include <Arduino.h>
// attn: increment version after modifications to configData_t truct!
#define PROGVERSION "1.4.30" // use max 10 chars here!
#define PROGNAME "PAXCNT"
// std::set for unified array functions
#include <set>
#include <array>

View File

@ -1,69 +0,0 @@
/* Hardware related definitions for TTGO V2.1 Board
/ ATTENTION: check your board version!
/ Different versions are on the market which need different settings in this file:
/ - without label -> use settings (2)
/ - labeled V1.5 on pcb -> use settings (2)
/ - labeled V1.6 on pcb -> use settings (1)
/ Choose the right configuration below
*/
/*
// (1) settings for board labeled "T3_V1.6" on pcb
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
#define HAS_SPI 1 // comment out if device shall not send data via SPI
#define CFG_sx1276_radio 1 // HPD13A LoRa SoC
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
#define HAS_LED GPIO_NUM_25 // green on board LED
#define HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // uses GPIO7
#define BATT_FACTOR 2 // voltage divider 100k/100k on board
// re-define pin definitions of pins_arduino.h
#define PIN_SPI_SS GPIO_NUM_18 // ESP32 GPIO18 (Pin18) -- HPD13A NSS/SEL (Pin4) SPI Chip Select Input
#define PIN_SPI_MOSI GPIO_NUM_27 // ESP32 GPIO27 (Pin27) -- HPD13A MOSI/DSI (Pin6) SPI Data Input
#define PIN_SPI_MISO GPIO_NUM_19 // ESP32 GPIO19 (Pin19) -- HPD13A MISO/DSO (Pin7) SPI Data Output
#define PIN_SPI_SCK GPIO_NUM_5 // ESP32 GPIO5 (Pin5) -- HPD13A SCK (Pin5) SPI Clock Input
// non arduino pin definitions
#define RST GPIO_NUM_23 // ESP32 GPIO23 <-> HPD13A RESET
#define DIO0 GPIO_NUM_26 // ESP32 GPIO26 <-> HPD13A IO0
#define DIO1 GPIO_NUM_33 // ESP32 GPIO33 <-> HPDIO1 <-> HPD13A IO1
#define DIO2 GPIO_NUM_32 // ESP32 GPIO32 <-> HPDIO2 <-> HPD13A IO2
// Hardware pin definitions for TTGO V2 Board with OLED SSD1306 0,96" I2C Display
#define OLED_RST U8X8_PIN_NONE // connected to CPU RST/EN
#define OLED_SDA GPIO_NUM_21 // ESP32 GPIO21 -- SD1306 D1+D2
#define OLED_SCL GPIO_NUM_22 // ESP32 GPIO22 -- SD1306 D0
*/
// (2) settings for boards without label on pcb, or labeled v1.5 on pcb
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
#define HAS_SPI 1 // comment out if device shall not send data via SPI
#define CFG_sx1276_radio 1 // HPD13A LoRa SoC
#define HAS_LED NOT_A_PIN // no usable LED on board
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
#define DISPLAY_FLIP 1 // rotated display
#define HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // uses GPIO7
#define BATT_FACTOR 2 // voltage divider 100k/100k on board
// re-define pin definitions of pins_arduino.h
#define PIN_SPI_SS GPIO_NUM_18 // ESP32 GPIO18 (Pin18) -- HPD13A NSS/SEL (Pin4) SPI Chip Select Input
#define PIN_SPI_MOSI GPIO_NUM_27 // ESP32 GPIO27 (Pin27) -- HPD13A MOSI/DSI (Pin6) SPI Data Input
#define PIN_SPI_MISO GPIO_NUM_19 // ESP32 GPIO19 (Pin19) -- HPD13A MISO/DSO (Pin7) SPI Data Output
#define PIN_SPI_SCK GPIO_NUM_5 // ESP32 GPIO5 (Pin5) -- HPD13A SCK (Pin5) SPI Clock Input
// non arduino pin definitions
#define RST LMIC_UNUSED_PIN // connected to ESP32 RST/EN (old board)
//#define RST GPIO_NUM_12 // (boards labeled v1.5)
#define DIO0 GPIO_NUM_26 // ESP32 GPIO26 <-> HPD13A IO0
#define DIO1 GPIO_NUM_33 // ESP32 GPIO33 <-> HPDIO1 <-> HPD13A IO1
#define DIO2 GPIO_NUM_32 // ESP32 GPIO32 <-> HPDIO2 <-> HPD13A IO2
// Hardware pin definitions for TTGO V2 Board with OLED SSD1306 0,96" I2C Display
#define OLED_RST U8X8_PIN_NONE // connected to CPU RST/EN
#define OLED_SDA GPIO_NUM_21 // ESP32 GPIO21 -- SD1306 D1+D2
#define OLED_SCL GPIO_NUM_22 // ESP32 GPIO22 -- SD1306 D0

30
src/hal/ttgov21new.h Normal file
View File

@ -0,0 +1,30 @@
/* Hardware related definitions for TTGO V2.1 Board
// ATTENTION: check your board version!
// This settings are for boards labeled v1.6 on pcb, NOT for v1.5 or older
*/
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
#define HAS_SPI 1 // comment out if device shall not send data via SPI
#define CFG_sx1276_radio 1 // HPD13A LoRa SoC
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
#define HAS_LED GPIO_NUM_25 // green on board LED
#define HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // uses GPIO7
#define BATT_FACTOR 2 // voltage divider 100k/100k on board
// re-define pin definitions of pins_arduino.h
#define PIN_SPI_SS GPIO_NUM_18 // ESP32 GPIO18 (Pin18) -- HPD13A NSS/SEL (Pin4) SPI Chip Select Input
#define PIN_SPI_MOSI GPIO_NUM_27 // ESP32 GPIO27 (Pin27) -- HPD13A MOSI/DSI (Pin6) SPI Data Input
#define PIN_SPI_MISO GPIO_NUM_19 // ESP32 GPIO19 (Pin19) -- HPD13A MISO/DSO (Pin7) SPI Data Output
#define PIN_SPI_SCK GPIO_NUM_5 // ESP32 GPIO5 (Pin5) -- HPD13A SCK (Pin5) SPI Clock Input
// non arduino pin definitions
#define RST GPIO_NUM_23 // ESP32 GPIO23 <-> HPD13A RESET
#define DIO0 GPIO_NUM_26 // ESP32 GPIO26 <-> HPD13A IO0
#define DIO1 GPIO_NUM_33 // ESP32 GPIO33 <-> HPDIO1 <-> HPD13A IO1
#define DIO2 GPIO_NUM_32 // ESP32 GPIO32 <-> HPDIO2 <-> HPD13A IO2
// Hardware pin definitions for TTGO V2 Board with OLED SSD1306 0,96" I2C Display
#define OLED_RST U8X8_PIN_NONE // connected to CPU RST/EN
#define OLED_SDA GPIO_NUM_21 // ESP32 GPIO21 -- SD1306 D1+D2
#define OLED_SCL GPIO_NUM_22 // ESP32 GPIO22 -- SD1306 D0

32
src/hal/ttgov21old.h Normal file
View File

@ -0,0 +1,32 @@
/* Hardware related definitions for TTGO V2.1 Board
// ATTENTION: check your board version!
// This settings are for boards without label on pcb, or labeled v1.5 on pcb
*/
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
#define HAS_SPI 1 // comment out if device shall not send data via SPI
#define CFG_sx1276_radio 1 // HPD13A LoRa SoC
#define HAS_LED NOT_A_PIN // no usable LED on board
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
#define DISPLAY_FLIP 1 // rotated display
#define HAS_BATTERY_PROBE ADC1_GPIO35_CHANNEL // uses GPIO7
#define BATT_FACTOR 2 // voltage divider 100k/100k on board
// re-define pin definitions of pins_arduino.h
#define PIN_SPI_SS GPIO_NUM_18 // ESP32 GPIO18 (Pin18) -- HPD13A NSS/SEL (Pin4) SPI Chip Select Input
#define PIN_SPI_MOSI GPIO_NUM_27 // ESP32 GPIO27 (Pin27) -- HPD13A MOSI/DSI (Pin6) SPI Data Input
#define PIN_SPI_MISO GPIO_NUM_19 // ESP32 GPIO19 (Pin19) -- HPD13A MISO/DSO (Pin7) SPI Data Output
#define PIN_SPI_SCK GPIO_NUM_5 // ESP32 GPIO5 (Pin5) -- HPD13A SCK (Pin5) SPI Clock Input
// non arduino pin definitions
#define RST LMIC_UNUSED_PIN // connected to ESP32 RST/EN (old board)
//#define RST GPIO_NUM_12 // (boards labeled v1.5)
#define DIO0 GPIO_NUM_26 // ESP32 GPIO26 <-> HPD13A IO0
#define DIO1 GPIO_NUM_33 // ESP32 GPIO33 <-> HPDIO1 <-> HPD13A IO1
#define DIO2 GPIO_NUM_32 // ESP32 GPIO32 <-> HPDIO2 <-> HPD13A IO2
// Hardware pin definitions for TTGO V2 Board with OLED SSD1306 0,96" I2C Display
#define OLED_RST U8X8_PIN_NONE // connected to CPU RST/EN
#define OLED_SDA GPIO_NUM_21 // ESP32 GPIO21 -- SD1306 D1+D2
#define OLED_SCL GPIO_NUM_22 // ESP32 GPIO22 -- SD1306 D0

View File

@ -90,7 +90,7 @@ void setup() {
esp_log_set_vprintf(redirect_log);
#endif
ESP_LOGI(TAG, "Starting %s v%s", PROGNAME, PROGVERSION);
ESP_LOGI(TAG, "Starting %s v%s", PRODUCTNAME, PROGVERSION);
// initialize system event handler for wifi task, needed for
// wifi_sniffer_init()
@ -213,7 +213,7 @@ void setup() {
#ifdef HAS_DISPLAY
strcat_P(features, " OLED");
DisplayState = cfg.screenon;
init_display(PROGNAME, PROGVERSION);
init_display(PRODUCTNAME, PROGVERSION);
// setup display refresh trigger IRQ using esp32 hardware timer
// https://techtutorialsx.com/2017/10/07/esp32-arduino-timer-interrupts/

View File

@ -4,6 +4,8 @@
//
// Note: After editing, before "build", use "clean" button in PlatformIO!
#define PRODUCTNAME "PAXCNT"
// Verbose enables serial output
#define VERBOSE 1 // comment out to silence the device, for mute use build option

View File

@ -52,8 +52,8 @@ void PayloadConvert::addConfig(configData_t value) {
cursor += 10;
}
void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime,
float cputemp, uint32_t mem) {
void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float cputemp,
uint32_t mem, uint8_t reset1, uint8_t reset2) {
buffer[cursor++] = highByte(voltage);
buffer[cursor++] = lowByte(voltage);
@ -124,6 +124,7 @@ void PayloadConvert::addConfig(configData_t value) {
value.screenon ? true : false, value.countermode ? true : false,
value.blescan ? true : false, value.wifiant ? true : false,
value.vendorfilter ? true : false, value.gpsmode ? true : false);
writeVersion(value.version);
}
void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float cputemp,
@ -160,6 +161,11 @@ void PayloadConvert::writeUptime(uint64_t uptime) {
intToBytes(cursor, uptime, 8);
}
void PayloadConvert::writeVersion(char * version) {
memcpy(buffer + cursor, version, 10);
cursor += 10;
}
void PayloadConvert::writeLatLng(double latitude, double longitude) {
intToBytes(cursor, latitude, 4);
intToBytes(cursor, longitude, 4);

View File

@ -64,6 +64,7 @@ private:
void writeUint8(uint8_t i);
void writeHumidity(float humidity);
void writeTemperature(float temperature);
void writeVersion(char * version);
void writeBitmap(bool a, bool b, bool c, bool d, bool e, bool f, bool g,
bool h);