Compare commits

...

12 Commits

Author SHA1 Message Date
Siwat Sirichai 59d0c470b1 Update Jenkinsfile 2023-12-07 16:45:56 +07:00
Siwat Sirichai 24871d2316 Update platformio.ini 2023-12-07 16:09:42 +07:00
Siwat Sirichai bc85bcf601 Update Jenkinsfile 2023-12-07 16:02:28 +07:00
Siwat Sirichai 1988bc953e Update gen_release.py 2023-12-07 15:52:14 +07:00
Siwat Sirichai 5f5176969f Update Jenkinsfile 2023-12-07 15:47:42 +07:00
Siwat Sirichai 816d31ad5f Update Jenkinsfile 2023-12-07 15:46:36 +07:00
Siwat Sirichai 2b728b55c5 Update Jenkinsfile 2023-12-07 15:45:02 +07:00
Siwat Sirichai 8ca7c5407d ci integration 2023-12-07 15:43:11 +07:00
Siwat Sirichai ed85d07148 Update gen_release.py 2023-12-07 14:59:39 +07:00
Siwat Sirichai c8ff21f522 finalize builder 2023-12-07 14:59:24 +07:00
Siwat Sirichai fc04b190a4 Update gen_release.py 2023-12-05 19:46:48 +07:00
Siwat Sirichai 921a5f1cc4 automated builds 2023-12-04 23:03:52 +07:00
7 changed files with 299 additions and 10 deletions

4
.gitignore vendored
View File

@ -5,4 +5,6 @@
.vscode/ipch .vscode/ipch
.vs/ .vs/
.vscode/ .vscode/
.vscode/settings.json .vscode/settings.json
firmware/
release/

View File

@ -73,5 +73,6 @@
"C_Cpp_Runner.useLeakSanitizer": false, "C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false, "C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": 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"
} }

20
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,20 @@
pipeline {
agent any
stages {
stage('Build') {
steps {
git branch: 'modbus', 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 {
unstash 'release_binaries'
archiveArtifacts artifacts: 'release/**/*', fingerprint: true
}
}
}
}

111
gen_release.py Normal file
View File

@ -0,0 +1,111 @@
import os
import shutil
import subprocess
import sys
import subprocess
import os
import shutil
import subprocess
import sys
import platform
import re
import configparser
from time import sleep as delay
# 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')
# 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')
# 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
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()
commit_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode().strip()[:10]
# If arguments are supplied, build the environments that match the arguments
if len(sys.argv) > 1:
environments = sys.argv[1:]
# 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)
# 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:
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}', 'run','-c',f'{firmware_folder}/platformio.ini'], cwd=current_dir)
for environment in environments:
if(len(sys.argv) > 1):
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):
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 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)

View File

@ -8,7 +8,153 @@
; Please visit documentation for the other options and examples ; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html ; 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 platform = espressif32
board = wt32-eth01 board = wt32-eth01
framework = arduino framework = arduino
@ -22,5 +168,4 @@ lib_deps = siwats/ESPMegaPROR3@^1.3.0
robtillaart/DHTNEW@^0.4.18 robtillaart/DHTNEW@^0.4.18
seithan/Easy Nextion Library@^1.0.6 seithan/Easy Nextion Library@^1.0.6
robtillaart/FRAM_I2C@^0.6.1 robtillaart/FRAM_I2C@^0.6.1
esphome/ESPAsyncWebServer-esphome@^3.1.0 esphome/ESPAsyncWebServer-esphome@^3.1.0
monitor_speed = 115200

View File

@ -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+"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+"MAC Address"+ota_part2_2+ETH.macAddress()+ota_part2_3;
otabuffer+=ota_part2_1+"Device"+ota_part2_2+ESPMEGA_REV+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 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+"BMS Endpoint"+ota_part2_2+String(MQTT_BASE_TOPIC)+ota_part2_3;
otabuffer+=ota_part2_1+"Centrally Managed"+ota_part2_2; otabuffer+=ota_part2_1+"Centrally Managed"+ota_part2_2;
@ -1837,6 +1842,7 @@ void set_mqtt_useauth(bool use_auth)
ESPMega_FRAM.write8(FRAM_ADDRESS_MQTT_USEAUTH, MQTT_USE_AUTH); ESPMega_FRAM.write8(FRAM_ADDRESS_MQTT_USEAUTH, MQTT_USE_AUTH);
} }
#ifdef ENABLE_WEBUI
void set_webui_username(String username) void set_webui_username(String username)
{ {
username.toCharArray(WEBUI_USERNAME, 32); username.toCharArray(WEBUI_USERNAME, 32);
@ -1848,6 +1854,7 @@ void set_webui_password(String password)
password.toCharArray(WEBUI_PASSWORD, 32); password.toCharArray(WEBUI_PASSWORD, 32);
ESPMega_FRAM.write(FRAM_ADDRESS_WEBUI_PASSWORD, (uint8_t *)WEBUI_PASSWORD, 32); ESPMega_FRAM.write(FRAM_ADDRESS_WEBUI_PASSWORD, (uint8_t *)WEBUI_PASSWORD, 32);
} }
#endif
/** /**
* @brief Resets the device to factory default settings. * @brief Resets the device to factory default settings.
@ -1884,8 +1891,10 @@ void factory_reset()
set_ip("192.168.0.10"); set_ip("192.168.0.10");
set_gw("192.168.0.1"); set_gw("192.168.0.1");
set_netmask("255.255.255.0"); set_netmask("255.255.255.0");
#ifdef ENABLE_WEBUI
set_webui_username("admin"); set_webui_username("admin");
set_webui_password("admin"); set_webui_password("admin");
#endif
// Reboot // Reboot
#ifdef ENABLE_INTERNAL_LCD #ifdef ENABLE_INTERNAL_LCD

View File

@ -16,11 +16,12 @@
#define VIRTUAL_INTERRUPT_PRELOAD // Preload Virtual Interrupts buffer #define VIRTUAL_INTERRUPT_PRELOAD // Preload Virtual Interrupts buffer
// Enable Software Module(s) // Enable Software Module(s)
#define ENABLE_INTERNAL_LCD // Deprecated. Use Build Flags instead.
#define ENABLE_IR_MODULE // #define ENABLE_INTERNAL_LCD
#define ENABLE_CLIMATE_MODULE // Require IR Module // #define ENABLE_IR_MODULE
#define ENABLE_ANALOG_MODULE // #define ENABLE_CLIMATE_MODULE // Require IR Module
#define ENABLE_WEBUI // #define ENABLE_ANALOG_MODULE
// #define ENABLE_WEBUI
// IR Kit Configuration // IR Kit Configuration
#define IR_RECIEVE_PIN 35 #define IR_RECIEVE_PIN 35