From e59c00b46e370ab4c46c614e52b5f1a68c683a42 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Sun, 3 Dec 2023 23:27:42 +0700 Subject: [PATCH 01/16] initial structure --- src/espmega_iot_homeassistant.cpp | 24 ++++++++++++++++++++++++ src/espmega_iot_homeassistant.hpp | 22 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/espmega_iot_homeassistant.cpp b/src/espmega_iot_homeassistant.cpp index e69de29..fe534ed 100644 --- a/src/espmega_iot_homeassistant.cpp +++ b/src/espmega_iot_homeassistant.cpp @@ -0,0 +1,24 @@ +#include +void homeassistant_setup() { + +} +void homeassistant_loop() { + +} +void homeassistant_mqtt_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length) { + +} + +char* homeassistant_get_state(char* entity_id) { + +} +void homeassistant_set_state(char* entity_id, char* state) { + +} + +char* homeassistant_get_attributes(char* entity_id, char* attribute_name) { + +} +void homeassistant_set_attributes(char* entity_id, char* attribute_name, char* value) { + +} \ No newline at end of file diff --git a/src/espmega_iot_homeassistant.hpp b/src/espmega_iot_homeassistant.hpp index e69de29..8eb0511 100644 --- a/src/espmega_iot_homeassistant.hpp +++ b/src/espmega_iot_homeassistant.hpp @@ -0,0 +1,22 @@ +#pragma once +#include + +extern PubSubClient mqtt; +extern bool standalone; +extern char MQTT_BASE_TOPIC[]; + +void homeassistant_setup(); +void homeassistant_loop(); + +void homeassistant_mqtt_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length); + +char* homeassistant_get_state(char* entity_id); +void homeassistant_set_state(char* entity_id, char* state); + +char* homeassistant_get_attributes(char* entity_id, char* attribute_name); +void homeassistant_set_attributes(char* entity_id, char* attribute_name, char* value); + +struct homeassistant_entity { + char* entity_id; + char* mqtt_topic; +}; \ No newline at end of file From 921a5f1cc45fd2109cd5433e4d82642d16e63413 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Mon, 4 Dec 2023 23:03:52 +0700 Subject: [PATCH 02/16] automated builds --- .gitignore | 4 +- .vscode/settings.json | 3 +- gen_release.py | 66 +++++++++++++++++ platformio.ini | 151 ++++++++++++++++++++++++++++++++++++++- src/espmega_iot_core.cpp | 4 ++ src/user_code.hpp | 11 +-- 6 files changed, 229 insertions(+), 10 deletions(-) create mode 100644 gen_release.py diff --git a/.gitignore b/.gitignore index 5c228a4..a4a37ad 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ .vscode/ipch .vs/ .vscode/ -.vscode/settings.json \ No newline at end of file +.vscode/settings.json +firmware/ +release/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 2975662..ee32b37 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -73,5 +73,6 @@ "C_Cpp_Runner.useLeakSanitizer": false, "C_Cpp_Runner.showCompilationTime": false, "C_Cpp_Runner.useLinkTimeOptimization": false, - "C_Cpp_Runner.msvcSecureNoWarnings": false + "C_Cpp_Runner.msvcSecureNoWarnings": false, + "cmake.sourceDirectory": "D:/Git/iot-firmware/.pio/libdeps/full/Adafruit BusIO" } \ No newline at end of file diff --git a/gen_release.py b/gen_release.py new file mode 100644 index 0000000..ed453a7 --- /dev/null +++ b/gen_release.py @@ -0,0 +1,66 @@ +import os +import shutil +import subprocess +import sys +import platform +import subprocess +import os +import shutil +import subprocess +import sys +import platform + + +# Get the current directory +current_dir = os.path.dirname(os.path.abspath(__file__)) + +# Define the path to the firmware folder +firmware_folder = os.path.join(current_dir, 'firmware') + +# Define the path to the release folder +release_folder = os.path.join(current_dir, 'release') + +# Add the path to the PlatformIO executable to the system PATH +platformio_path = os.path.expanduser('~/.platformio/penv/Scripts') + +if os.path.exists(release_folder): + # If the release folder exists, delete it + shutil.rmtree(release_folder) +os.makedirs(release_folder) + +# Get the current Git branch name +git_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode().strip() + +# Build the PlatformIO project +if len(sys.argv) > 1: + # If arguments are supplied, build the environments that match the arguments + environments = sys.argv[1:] + for environment in environments: + subprocess.run([f'{platformio_path}/platformio.exe', 'run', '-e', environment], cwd=current_dir) + + # Iterate over the subfolders in the firmware folder + for subfolder in os.listdir(firmware_folder): + subfolder_path = os.path.join(firmware_folder, subfolder) + + # Check if the subfolder matches the environment argument + if subfolder == environment: + # Check if the subfolder contains a firmware.bin file + firmware_file = os.path.join(subfolder_path, 'firmware.bin') + if os.path.isfile(firmware_file): + # Move the firmware.bin file to the release folder with the Git branch name appended + new_file_name = os.path.join(release_folder, f"{subfolder}_{git_branch}.bin") + shutil.move(firmware_file, new_file_name) +else: + # If no argument is supplied, build all environments + subprocess.run([f'{platformio_path}/platformio.exe', 'run'], cwd=current_dir) + + # Iterate over the subfolders in the firmware folder + for subfolder in os.listdir(firmware_folder): + subfolder_path = os.path.join(firmware_folder, subfolder) + + # Check if the subfolder contains a firmware.bin file + firmware_file = os.path.join(subfolder_path, 'firmware.bin') + if os.path.isfile(firmware_file): + # Move the firmware.bin file to the release folder with the Git branch name appended + new_file_name = os.path.join(release_folder, f"{subfolder}_{git_branch}.bin") + shutil.move(firmware_file, new_file_name) diff --git a/platformio.ini b/platformio.ini index 1995297..b32f365 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,7 +8,153 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html -[env:wt32-eth01] +[platformio] +build_dir = .\firmware + +[env:full] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_INTERNAL_LCD -DENABLE_IR_MODULE -DENABLE_CLIMATE_MODULE -DENABLE_ANALOG_MODULE -DENABLE_WEBUI +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 +monitor_speed = 115200 + +[env:lcd_climate] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_INTERNAL_LCD -DENABLE_IR_MODULE -DENABLE_CLIMATE_MODULE +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 +monitor_speed = 115200 + +[env:webui] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_WEBUI +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 + +[env:climate_webui] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_IR_MODULE -DENABLE_CLIMATE_MODULE -DENABLE_WEBUI +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 +monitor_speed = 115200 + +[env:lcd_webui] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_INTERNAL_LCD -DENABLE_WEBUI +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 +monitor_speed = 115200 + +[env:ir_climate_analog_webui] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_IR_MODULE -DENABLE_CLIMATE_MODULE -DENABLE_ANALOG_MODULE -DENABLE_WEBUI +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 +monitor_speed = 115200 + +[env:lcd_analog] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_INTERNAL_LCD -DENABLE_ANALOG_MODULE +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 +monitor_speed = 115200 + +[env:lcd] +platform = espressif32 +board = wt32-eth01 +framework = arduino +board_build.f_cpu = 240000000L +build_flags = -DENABLE_INTERNAL_LCD +lib_deps = siwats/ESPMegaPROR3@^1.3.0 + knolleary/PubSubClient@^2.8 + ivanseidel/ArduinoThread@^2.1.1 + arduino-libraries/Arduino_BuiltIn@^1.0.0 + dersimn/PubSubClientTools@^0.6 + z3t0/IRremote@^4.2.0 + robtillaart/DHTNEW@^0.4.18 + seithan/Easy Nextion Library@^1.0.6 + robtillaart/FRAM_I2C@^0.6.1 + esphome/ESPAsyncWebServer-esphome@^3.1.0 +monitor_speed = 115200 + +[env:minimal] platform = espressif32 board = wt32-eth01 framework = arduino @@ -22,5 +168,4 @@ lib_deps = siwats/ESPMegaPROR3@^1.3.0 robtillaart/DHTNEW@^0.4.18 seithan/Easy Nextion Library@^1.0.6 robtillaart/FRAM_I2C@^0.6.1 - esphome/ESPAsyncWebServer-esphome@^3.1.0 -monitor_speed = 115200 \ No newline at end of file + esphome/ESPAsyncWebServer-esphome@^3.1.0 \ No newline at end of file diff --git a/src/espmega_iot_core.cpp b/src/espmega_iot_core.cpp index ddfcaf2..a20b559 100644 --- a/src/espmega_iot_core.cpp +++ b/src/espmega_iot_core.cpp @@ -1837,6 +1837,7 @@ void set_mqtt_useauth(bool use_auth) ESPMega_FRAM.write8(FRAM_ADDRESS_MQTT_USEAUTH, MQTT_USE_AUTH); } +#ifdef ENABLE_WEBUI void set_webui_username(String username) { username.toCharArray(WEBUI_USERNAME, 32); @@ -1848,6 +1849,7 @@ void set_webui_password(String password) password.toCharArray(WEBUI_PASSWORD, 32); ESPMega_FRAM.write(FRAM_ADDRESS_WEBUI_PASSWORD, (uint8_t *)WEBUI_PASSWORD, 32); } +#endif /** * @brief Resets the device to factory default settings. @@ -1884,8 +1886,10 @@ void factory_reset() set_ip("192.168.0.10"); set_gw("192.168.0.1"); set_netmask("255.255.255.0"); + #ifdef ENABLE_WEBUI set_webui_username("admin"); set_webui_password("admin"); + #endif // Reboot #ifdef ENABLE_INTERNAL_LCD diff --git a/src/user_code.hpp b/src/user_code.hpp index fba970a..938316e 100644 --- a/src/user_code.hpp +++ b/src/user_code.hpp @@ -16,11 +16,12 @@ #define VIRTUAL_INTERRUPT_PRELOAD // Preload Virtual Interrupts buffer // Enable Software Module(s) -#define ENABLE_INTERNAL_LCD -#define ENABLE_IR_MODULE -#define ENABLE_CLIMATE_MODULE // Require IR Module -#define ENABLE_ANALOG_MODULE -#define ENABLE_WEBUI +// Deprecated. Use Build Flags instead. +// #define ENABLE_INTERNAL_LCD +// #define ENABLE_IR_MODULE +// #define ENABLE_CLIMATE_MODULE // Require IR Module +// #define ENABLE_ANALOG_MODULE +// #define ENABLE_WEBUI // IR Kit Configuration #define IR_RECIEVE_PIN 35 From fc04b190a47b2777875577cacec44a4cbc7df3a0 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Tue, 5 Dec 2023 19:46:48 +0700 Subject: [PATCH 03/16] Update gen_release.py --- gen_release.py | 57 +++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/gen_release.py b/gen_release.py index ed453a7..a759918 100644 --- a/gen_release.py +++ b/gen_release.py @@ -9,6 +9,7 @@ import shutil import subprocess import sys import platform +import re # Get the current directory @@ -30,37 +31,41 @@ os.makedirs(release_folder) # Get the current Git branch name git_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode().strip() +commit_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode().strip()[:10] -# Build the PlatformIO project +# If arguments are supplied, build the environments that match the arguments if len(sys.argv) > 1: - # If arguments are supplied, build the environments that match the arguments environments = sys.argv[1:] - for environment in environments: - subprocess.run([f'{platformio_path}/platformio.exe', 'run', '-e', environment], cwd=current_dir) - - # Iterate over the subfolders in the firmware folder - for subfolder in os.listdir(firmware_folder): - subfolder_path = os.path.join(firmware_folder, subfolder) - - # Check if the subfolder matches the environment argument - if subfolder == environment: - # Check if the subfolder contains a firmware.bin file - firmware_file = os.path.join(subfolder_path, 'firmware.bin') - if os.path.isfile(firmware_file): - # Move the firmware.bin file to the release folder with the Git branch name appended - new_file_name = os.path.join(release_folder, f"{subfolder}_{git_branch}.bin") - shutil.move(firmware_file, new_file_name) -else: - # If no argument is supplied, build all environments - subprocess.run([f'{platformio_path}/platformio.exe', 'run'], cwd=current_dir) +# If no argument are supplied, build all environments listed in platformio.ini +else: + environments = [] + with open(os.path.join(current_dir, 'platformio.ini')) as f: + + # Iterate over the lines in platformio.ini + for line in f.readlines(): + + # Check if the line contains the string "env:" + if '[env:' in line: + + # Extract the environment using regular expressions + environment = re.search(r'\[env:(.*?)\]', line).group(1) + + # Add the environment to the list of environments + environments.append(environment) + +for environment in environments: + subprocess.run([f'{platformio_path}/platformio.exe', 'run', '-e', environment,f'-DFW_VERSION={git_branch}_{environment}_{commit_hash}'], cwd=current_dir) + # Iterate over the subfolders in the firmware folder for subfolder in os.listdir(firmware_folder): subfolder_path = os.path.join(firmware_folder, subfolder) - # Check if the subfolder contains a firmware.bin file - firmware_file = os.path.join(subfolder_path, 'firmware.bin') - if os.path.isfile(firmware_file): - # Move the firmware.bin file to the release folder with the Git branch name appended - new_file_name = os.path.join(release_folder, f"{subfolder}_{git_branch}.bin") - shutil.move(firmware_file, new_file_name) + # Check if the subfolder matches the environment argument + if subfolder == environment: + # Check if the subfolder contains a firmware.bin file + firmware_file = os.path.join(subfolder_path, 'firmware.bin') + if os.path.isfile(firmware_file): + # Move the firmware.bin file to the release folder with the Git branch name and commit hash appended + new_file_name = os.path.join(release_folder, f"{git_branch}_{subfolder}_{commit_hash}.bin") + shutil.move(firmware_file, new_file_name) \ No newline at end of file From c8ff21f522eb9260b8280b7bc060ca782c21d4dc Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 14:59:24 +0700 Subject: [PATCH 04/16] finalize builder --- gen_release.py | 31 ++++++++++++++++++++++++++++++- src/espmega_iot_core.cpp | 5 +++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/gen_release.py b/gen_release.py index a759918..34587da 100644 --- a/gen_release.py +++ b/gen_release.py @@ -10,6 +10,8 @@ import subprocess import sys import platform import re +import configparser +from time import sleep as delay # Get the current directory @@ -54,8 +56,35 @@ else: # Add the environment to the list of environments environments.append(environment) +# Remove old platformio.ini file from firmware folder if it exists +if os.path.isfile(os.path.join(firmware_folder, 'platformio.ini')): + os.remove(os.path.join(firmware_folder, 'platformio.ini')) + +# Copy the platformio.ini file to the firmware folder +shutil.copyfile(os.path.join(current_dir, 'platformio.ini'), os.path.join(firmware_folder, 'platformio.ini')) + +# Check that the file is copied correctly +if not os.path.isfile(os.path.join(firmware_folder, 'platformio.ini')): + raise Exception('platformio.ini file not copied correctly') + +# Read the platformio.ini file +config = configparser.ConfigParser() +config.read(os.path.join(firmware_folder, 'platformio.ini')) + +# Add firmware version to build_flags in platformio.ini for environment in environments: - subprocess.run([f'{platformio_path}/platformio.exe', 'run', '-e', environment,f'-DFW_VERSION={git_branch}_{environment}_{commit_hash}'], cwd=current_dir) + if 'build_flags' not in config[f'env:{environment}']: + config[f'env:{environment}']['build_flags'] = f'-DFW_VERSION=\\"{git_branch}_{environment}_{commit_hash}\\"' + else: + config[f'env:{environment}']['build_flags'] = config[f'env:{environment}']['build_flags'] + f' -DFW_VERSION=\\"{git_branch}_{environment}_{commit_hash}\\"' + +# if argument is not supplied, build all environments listed in platformio.ini +if len(sys.argv) == 1: + subprocess.run([f'{platformio_path}/platformio.exe', 'run','-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir) + +for environment in environments: + if(len(sys.argv) > 1): + subprocess.run([f'{platformio_path}/platformio.exe', 'run', '-e', environment,'-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir) # Iterate over the subfolders in the firmware folder for subfolder in os.listdir(firmware_folder): diff --git a/src/espmega_iot_core.cpp b/src/espmega_iot_core.cpp index a20b559..845de70 100644 --- a/src/espmega_iot_core.cpp +++ b/src/espmega_iot_core.cpp @@ -395,6 +395,11 @@ void ota_begin() otabuffer+=ota_part2_1+"IP Address"+ota_part2_2+IP.toString()+ota_part2_3; otabuffer+=ota_part2_1+"MAC Address"+ota_part2_2+ETH.macAddress()+ota_part2_3; otabuffer+=ota_part2_1+"Device"+ota_part2_2+ESPMEGA_REV+ota_part2_3; + #ifdef FW_VERSION + otabuffer+=ota_part2_1+"Firmware"+ota_part2_2+FW_VERSION+ota_part2_3; + #else + otabuffer+=ota_part2_1+"Firmware"+ota_part2_2+"Out of Tree"+ota_part2_3; + #endif otabuffer+=ota_part2_1+"BMS Server"+ota_part2_2+MQTT_SERVER.toString()+ota_part2_3; otabuffer+=ota_part2_1+"BMS Endpoint"+ota_part2_2+String(MQTT_BASE_TOPIC)+ota_part2_3; otabuffer+=ota_part2_1+"Centrally Managed"+ota_part2_2; From ed85d0714878fdea0c68d9e349e76e124b3440cd Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 14:59:39 +0700 Subject: [PATCH 05/16] Update gen_release.py --- gen_release.py | 1 - 1 file changed, 1 deletion(-) diff --git a/gen_release.py b/gen_release.py index 34587da..5e91300 100644 --- a/gen_release.py +++ b/gen_release.py @@ -2,7 +2,6 @@ import os import shutil import subprocess import sys -import platform import subprocess import os import shutil From 8ca7c5407de63531b92ee08a4c7b05384143b31c Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 15:43:11 +0700 Subject: [PATCH 06/16] ci integration --- Jenkinsfile | 19 +++++++++++++++++++ gen_release.py | 16 ++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..971e5f9 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,19 @@ +pipeline { + agent any + + stages { + stage('Build') { + steps { + sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio' + sh 'python gen_release.py' + } + } + stage('Publish') { + steps { + sh 'mkdir -p artifacts' + sh 'cp -r release/ artifacts/' + archiveArtifacts artifacts: 'artifacts/**/*', fingerprint: true + } + } + } +} diff --git a/gen_release.py b/gen_release.py index 5e91300..0791e79 100644 --- a/gen_release.py +++ b/gen_release.py @@ -22,8 +22,16 @@ firmware_folder = os.path.join(current_dir, 'firmware') # Define the path to the release folder release_folder = os.path.join(current_dir, 'release') -# Add the path to the PlatformIO executable to the system PATH -platformio_path = os.path.expanduser('~/.platformio/penv/Scripts') +# Get the platformio path from environment variable +platformio_path = os.environ.get('PLATFORMIO_PATH') +# If the environment variable is not set, use the default path +if platformio_path is None: + if platform.system() == 'Darwin': + platformio_path = os.path.expanduser('~/.platformio/penv/bin/platformio') + elif platform.system() == 'Windows': + platformio_path = os.path.expanduser('~/.platformio/penv/Scripts/platformio.exe') + elif platform.system() == 'Linux': + platformio_path = os.path.expanduser('~/.platformio/penv/bin/platformio') if os.path.exists(release_folder): # If the release folder exists, delete it @@ -79,11 +87,11 @@ for environment in environments: # if argument is not supplied, build all environments listed in platformio.ini if len(sys.argv) == 1: - subprocess.run([f'{platformio_path}/platformio.exe', 'run','-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir) + subprocess.run([f'{platformio_path}', 'run','-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir) for environment in environments: if(len(sys.argv) > 1): - subprocess.run([f'{platformio_path}/platformio.exe', 'run', '-e', environment,'-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir) + subprocess.run([f'{platformio_path}', 'run', '-e', environment,'-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir) # Iterate over the subfolders in the firmware folder for subfolder in os.listdir(firmware_folder): From 2b728b55c5023aaf4fcae0eb13a70e3e9eba4e79 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 15:45:02 +0700 Subject: [PATCH 07/16] Update Jenkinsfile --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 971e5f9..3c70497 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,6 +2,11 @@ pipeline { agent any stages { + stage('Clone') { + steps { + git branch: 'main', url: 'https://git.siwatsystem.com/ise-senior-iot/iot-firmware.git' + } + } stage('Build') { steps { sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio' From 816d31ad5f82307e99cc66e8407b1a0486b2c90b Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 15:46:36 +0700 Subject: [PATCH 08/16] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3c70497..54ce469 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { stage('Build') { steps { sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio' - sh 'python gen_release.py' + sh 'python3 gen_release.py' } } stage('Publish') { From 5f5176969f64b457bb3b4f1913bc76300310e743 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 15:47:42 +0700 Subject: [PATCH 09/16] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 54ce469..9ef0dd4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ pipeline { stage('Build') { steps { sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio' - sh 'python3 gen_release.py' + sh '/usr/bin/python3 gen_release.py' } } stage('Publish') { From 1988bc953e07c3df38a2e2494120640a27cb0b05 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 15:52:14 +0700 Subject: [PATCH 10/16] Update gen_release.py --- gen_release.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gen_release.py b/gen_release.py index 0791e79..24fa03b 100644 --- a/gen_release.py +++ b/gen_release.py @@ -19,6 +19,10 @@ current_dir = os.path.dirname(os.path.abspath(__file__)) # Define the path to the firmware folder firmware_folder = os.path.join(current_dir, 'firmware') +# Create the firmware folder if it does not exist +if not os.path.exists(firmware_folder): + os.makedirs(firmware_folder) + # Define the path to the release folder release_folder = os.path.join(current_dir, 'release') From bc85bcf6015312b83a0272ab9e215c1cf1baf540 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 16:02:28 +0700 Subject: [PATCH 11/16] Update Jenkinsfile --- Jenkinsfile | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9ef0dd4..dcf9353 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,22 +2,18 @@ pipeline { agent any stages { - stage('Clone') { - steps { - git branch: 'main', url: 'https://git.siwatsystem.com/ise-senior-iot/iot-firmware.git' - } - } stage('Build') { steps { + git branch: 'main', url: 'https://git.siwatsystem.com/ise-senior-iot/iot-firmware.git' sh 'export PLATFORMIO_PATH=/root/.platformio/penv/bin/platformio' sh '/usr/bin/python3 gen_release.py' + stash includes: 'release/**/*', name: 'release_binaries' } } stage('Publish') { steps { - sh 'mkdir -p artifacts' - sh 'cp -r release/ artifacts/' - archiveArtifacts artifacts: 'artifacts/**/*', fingerprint: true + unstash 'release_binaries' + archiveArtifacts artifacts: 'release/**/*', fingerprint: true } } } From 24871d2316e2dfa14874a12c00f9f16a6c675d7c Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 16:09:42 +0700 Subject: [PATCH 12/16] Update platformio.ini --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index b32f365..da29e98 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,7 +9,7 @@ ; https://docs.platformio.org/page/projectconf.html [platformio] -build_dir = .\firmware +build_dir = firmware [env:full] platform = espressif32 From 3736f531128da2aac734e29277f1206fd965e76e Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Fri, 8 Dec 2023 17:58:10 +0700 Subject: [PATCH 13/16] light show optimization --- src/espmega_iot_core.cpp | 99 ++++++++++++++++++++++++++-------------- src/espmega_iot_core.hpp | 5 +- 2 files changed, 68 insertions(+), 36 deletions(-) diff --git a/src/espmega_iot_core.cpp b/src/espmega_iot_core.cpp index 845de70..9146fb1 100644 --- a/src/espmega_iot_core.cpp +++ b/src/espmega_iot_core.cpp @@ -47,6 +47,7 @@ uint8_t utc_offset = 7; float current_room_temp = 0; float current_room_humid = 0; #endif +bool pwm_report_enable = true; // Inputs #define VINT_COUNT 16 @@ -69,6 +70,7 @@ const float pwm_linear_scaling_c[PWM_COUNT] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, const int PWM_CYCLE_VALUES[PWM_CYCLE_VALUES_COUNT] = {50, 125, 255}; char PWM_SET_STATE_TOPIC[70]; char PWM_SET_VALUE_TOPIC[70]; +char PWM_REPORT_ENABLE_TOPIC[70]; #ifdef ENABLE_INTERNAL_LCD // LCD @@ -249,18 +251,20 @@ void loop() */ void fram_retrieve_init() { - #ifdef ENABLE_WEBUI +#ifdef ENABLE_WEBUI ESPMega_FRAM.read(FRAM_ADDRESS_WEBUI_USERNAME, (uint8_t *)WEBUI_USERNAME, 32); ESPMega_FRAM.read(FRAM_ADDRESS_WEBUI_PASSWORD, (uint8_t *)WEBUI_PASSWORD, 32); - if(strlen(WEBUI_USERNAME)==0) { - strcpy(WEBUI_USERNAME,"admin"); + if (strlen(WEBUI_USERNAME) == 0) + { + strcpy(WEBUI_USERNAME, "admin"); ESPMega_FRAM.write(FRAM_ADDRESS_WEBUI_USERNAME, (uint8_t *)WEBUI_USERNAME, 32); } - if(strlen(WEBUI_PASSWORD)==0) { - strcpy(WEBUI_PASSWORD,"admin"); + if (strlen(WEBUI_PASSWORD) == 0) + { + strcpy(WEBUI_PASSWORD, "admin"); ESPMega_FRAM.write(FRAM_ADDRESS_WEBUI_PASSWORD, (uint8_t *)WEBUI_PASSWORD, 32); } - #endif +#endif // FRAM Data Retrival #ifdef ENABLE_CLIMATE_MODULE ac_mode = ESPMega_FRAM.read8(FRAM_ADDRESS_AC_MODE); @@ -320,6 +324,8 @@ void fram_retrieve_init() strcat(PWM_SET_STATE_TOPIC, "/pwm/00/set/state"); memcpy(PWM_SET_VALUE_TOPIC, MQTT_BASE_TOPIC, 20); strcat(PWM_SET_VALUE_TOPIC, "/pwm/00/set/value"); + memcpy(PWM_REPORT_ENABLE_TOPIC, MQTT_BASE_TOPIC, 20); + strcat(PWM_REPORT_ENABLE_TOPIC, "/pwm/report_enable"); #ifdef ENABLE_CLIMATE_MODULE memcpy(AC_SET_MODE_TOPIC, MQTT_BASE_TOPIC, 20); strcat(AC_SET_MODE_TOPIC, "/ac/set/mode"); @@ -395,11 +401,11 @@ void ota_begin() otabuffer+=ota_part2_1+"IP Address"+ota_part2_2+IP.toString()+ota_part2_3; otabuffer+=ota_part2_1+"MAC Address"+ota_part2_2+ETH.macAddress()+ota_part2_3; otabuffer+=ota_part2_1+"Device"+ota_part2_2+ESPMEGA_REV+ota_part2_3; - #ifdef FW_VERSION +#ifdef FW_VERSION otabuffer+=ota_part2_1+"Firmware"+ota_part2_2+FW_VERSION+ota_part2_3; - #else +#else otabuffer+=ota_part2_1+"Firmware"+ota_part2_2+"Out of Tree"+ota_part2_3; - #endif +#endif otabuffer+=ota_part2_1+"BMS Server"+ota_part2_2+MQTT_SERVER.toString()+ota_part2_3; otabuffer+=ota_part2_1+"BMS Endpoint"+ota_part2_2+String(MQTT_BASE_TOPIC)+ota_part2_3; otabuffer+=ota_part2_1+"Centrally Managed"+ota_part2_2; @@ -665,6 +671,7 @@ void mqtt_subscribe() mqtt.subscribe(PWM_SET_STATE_TOPIC); mqtt.subscribe(PWM_SET_VALUE_TOPIC); } + mqtt.subscribe(PWM_REPORT_ENABLE_TOPIC); #ifdef ENABLE_CLIMATE_MODULE mqtt.subscribe(AC_SET_FAN_TOPIC); mqtt.subscribe(AC_SET_TEMPERATURE_TOPIC); @@ -713,6 +720,10 @@ void mqtt_callback(char *topic, byte *payload, unsigned int length) { pwm_value_callback(topic_trim, topic_length, payload_nt, length); } + else if (!strcmp(topic_trim, "/pwm/report_enable")) + { + pwm_set_publish_callback(topic_trim, topic_length, payload_nt, length); + } #ifdef ENABLE_ANALOG_MODULE else if ((!strncmp(topic_trim, "/adc/", 5)) && !strncmp(topic_trim + 7, "/set/state", 10)) { @@ -730,13 +741,14 @@ void mqtt_callback(char *topic, byte *payload, unsigned int length) #ifdef ENABLE_IR_MODULE else if (!strcmp(topic_trim, "/ir/send")) { - const char* delimiter = ","; - char* token = strtok(const_cast(payload_nt), delimiter); - while (token != nullptr && ir_buffer_length < IR_RAW_BUFFER_LENGTH) { - ir_buffer[ir_buffer_length++] = atoi(token); - token = strtok(nullptr, delimiter); + const char *delimiter = ","; + char *token = strtok(const_cast(payload_nt), delimiter); + while (token != nullptr && ir_buffer_length < IR_RAW_BUFFER_LENGTH) + { + ir_buffer[ir_buffer_length++] = atoi(token); + token = strtok(nullptr, delimiter); } - IrSender.sendRaw(ir_buffer,ir_buffer_length ,NEC_KHZ); + IrSender.sendRaw(ir_buffer, ir_buffer_length, NEC_KHZ); } #endif else if (!strcmp(topic, STATE_REQUEST_TOPIC)) @@ -869,6 +881,7 @@ void publish_pwm_states() for (int i = 0; i < PWM_COUNT; i++) { publish_pwm_state(i); + publish_pwm_value(i); } } @@ -879,12 +892,11 @@ void publish_pwm_states() */ void publish_pwm_state(int id) { + if (!pwm_report_enable) + return; int state = pwm_states[id]; - int value = pwm_values[id]; PWM_STATE_TOPIC[base_topic_length + 4] = ((id - id % 10) / 10) + '0'; PWM_STATE_TOPIC[base_topic_length + 5] = (id % 10) + '0'; - PWM_VALUE_TOPIC[base_topic_length + 4] = ((id - id % 10) / 10) + '0'; - PWM_VALUE_TOPIC[base_topic_length + 5] = (id % 10) + '0'; if (state == 1) { mqtt.publish(PWM_STATE_TOPIC, "on"); @@ -893,6 +905,15 @@ void publish_pwm_state(int id) { mqtt.publish(PWM_STATE_TOPIC, "off"); } +} + +void publish_pwm_value(int id) +{ + if (!pwm_report_enable) + return; + int value = pwm_values[id]; + PWM_VALUE_TOPIC[base_topic_length + 4] = ((id - id % 10) / 10) + '0'; + PWM_VALUE_TOPIC[base_topic_length + 5] = (id % 10) + '0'; char temp[6]; itoa(value, temp, DEC); mqtt.publish(PWM_VALUE_TOPIC, temp); @@ -939,7 +960,7 @@ void pwm_set_value(int id, int value) else if (lcd_current_page == 5 && id == lcd_pwmAdj_id) panel.writeNum("pwm_value.val", pwm_values[lcd_pwmAdj_id]); #endif - publish_pwm_state(id); + publish_pwm_value(id); pwm_changed_user_callback(id); } @@ -1055,6 +1076,11 @@ void publish_input_state(int id, int state) mqtt.publish(INPUTS_TOPIC, state ? "1" : "0"); } +void pwm_set_publish_callback(char *topic, uint8_t topic_length, char *payload, unsigned int payload_length) +{ + pwm_report_enable = !strcmp(payload, "on"); +} + /** * @brief Callback function to request the current state of the device. * @@ -1065,6 +1091,7 @@ void state_request_callback() { publish_input_states(); publish_pwm_states(); + pwm_report_enable = true; #ifdef ENABLE_CLIMATE_MODULE publish_ac_state(); publish_env_state(); @@ -1891,10 +1918,10 @@ void factory_reset() set_ip("192.168.0.10"); set_gw("192.168.0.1"); set_netmask("255.255.255.0"); - #ifdef ENABLE_WEBUI +#ifdef ENABLE_WEBUI set_webui_username("admin"); set_webui_password("admin"); - #endif +#endif // Reboot #ifdef ENABLE_INTERNAL_LCD @@ -1948,7 +1975,7 @@ void disable_adc(int id) /** * Publishes the state of an ADC (Analog-to-Digital Converter) to the MQTT broker. - * + * * @param id The ID of the ADC. */ void publish_adc_state(int id) @@ -1960,7 +1987,7 @@ void publish_adc_state(int id) /** * @brief Publishes the ADC states. - * + * * This function iterates over the ADC channels and publishes the state of each channel. */ void publish_adc_states() @@ -2050,7 +2077,7 @@ void publish_adc_values() /** * Publishes the state of a DAC (Digital-to-Analog Converter) to the MQTT broker. - * + * * @param id The ID of the DAC. */ void publish_dac_state(int id) @@ -2062,7 +2089,7 @@ void publish_dac_state(int id) /** * Publishes the DAC value for a given ID. - * + * * @param id The ID of the DAC value to publish. */ void publish_dac_value(int id) @@ -2154,9 +2181,9 @@ void dac_set_state(int id, bool state) /** * @brief Publishes the states of all DACs. - * + * * This function iterates through all DACs and publishes their states. - * + * * @return void */ void publish_dac_states() @@ -2169,9 +2196,9 @@ void publish_dac_states() /** * @brief Publishes the DAC values. - * + * * This function iterates through all the DAC channels and publishes their values. - * + * * @return void */ void publish_dac_values() @@ -2226,7 +2253,7 @@ void dac_set_state_callback(char *topic, uint8_t topic_length, char *payload, un /** * @brief Get the ADC value for the specified ID. - * + * * @param id The ID of the ADC channel. * @return The ADC value. */ @@ -2236,7 +2263,7 @@ uint16_t adc_get_value(int id) } /** * @brief Get the state of the ADC with the specified ID. - * + * * @param id The ID of the ADC. * @return true if the ADC is enabled, false otherwise. */ @@ -2246,7 +2273,7 @@ bool adc_get_state(int id) } /** * @brief Get the value of a DAC channel. - * + * * @param id The ID of the DAC channel. * @return The value of the DAC channel. */ @@ -2256,7 +2283,7 @@ uint16_t dac_get_value(int id) } /** * @brief Get the state of the DAC with the specified ID. - * + * * @param id The ID of the DAC. * @return The state of the DAC. */ @@ -2267,8 +2294,10 @@ bool dac_get_state(int id) #endif -void virtual_interrupt_preload() { - for (int i = 0; i < 16; i++) { +void virtual_interrupt_preload() +{ + for (int i = 0; i < 16; i++) + { virtual_interupt_state[i] = ESPMega_digitalRead(virtual_interrupt_pins[i]); } } \ No newline at end of file diff --git a/src/espmega_iot_core.hpp b/src/espmega_iot_core.hpp index f7cd015..51777c3 100644 --- a/src/espmega_iot_core.hpp +++ b/src/espmega_iot_core.hpp @@ -61,6 +61,7 @@ void ota_begin(); void publish_pwm_states(); void publish_pwm_state(int id); +void publish_pwm_value(int id); void pwm_set_state(int id, int state); void pwm_set_value(int id, int value); void pwm_toggle(int id); @@ -157,4 +158,6 @@ void publish_adc_states(); uint16_t adc_get_value(int id); bool adc_get_state(int id); uint16_t dac_get_value(int id); -bool dac_get_state(int id); \ No newline at end of file +bool dac_get_state(int id); + +void pwm_set_publish_callback(char *topic, uint8_t topic_length, char *payload, unsigned int payload_length); \ No newline at end of file From c1f4f5c1cdb04a0a0344798cd8686c3f73087d88 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Fri, 8 Dec 2023 18:33:33 +0700 Subject: [PATCH 14/16] code space optimization --- src/espmega_iot_core.cpp | 12 +++++++----- src/espmega_iot_core.hpp | 10 +++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/espmega_iot_core.cpp b/src/espmega_iot_core.cpp index 9146fb1..0472888 100644 --- a/src/espmega_iot_core.cpp +++ b/src/espmega_iot_core.cpp @@ -704,7 +704,7 @@ void mqtt_subscribe() * @param payload The payload of the received message. * @param length The length of the payload. */ -void mqtt_callback(char *topic, byte *payload, unsigned int length) +IRAM_ATTR void mqtt_callback(char *topic, byte *payload, unsigned int length) { uint8_t topic_length = strlen(topic); char topic_trim[50]; @@ -796,7 +796,7 @@ void thread_initialization() * @param payload The message payload. * @param payload_length The length of the message payload. */ -void pwm_state_callback(char *topic, uint8_t topic_length, char *payload, unsigned int payload_length) +IRAM_ATTR void pwm_state_callback(char *topic, uint8_t topic_length, char *payload, unsigned int payload_length) { int a = topic[5] - '0'; int b = topic[6] - '0'; @@ -822,7 +822,7 @@ void pwm_state_callback(char *topic, uint8_t topic_length, char *payload, unsign * @param payload The message payload. * @param payload_length The length of the message payload. */ -void pwm_value_callback(char *topic, uint8_t topic_length, char *payload, unsigned int payload_length) +IRAM_ATTR void pwm_value_callback(char *topic, uint8_t topic_length, char *payload, unsigned int payload_length) { int a = topic[5] - '0'; int b = topic[6] - '0'; @@ -925,7 +925,7 @@ void publish_pwm_value(int id) * @param id The ID of the PWM pin. * @param state The new state of the PWM pin. */ -void pwm_set_state(int id, int state) +IRAM_ATTR void pwm_set_state(int id, int state) { if (state != pwm_states[id]) { @@ -949,7 +949,7 @@ void pwm_set_state(int id, int state) * @param id The id of the PWM pin. * @param value The value to set the PWM pin to. */ -void pwm_set_value(int id, int value) +IRAM_ATTR void pwm_set_value(int id, int value) { pwm_values[id] = value; int pwm_state = pwm_states[id]; @@ -1268,6 +1268,8 @@ void ac_set_state(int mode, int temperature, int fan_speed) */ void publish_env_state() { + if(!pwm_report_enable) + return; int errorCode = env_sensor.read(); yield(); switch (errorCode) diff --git a/src/espmega_iot_core.hpp b/src/espmega_iot_core.hpp index 51777c3..fb6afc7 100644 --- a/src/espmega_iot_core.hpp +++ b/src/espmega_iot_core.hpp @@ -43,7 +43,7 @@ #endif #include "espmega_iot_timer.hpp" -void mqtt_callback(char* topic, byte* payload, unsigned int length); +IRAM_ATTR void mqtt_callback(char* topic, byte* payload, unsigned int length); void virtual_interrupt_loop(); void virtual_interrupt_callback(int pin, int state); void virtual_interrupt_preload(); @@ -51,8 +51,8 @@ void network_begin(); void mqtt_connect(); void mqtt_subscribe(); void thread_initialization(); -void pwm_state_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length); -void pwm_value_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length); +IRAM_ATTR void pwm_state_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length); +IRAM_ATTR void pwm_value_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length); void state_request_callback(); void io_begin(); void ir_loop(); @@ -62,8 +62,8 @@ void ota_begin(); void publish_pwm_states(); void publish_pwm_state(int id); void publish_pwm_value(int id); -void pwm_set_state(int id, int state); -void pwm_set_value(int id, int value); +IRAM_ATTR void pwm_set_state(int id, int state); +IRAM_ATTR void pwm_set_value(int id, int value); void pwm_toggle(int id); void pwm_toggle(int id1, int id2); void pwm_cycle_value(int id); From 0a93b41845248a61cf2c52ef7de7b10779f3a950 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Mon, 11 Dec 2023 11:31:52 +0700 Subject: [PATCH 15/16] add version number --- gen_release.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gen_release.py b/gen_release.py index 24fa03b..2c07d5e 100644 --- a/gen_release.py +++ b/gen_release.py @@ -89,6 +89,10 @@ for environment in environments: else: config[f'env:{environment}']['build_flags'] = config[f'env:{environment}']['build_flags'] + f' -DFW_VERSION=\\"{git_branch}_{environment}_{commit_hash}\\"' +# Write the platformio.ini file +with open(os.path.join(firmware_folder, 'platformio.ini'), 'w') as configfile: + config.write(configfile) + # if argument is not supplied, build all environments listed in platformio.ini if len(sys.argv) == 1: subprocess.run([f'{platformio_path}', 'run','-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir) From 5c55023829bbab3c91aa694d771f3b8abc1b4799 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Tue, 26 Dec 2023 23:52:24 +0700 Subject: [PATCH 16/16] adjust default ir send pin so it does not overlapse with elcd --- src/user_code.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/user_code.hpp b/src/user_code.hpp index 938316e..8b3e361 100644 --- a/src/user_code.hpp +++ b/src/user_code.hpp @@ -25,7 +25,7 @@ // IR Kit Configuration #define IR_RECIEVE_PIN 35 -#define IR_SEND_PIN 17 +#define IR_SEND_PIN 5 #define MARK_EXCESS_MICROS 20 #define IR_RAW_BUFFER_LENGTH 750 #define AC_MAX_TEMPERATURE 30