From 59d0c470b11f9f81e3ebfe537862a0ee20f5a7e6 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Thu, 7 Dec 2023 16:45:56 +0700 Subject: [PATCH 1/4] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index dcf9353..1b77434 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { stages { stage('Build') { steps { - git branch: 'main', url: 'https://git.siwatsystem.com/ise-senior-iot/iot-firmware.git' + 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' From c1f4f5c1cdb04a0a0344798cd8686c3f73087d88 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Fri, 8 Dec 2023 18:33:33 +0700 Subject: [PATCH 2/4] 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 3/4] 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 4/4] 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