Ver código fonte

Merge branch 'master' of http://jiecheng2024.tpddns.cn:3000/liyuezong/SmartPDCode

chenyuanjie 1 ano atrás
pai
commit
2791d9adfc

+ 5 - 1
control/bootloader64k/boot/USER/main.c

@@ -605,7 +605,11 @@ int main(void)
 						break;
 					case UPGRADE_STATUS_FINISH:
 					{
-						UserJumpToApplication(start_addr);
+						
+						//jiaoyan and break
+						app1_checum = md5_check(meta_data.app1_rom_addr,meta_data.app1_size,meta_data.app1_md5);
+						if(app1_checum == 0)
+							UserJumpToApplication(start_addr);
 						
 						md_status = UPGRADE_STATUS_IDE;
 						meta_write_complete_flag = 0;   // 

+ 345 - 8
cust_data/changes.txt

@@ -1,10 +1,347 @@
-V0.0.2
+# V1.2.0 (2025-06-16 - 2025-06-26)
 
-New and improved:
-1. Add NTP time sync
-2. Add Changes log in firmware upgrade page
-3. Add power data manual export in web and auto export in smtp mail
+**New Features**
+-   Added SNMP interface for retrieving F407 power information.
 
-Fixes and enhancements:
-1. Increase the data quantity in power history query, upper limit 7 days
-2. Fix the not working bug in Overall Status History/Device History/Power Chart
+**Bug Fixes**
+-   Fixed GPIO conflict for dry contact sensors on the LCD screen.
+-   Resolved issue with batch threshold setting failure.
+-   Fixed SNMP GETNEXT command errors.
+
+**Optimizations**
+-   Optimized three-phase engineering configuration parameters.
+-   Streamlined firmware by removing unused functional modules.
+
+------------------------------------------------------------------------------
+
+# V1.1.9 (2025-06-01 - 2025-06-15)
+
+**New Features**
+-   Added support for displaying CO₂ sensor data.
+-   Added Bootloader secure jump verification for 4-channel boards.
+
+**Bug Fixes**
+-   Fixed sensor disconnection issue caused by rapid plugging/unplugging.
+-   Resolved MQTT device number type error.
+
+**Optimizations**
+-   Optimized alarm interface interaction logic.
+-   Reduced Websocket push data volume.
+
+------------------------------------------------------------------------------
+
+# V1.1.8 (2025-05-16 - 2025-05-31)
+
+**New Features**
+-   Added batch threshold setting function for F407 sensors.
+-   Supports hot-switching between three-phase/single-phase operating modes.
+
+**Bug Fixes**
+-   Fixed GPIO conflict during RGB meter head initialization.
+-   Resolved SNMP sensor list retrieval exception.
+
+**Optimizations**
+-   Optimized QT startup page loading speed.
+-   Added Bootloader upgrade file verification mechanism.
+
+------------------------------------------------------------------------------
+
+# V1.1.7 (2025-05-01 - 2025-05-15)
+
+**New Features**
+-   Supports dry contact alarms for multiple sensors.
+-   Added channel timed Websocket push function.
+
+**Bug Fixes**
+-   Fixed LCD data display conflict for multiple sensors.
+-   Solved crash issue caused by MQTT connection failure.
+
+**Optimizations**
+-   Optimized 4G activation configuration, reducing CPU usage.
+-   Shortened sensor offline determination time (3 timeouts).
+
+------------------------------------------------------------------------------
+
+# V1.1.6 (2025-04-16 - 2025-04-30)
+
+**New Features**
+-   Supports circuit breaker status detection.
+-   Added support for 4-channel / 1-channel self-locking control boards.
+
+**Bug Fixes**
+-   Fixed three-phase phase loss detection anomaly.
+-   Resolved NTP synchronization failure for IP meter heads.
+
+**Optimizations**
+-   Optimized Modbus TCP communication timeout handling.
+-   Reduced memory usage for historical record storage.
+
+------------------------------------------------------------------------------
+
+# V1.1.5 (2025-04-01 - 2025-04-15)
+
+**New Features**
+-   Supports 125A engineering configuration.
+-   Added dual live wire version for three-phase input to single-phase output.
+
+**Bug Fixes**
+-   Fixed Web threshold upper limit (max 999999).
+-   Solved QT interface misalignment issue for three-phase data display.
+
+**Optimizations**
+-   Optimized dual live wire power factor calculation algorithm.
+-   Simplified product file reading logic.
+
+------------------------------------------------------------------------------
+
+# V1.1.4 (2025-03-16 - 2025-03-31)
+
+**New Features**
+-   Supports reverse control for magnetic latching relays.
+-   Added hardware support for 7-channel / 3-channel boards.
+
+**Bug Fixes**
+-   Fixed dual live wire threshold enable anomaly.
+-   Resolved STS control logic conflict.
+
+**Optimizations**
+-   Unified parameter configuration for DC control boards.
+-   Optimized stability of cascaded data reading.
+
+------------------------------------------------------------------------------
+
+# V1.1.3 (2025-03-01 - 2025-03-15)
+
+**New Features**
+-   Supports SNMP power threshold management.
+
+**Bug Fixes**
+-   Fixed crash issue on legacy three-phase control boards.
+-   Resolved IP meter head database access conflict.
+
+**Optimizations**
+-   Optimized synchronization between channel control and web data.
+-   Reduced EEPROM write frequency on DC control boards.
+
+------------------------------------------------------------------------------
+
+# V1.1.2 (2025-02-16 - 2025-02-28)
+
+**New Features**
+-   Supports App-side version number upload.
+-   Added dual-stack (IPv4/IPv6) detection for 4G networks.
+
+**Bug Fixes**
+-   Fixed Bootloader verification failure issue for new 5-channel/4-channel boards.
+
+**Optimizations**
+-   Optimized QT interface layout, unified sensor unit display.
+-   Compressed F407 basic data structure (256 → 92 bytes).
+
+------------------------------------------------------------------------------
+
+# V1.1.1 (2025-02-01 - 2025-02-15)
+
+**New Features**
+-   Added web configuration items for 4G-related functions.
+-   Added dual live wire single-phase control matching logic.
+
+**Bug Fixes**
+-   Fixed WiFi SNMP protocol unavailability.
+-   Solved stack overflow issue caused by frequent three-phase data reading.
+
+**Optimizations**
+-   Optimized Websocket push cycle (0.5 seconds/push).
+-   Added display support for CO₂ sensors.
+
+------------------------------------------------------------------------------
+
+# V1.1.0 (2025-01-16 - 2025-01-31)
+
+**New Features**
+-   Supports STS (Static Transfer Switch) temperature monitoring.
+-   Added magnetic latching relay control logic.
+
+**Bug Fixes**
+-   Fixed upgrade function anomaly on single-phase control boards.
+-   Resolved STS Modbus communication out-of-bounds issue.
+
+**Optimizations**
+-   Optimized Bootloader jump verification process.
+-   Reduced stack memory usage on three-phase control boards.
+
+------------------------------------------------------------------------------
+
+# V1.0.9 (2025-01-01 - 2025-01-15)
+
+**New Features**
+-   Added network reset function (hold Up/Down keys to restore default configuration).
+
+**Bug Fixes**
+-   Fixed dual live wire project configuration error.
+-   Resolved QT interface sensor unit display anomaly.
+
+**Optimizations**
+-   Optimized MQTT data structure (power status upload).
+-   Streamlined firmware size by removing redundant modules.
+
+------------------------------------------------------------------------------
+
+# V1.0.8 (2024-12-16 - 2024-12-31)
+
+**New Features**
+-   Supports channel "Monitor Only" mode.
+-   Added 4G SMS alarm push function.
+
+**Bug Fixes**
+-   Fixed GPIO conflict between RGB meter head and LCD screen.
+-   Resolved INI configuration deadlock issue.
+
+**Optimizations**
+-   Optimized 4G network detection mechanism.
+-   Shortened sensor serial port read timeout to improve response speed.
+
+------------------------------------------------------------------------------
+
+# V1.0.7 (2024-12-01 - 2024-12-15)
+
+**New Features**
+-   Supports three-phase total detection function.
+-   Added dynamic DHCP allocation for Modbus TCP addresses.
+
+**Bug Fixes**
+-   Fixed leak sensor display error on military 8-inch screen.
+-   Solved QT interface rotation direction anomaly.
+
+**Optimizations**
+-   Optimized communication efficiency between QT and PDU message queues.
+
+------------------------------------------------------------------------------
+
+# V1.0.6 (2024-11-16 - 2024-11-30)
+
+**New Features**
+-   Added circuit breaker trip alarm function.
+-   Supports control board firmware upgrade via web interface (includes QR code generation).
+
+**Bug Fixes**
+-   Fixed threshold import exception.
+-   Resolved sensor data garbled text issue on IP meter heads.
+
+**Optimizations**
+-   Optimized packaging scripts for new hardware compatibility.
+-   Refactored Web interface layout, fixed display misalignment.
+
+------------------------------------------------------------------------------
+
+# V1.0.5 (2024-11-01 - 2024-11-15)
+
+**New Features**
+-   Added configuration file import/export interfaces.
+-   Supports configuring meter face maximum values for voltage/current/power.
+
+**Bug Fixes**
+-   Fixed memory leak in three-phase input to single-phase output configuration.
+-   Resolved NTP synchronization failure.
+
+**Optimizations**
+-   Removed database dependency on `product_id` to avoid configuration change anomalies.
+-   Added slave temperature sensor data display to IP meter heads.
+
+------------------------------------------------------------------------------
+
+# V1.0.4 (2024-10-16 - 2024-10-31)
+
+**New Features**
+-   Supports SNMP TRAP function (sensor/power overload alarms).
+-   Added Websocket encrypted connection and HTTPS access.
+
+**Bug Fixes**
+-   Fixed crash issue caused by cascaded data anomalies.
+-   Resolved SNMP configuration invalid error.
+
+**Optimizations**
+-   Optimized upgrade script push logic.
+-   Sensor history records now displayed in reverse chronological order (last 60 entries).
+
+------------------------------------------------------------------------------
+
+# V1.0.3 (2024-10-01 - 2024-10-15)
+
+**New Features**
+-   Supports Modbus TCP cascading communication and dynamic slave scanning.
+-   Integrated Libcurl for email alarm functionality.
+-   Added NTP time synchronization function.
+
+**Bug Fixes**
+-   Fixed time zone setting error.
+-   Resolved database anomalies caused by configuration file ID changes.
+
+**Optimizations**
+-   Optimized NTP interface to support both IP and domain name modes.
+-   Refactored thread management interface.
+
+------------------------------------------------------------------------------
+
+# V1.0.2 (2024-10-01 - 2024-10-07)
+
+**New Features**
+-   Control boards support firmware upgrade logic.
+-   Added time range restriction function for database queries.
+
+**Bug Fixes**
+-   Fixed high CPU usage when no channels are scanned.
+-   Solved three-phase total data reading anomaly.
+-   Fixed single-phase/DC power consumption calculation error.
+
+**Optimizations**
+-   Increased maximum voltage display limit to 500V.
+-   Optimized configuration file import/export interfaces.
+-   Resolved button display issues caused by XML limitations.
+-   Improved sensor historical status storage logic.
+
+------------------------------------------------------------------------------
+
+# V1.0.1 (2024-09-16 - 2024-09-30)
+
+**New Features**
+-   Supports synchronized three-phase data display on QT screen.
+-   Added power consumption reset function for DC/single-phase devices.
+-   Added watchdog mechanism to enhance system stability.
+-   Supports independent configuration for DC overload alarm/action.
+
+**Bug Fixes**
+-   Fixed DNS configuration error.
+-   Solved issue where alarm threshold flags were not updated after reset.
+-   Fixed single-phase/DC total power consumption calculation error.
+-   Resolved file export function bug.
+-   Optimized database query efficiency (default time range reduced to 1 week).
+
+**Optimizations**
+-   Optimized power consumption calculation algorithm.
+-   Changed meter head alarm identifiers from `ABC` to `L123`.
+-   Adapted to dry contact sequence mapping requirements.
+-   Web interface upgraded to version 9.28, supporting Alibaba Cloud MQTT.
+
+------------------------------------------------------------------------------
+
+# V1.0.0 (2024-09-01 - 2024-09-15)
+
+**New Features**
+-   Adapted to Alibaba Cloud MQTT service.
+-   Supports CO₂ sensor data reading.
+-   Added sensor history record query interface.
+-   Customized Web pages for clients (separated by user directory).
+
+**Bug Fixes**
+-   Fixed sensor historical record storage anomaly.
+-   Solved three-phase frequency calculation error.
+-   Fixed power consumption reset function failure.
+-   Fixed dual-head sensor threshold setting anomaly.
+-   Resolved delay issue caused by switch detection board scan timeout.
+
+**Optimizations**
+-   Merged RAM/ROM checks into a unified interface.
+-   Optimized temperature/humidity sensor threshold retrieval logic.
+-   Updated Web to version 9.28.
+-   Added null checks to prevent out-of-bounds crashes.

+ 345 - 8
cust_data/changes_list.txt

@@ -1,10 +1,347 @@
-V0.0.2
+# V1.2.0 (2025-06-16 - 2025-06-26)
 
-New and improved:
-1. Add NTP time sync
-2. Add Changes log in firmware upgrade page
-3. Add power data manual export in web and auto export in smtp mail
+**New Features**
+-   Added SNMP interface for retrieving F407 power information.
 
-Fixes and enhancements:
-1. Increase the data quantity in power history query, upper limit 7 days
-2. Fix the not working bug in Overall Status History/Device History/Power Chart
+**Bug Fixes**
+-   Fixed GPIO conflict for dry contact sensors on the LCD screen.
+-   Resolved issue with batch threshold setting failure.
+-   Fixed SNMP GETNEXT command errors.
+
+**Optimizations**
+-   Optimized three-phase engineering configuration parameters.
+-   Streamlined firmware by removing unused functional modules.
+
+------------------------------------------------------------------------------
+
+# V1.1.9 (2025-06-01 - 2025-06-15)
+
+**New Features**
+-   Added support for displaying CO₂ sensor data.
+-   Added Bootloader secure jump verification for 4-channel boards.
+
+**Bug Fixes**
+-   Fixed sensor disconnection issue caused by rapid plugging/unplugging.
+-   Resolved MQTT device number type error.
+
+**Optimizations**
+-   Optimized alarm interface interaction logic.
+-   Reduced Websocket push data volume.
+
+------------------------------------------------------------------------------
+
+# V1.1.8 (2025-05-16 - 2025-05-31)
+
+**New Features**
+-   Added batch threshold setting function for F407 sensors.
+-   Supports hot-switching between three-phase/single-phase operating modes.
+
+**Bug Fixes**
+-   Fixed GPIO conflict during RGB meter head initialization.
+-   Resolved SNMP sensor list retrieval exception.
+
+**Optimizations**
+-   Optimized QT startup page loading speed.
+-   Added Bootloader upgrade file verification mechanism.
+
+------------------------------------------------------------------------------
+
+# V1.1.7 (2025-05-01 - 2025-05-15)
+
+**New Features**
+-   Supports dry contact alarms for multiple sensors.
+-   Added channel timed Websocket push function.
+
+**Bug Fixes**
+-   Fixed LCD data display conflict for multiple sensors.
+-   Solved crash issue caused by MQTT connection failure.
+
+**Optimizations**
+-   Optimized 4G activation configuration, reducing CPU usage.
+-   Shortened sensor offline determination time (3 timeouts).
+
+------------------------------------------------------------------------------
+
+# V1.1.6 (2025-04-16 - 2025-04-30)
+
+**New Features**
+-   Supports circuit breaker status detection.
+-   Added support for 4-channel / 1-channel self-locking control boards.
+
+**Bug Fixes**
+-   Fixed three-phase phase loss detection anomaly.
+-   Resolved NTP synchronization failure for IP meter heads.
+
+**Optimizations**
+-   Optimized Modbus TCP communication timeout handling.
+-   Reduced memory usage for historical record storage.
+
+------------------------------------------------------------------------------
+
+# V1.1.5 (2025-04-01 - 2025-04-15)
+
+**New Features**
+-   Supports 125A engineering configuration.
+-   Added dual live wire version for three-phase input to single-phase output.
+
+**Bug Fixes**
+-   Fixed Web threshold upper limit (max 999999).
+-   Solved QT interface misalignment issue for three-phase data display.
+
+**Optimizations**
+-   Optimized dual live wire power factor calculation algorithm.
+-   Simplified product file reading logic.
+
+------------------------------------------------------------------------------
+
+# V1.1.4 (2025-03-16 - 2025-03-31)
+
+**New Features**
+-   Supports reverse control for magnetic latching relays.
+-   Added hardware support for 7-channel / 3-channel boards.
+
+**Bug Fixes**
+-   Fixed dual live wire threshold enable anomaly.
+-   Resolved STS control logic conflict.
+
+**Optimizations**
+-   Unified parameter configuration for DC control boards.
+-   Optimized stability of cascaded data reading.
+
+------------------------------------------------------------------------------
+
+# V1.1.3 (2025-03-01 - 2025-03-15)
+
+**New Features**
+-   Supports SNMP power threshold management.
+
+**Bug Fixes**
+-   Fixed crash issue on legacy three-phase control boards.
+-   Resolved IP meter head database access conflict.
+
+**Optimizations**
+-   Optimized synchronization between channel control and web data.
+-   Reduced EEPROM write frequency on DC control boards.
+
+------------------------------------------------------------------------------
+
+# V1.1.2 (2025-02-16 - 2025-02-28)
+
+**New Features**
+-   Supports App-side version number upload.
+-   Added dual-stack (IPv4/IPv6) detection for 4G networks.
+
+**Bug Fixes**
+-   Fixed Bootloader verification failure issue for new 5-channel/4-channel boards.
+
+**Optimizations**
+-   Optimized QT interface layout, unified sensor unit display.
+-   Compressed F407 basic data structure (256 → 92 bytes).
+
+------------------------------------------------------------------------------
+
+# V1.1.1 (2025-02-01 - 2025-02-15)
+
+**New Features**
+-   Added web configuration items for 4G-related functions.
+-   Added dual live wire single-phase control matching logic.
+
+**Bug Fixes**
+-   Fixed WiFi SNMP protocol unavailability.
+-   Solved stack overflow issue caused by frequent three-phase data reading.
+
+**Optimizations**
+-   Optimized Websocket push cycle (0.5 seconds/push).
+-   Added display support for CO₂ sensors.
+
+------------------------------------------------------------------------------
+
+# V1.1.0 (2025-01-16 - 2025-01-31)
+
+**New Features**
+-   Supports STS (Static Transfer Switch) temperature monitoring.
+-   Added magnetic latching relay control logic.
+
+**Bug Fixes**
+-   Fixed upgrade function anomaly on single-phase control boards.
+-   Resolved STS Modbus communication out-of-bounds issue.
+
+**Optimizations**
+-   Optimized Bootloader jump verification process.
+-   Reduced stack memory usage on three-phase control boards.
+
+------------------------------------------------------------------------------
+
+# V1.0.9 (2025-01-01 - 2025-01-15)
+
+**New Features**
+-   Added network reset function (hold Up/Down keys to restore default configuration).
+
+**Bug Fixes**
+-   Fixed dual live wire project configuration error.
+-   Resolved QT interface sensor unit display anomaly.
+
+**Optimizations**
+-   Optimized MQTT data structure (power status upload).
+-   Streamlined firmware size by removing redundant modules.
+
+------------------------------------------------------------------------------
+
+# V1.0.8 (2024-12-16 - 2024-12-31)
+
+**New Features**
+-   Supports channel "Monitor Only" mode.
+-   Added 4G SMS alarm push function.
+
+**Bug Fixes**
+-   Fixed GPIO conflict between RGB meter head and LCD screen.
+-   Resolved INI configuration deadlock issue.
+
+**Optimizations**
+-   Optimized 4G network detection mechanism.
+-   Shortened sensor serial port read timeout to improve response speed.
+
+------------------------------------------------------------------------------
+
+# V1.0.7 (2024-12-01 - 2024-12-15)
+
+**New Features**
+-   Supports three-phase total detection function.
+-   Added dynamic DHCP allocation for Modbus TCP addresses.
+
+**Bug Fixes**
+-   Fixed leak sensor display error on military 8-inch screen.
+-   Solved QT interface rotation direction anomaly.
+
+**Optimizations**
+-   Optimized communication efficiency between QT and PDU message queues.
+
+------------------------------------------------------------------------------
+
+# V1.0.6 (2024-11-16 - 2024-11-30)
+
+**New Features**
+-   Added circuit breaker trip alarm function.
+-   Supports control board firmware upgrade via web interface (includes QR code generation).
+
+**Bug Fixes**
+-   Fixed threshold import exception.
+-   Resolved sensor data garbled text issue on IP meter heads.
+
+**Optimizations**
+-   Optimized packaging scripts for new hardware compatibility.
+-   Refactored Web interface layout, fixed display misalignment.
+
+------------------------------------------------------------------------------
+
+# V1.0.5 (2024-11-01 - 2024-11-15)
+
+**New Features**
+-   Added configuration file import/export interfaces.
+-   Supports configuring meter face maximum values for voltage/current/power.
+
+**Bug Fixes**
+-   Fixed memory leak in three-phase input to single-phase output configuration.
+-   Resolved NTP synchronization failure.
+
+**Optimizations**
+-   Removed database dependency on `product_id` to avoid configuration change anomalies.
+-   Added slave temperature sensor data display to IP meter heads.
+
+------------------------------------------------------------------------------
+
+# V1.0.4 (2024-10-16 - 2024-10-31)
+
+**New Features**
+-   Supports SNMP TRAP function (sensor/power overload alarms).
+-   Added Websocket encrypted connection and HTTPS access.
+
+**Bug Fixes**
+-   Fixed crash issue caused by cascaded data anomalies.
+-   Resolved SNMP configuration invalid error.
+
+**Optimizations**
+-   Optimized upgrade script push logic.
+-   Sensor history records now displayed in reverse chronological order (last 60 entries).
+
+------------------------------------------------------------------------------
+
+# V1.0.3 (2024-10-01 - 2024-10-15)
+
+**New Features**
+-   Supports Modbus TCP cascading communication and dynamic slave scanning.
+-   Integrated Libcurl for email alarm functionality.
+-   Added NTP time synchronization function.
+
+**Bug Fixes**
+-   Fixed time zone setting error.
+-   Resolved database anomalies caused by configuration file ID changes.
+
+**Optimizations**
+-   Optimized NTP interface to support both IP and domain name modes.
+-   Refactored thread management interface.
+
+------------------------------------------------------------------------------
+
+# V1.0.2 (2024-10-01 - 2024-10-07)
+
+**New Features**
+-   Control boards support firmware upgrade logic.
+-   Added time range restriction function for database queries.
+
+**Bug Fixes**
+-   Fixed high CPU usage when no channels are scanned.
+-   Solved three-phase total data reading anomaly.
+-   Fixed single-phase/DC power consumption calculation error.
+
+**Optimizations**
+-   Increased maximum voltage display limit to 500V.
+-   Optimized configuration file import/export interfaces.
+-   Resolved button display issues caused by XML limitations.
+-   Improved sensor historical status storage logic.
+
+------------------------------------------------------------------------------
+
+# V1.0.1 (2024-09-16 - 2024-09-30)
+
+**New Features**
+-   Supports synchronized three-phase data display on QT screen.
+-   Added power consumption reset function for DC/single-phase devices.
+-   Added watchdog mechanism to enhance system stability.
+-   Supports independent configuration for DC overload alarm/action.
+
+**Bug Fixes**
+-   Fixed DNS configuration error.
+-   Solved issue where alarm threshold flags were not updated after reset.
+-   Fixed single-phase/DC total power consumption calculation error.
+-   Resolved file export function bug.
+-   Optimized database query efficiency (default time range reduced to 1 week).
+
+**Optimizations**
+-   Optimized power consumption calculation algorithm.
+-   Changed meter head alarm identifiers from `ABC` to `L123`.
+-   Adapted to dry contact sequence mapping requirements.
+-   Web interface upgraded to version 9.28, supporting Alibaba Cloud MQTT.
+
+------------------------------------------------------------------------------
+
+# V1.0.0 (2024-09-01 - 2024-09-15)
+
+**New Features**
+-   Adapted to Alibaba Cloud MQTT service.
+-   Supports CO₂ sensor data reading.
+-   Added sensor history record query interface.
+-   Customized Web pages for clients (separated by user directory).
+
+**Bug Fixes**
+-   Fixed sensor historical record storage anomaly.
+-   Solved three-phase frequency calculation error.
+-   Fixed power consumption reset function failure.
+-   Fixed dual-head sensor threshold setting anomaly.
+-   Resolved delay issue caused by switch detection board scan timeout.
+
+**Optimizations**
+-   Merged RAM/ROM checks into a unified interface.
+-   Optimized temperature/humidity sensor threshold retrieval logic.
+-   Updated Web to version 9.28.
+-   Added null checks to prevent out-of-bounds crashes.

BIN
cust_data/qt/Qt_Test


BIN
cust_data/qt/rgb_lcd/Qt_Test


+ 148 - 0
cust_data/qt/rgb_lcd/S90PDUApp

@@ -0,0 +1,148 @@
+#!/bin/sh
+
+RUNDIR=/root/run
+APPDIR=$RUNDIR/app
+WEBDIR=$RUNDIR/web
+SNMPDIR=$APPDIR/snmp
+
+source /etc/qtenv.sh
+export MIBDIRS=$SNMPDIR/mibs
+export LD_LIBRARY_PATH=$APPDIR/lib:$LD_LIBRARY_PATH
+export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event4:rotate=180:invertx
+
+
+start_snmpd()
+{
+    $SNMPDIR/bin/snmpd -Cc $SNMPDIR/conf/snmpd.conf -Lo 
+    chmod 777 /var/agentx/master
+}
+start_pdu()
+{
+    #run smartPDU
+    $APPDIR/smartPDU &
+}
+led_on()
+{
+    #light led
+    echo 98 > /sys/class/gpio/export
+    echo out > /sys/class/gpio/gpio98/direction
+    echo 1 > /sys/class/gpio/gpio98/value
+    echo 101 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio101/direction
+    echo 102 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio102/direction
+    echo 103 > /sys/class/gpio/export
+    echo out > /sys/class/gpio/gpio103/direction
+    echo 104 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio104/direction
+    echo 105 > /sys/class/gpio/export
+    echo out > /sys/class/gpio/gpio105/direction
+    echo 106 > /sys/class/gpio/export
+    echo out > /sys/class/gpio/gpio106/direction
+    echo 113 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio113/direction
+    echo 115 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio115/direction
+    echo 142 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio142/direction
+    echo 143 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio143/direction
+    echo 144 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio144/direction
+    echo 145 > /sys/class/gpio/export
+    echo in  > /sys/class/gpio/gpio145/direction
+
+}
+start_lcd()
+{
+    #light lcd
+    led_on
+if [ -f $APPDIR/Qt_Test ]; then
+    fbinit
+    $APPDIR/Qt_Test --platform=linuxfb &
+fi
+}
+
+
+
+app_start()
+{
+  case "$1" in
+    smartPDU)
+      start_pdu   
+      ;;
+    snmpd)
+      start_snmpd
+      ;;
+    Qt_Test)
+      start_lcd
+      ;;
+    all)
+      start_snmpd
+      start_pdu
+      start_lcd
+      ;;
+    *)
+      exit 1
+  esac
+}
+app_stop()
+{
+  case "$1" in
+    smartPDU)
+      killall $1
+      ;;
+    snmpd)
+      killall $1
+      ;;
+    Qt_Test)
+      killall $1
+      ;;
+    all)
+      killall snmpd smartPDU Qt_Test
+      ;;
+    *)
+      exit 1
+  esac
+}
+
+
+if [ $# -eq 0 ]; then
+  app_start all
+elif [ $# -eq 1 ]; then
+  case "$1" in
+    start)
+      app_start all        
+      ;;
+    stop)
+      app_stop all
+      ;;
+    restart)
+      "$0" stop all
+      "$0" start all
+    ;;
+    *)
+      echo "wrong param!"
+      exit 1
+  esac
+
+else
+  case "$1" in
+    start)
+      app_start $2        
+      ;;
+    stop)
+      app_stop $2
+      ;;
+    restart)
+      "$0" stop $2
+      "$0" start $2
+      ;;
+    *)
+      echo "wrong param!"
+      exit 1
+  esac
+fi
+
+
+

+ 468 - 46
f407/applications/snmp.c

@@ -8,6 +8,7 @@
 #include "lwip/apps/snmp_table.h"
 #include "lwip/apps/snmp_scalar.h"
 #include "string.h"
+#include "power.h"
 
 
 
@@ -16,8 +17,9 @@
 
 #define SNMP_SMARTPDU_OID 										{1,3,6,1,4,1,2024}
 #define SNMP_SMARTPDU_DEVICE_OID							{1,3,6,1,4,1,2024,1}
-#define SNMP_SMARTPDU_CHANNEL_TABLE           {1,3,6,1,4,1,2024,1,3,9}
-
+//#define SNMP_SMARTPDU_CHANNEL_TABLE           {1,3,6,1,4,1,2024,1,3,9}
+//#define SNMP_SMARTPDU_ALARM_TABLE_IOD       	{1,3,6,1,4,1,2024,1,6,1}
+#define   SNMP_SMARTPDU_THR_TABLE_IOD           {1,3,6,1,4,1,2024,1,7}
 typedef struct 
 {
 	uint8_t sysdescr[10];
@@ -114,6 +116,38 @@ typedef struct power_data{
 	float             a_p;
 }p_data_t;
 
+typedef struct alarm_data{
+	uint8_t id;
+	uint8_t type;
+	char * alarm_info;
+	uint8_t alarm_action;
+	uint32_t alarm_action_para;
+	char * date;
+	char * time;
+}p_alarm_t;
+
+typedef struct threshold_data{
+	uint8_t 		 id;
+	char 			*name;
+	float     v_max;
+	float     v_min;
+	float     i_max;
+	float     p_max;
+	float     c_max;
+}thr_d_t;
+
+
+typedef struct thr_sensor_data{
+	uint8_t 		 id;
+	char         *name;
+	uint32_t     val1_up;
+	uint32_t     val2_up;
+	uint32_t     val1_down;
+	uint32_t     val2_down;
+}thr_s_t;
+
+
+
 
 
 static p_data_t p_data[POWER_VALUE]={
@@ -171,14 +205,320 @@ static p_data_t p_data[POWER_VALUE]={
 	},
 };
 
-
+static thr_s_t  p_thr_s[POWER_VALUE] = {
+	{
+		.id = 1,
+	  .name = "sers_th1",
+		.val1_up = 23,
+		.val2_up = 32,
+		.val1_down = 11,
+		.val2_down = 12,
+	},
+	{
+		.id = 2,
+	  .name = "sers_th2",
+		.val1_up = 23,
+		.val2_up = 32,
+		.val1_down = 11,
+		.val2_down = 12,
+	},
+	{
+		.id = 3,
+	  .name = "sers_th3",
+		.val1_up = 23,
+		.val2_up = 32,
+		.val1_down = 11,
+		.val2_down = 12,
+	},
+	{
+		.id = 4,
+	  .name = "sers_th4",
+		.val1_up = 23,
+		.val2_up = 32,
+		.val1_down = 11,
+		.val2_down = 12,
+	},
+};
 
 static const struct snmp_oid_range th_table_oid_ranges[] = {
     {1, POWER_VALUE},
 };
 
 
-static snmp_err_t power_get_instance(const u32_t *column, const u32_t *row_oid, u8_t row_oid_len, struct snmp_node_instance *cell_instance)
+
+
+static p_alarm_t p_a_data[POWER_VALUE]={
+	{
+		.id = 1,
+		.type = 3,
+		.alarm_info="voltage alarm!!!",
+		.alarm_action = 0,
+		.alarm_action_para = 4,
+		.date = "2052.12.20",
+		.time = "12:30:47",
+	},
+	{
+		.id = 2,
+		.type = 2,
+		.alarm_info="current alarm!!!",
+		.alarm_action = 1,
+		.alarm_action_para = 2,
+		.date = "2002-11-20",
+		.time = "10:30:47",
+	},
+	{
+		.id = 3,
+		.type = 1,
+		.alarm_info="power alarm!!!",
+		.alarm_action = 3,
+		.alarm_action_para = 6,
+		.date = "2012-11-20",
+		.time = "10:59:47",
+	},
+	{
+		.id = 4,
+		.type = 4,
+		.alarm_info="consumer alarm!!!",
+		.alarm_action = 3,
+		.alarm_action_para = 6,
+		.date = "2012-11-20",
+		.time = "10:59:47",
+	},
+};
+
+static thr_d_t p_t_data[POWER_VALUE]=
+{
+	{
+		.id = 1,
+		.name="thrould",
+		.v_max = 250.00,
+		.v_min = 180.00,
+		.i_max = 50.00,
+		.p_max = 20000.00,
+		.c_max = 10000,
+	},
+	{
+		.id = 2,
+		.name="thrould",
+		.v_max = 250.00,
+		.v_min = 180.00,
+		.i_max = 50.00,
+		.p_max = 20000.00,
+		.c_max = 10000,
+	},
+	{
+		.id = 3,
+		.name="thrould",
+		.v_max = 250.00,
+		.v_min = 180.00,
+		.i_max = 50.00,
+		.p_max = 20000.00,
+		.c_max = 10000,
+	},
+	{
+		.id = 4,
+		.name="thrould",
+		.v_max = 250.00,
+		.v_min = 180.00,
+		.i_max = 50.00,
+		.p_max = 20000.00,
+		.c_max = 10000,
+	},
+};
+
+static snmp_err_t thr_s_set_value(struct snmp_node_instance *instance,u16_t len, void *value)
+{
+	  u32_t row = instance->reference.u32;
+    u32_t col = SNMP_TABLE_GET_COLUMN_FROM_OID(instance->instance_oid.id);
+		switch(col)
+		{
+			case COLUMN_PDUSENSORLIMITVALUE1UP:
+			{
+				p_thr_s[row-1].val1_up =  *(uint32_t *)value;
+			}
+				break;
+			case COLUMN_PDUSENSORLIMITVALUE2UP:
+			{
+				p_thr_s[row-1].val2_up =  *(uint32_t *)value;
+			}
+				break;
+			case COLUMN_PDUSENSORLIMITVALUE1DOWN:
+			{
+				p_thr_s[row-1].val1_down =  *(uint32_t *)value;
+			}
+				break;
+			case COLUMN_PDUSENSORLIMITVALUE2DOWN:
+			{
+				p_thr_s[row-1].val2_down =  *(uint32_t *)value;
+			}
+				break;
+			default:
+				return SNMP_ERR_NOTWRITABLE;
+		}
+		return SNMP_ERR_NOERROR;
+}
+
+static s16_t  thr_s_get_value(struct snmp_node_instance *instance, void *value)
+{
+    u32_t row = instance->reference.u32;
+    u32_t col = SNMP_TABLE_GET_COLUMN_FROM_OID(instance->instance_oid.id);
+		char buff[50]= {0};
+		switch(col)
+		{
+			case COLUMN_PDUSENSORLIMITID:
+			{
+				*(s32_t *)value	= p_thr_s[row-1].id;
+				return 4;
+			}
+			break;
+			case COLUMN_PDUSENSORLIMITNAME:
+			{
+				sprintf(buff,"%s",p_thr_s[row-1].name);
+			}
+				break;
+			case COLUMN_PDUSENSORLIMITVALUE1UP:
+			{
+				*(s32_t *)value	= p_thr_s[row-1].val1_up;
+				return 4;
+			}
+				break;
+			case COLUMN_PDUSENSORLIMITVALUE2UP:
+			{
+				*(s32_t *)value	= p_thr_s[row-1].val2_up;
+				return 4;
+			}
+			break;
+			case COLUMN_PDUSENSORLIMITVALUE1DOWN:
+			{
+				*(s32_t *)value	= p_thr_s[row-1].val1_down;
+				return 4;
+			}
+			break;
+			case COLUMN_PDUSENSORLIMITVALUE2DOWN:
+			{
+				*(s32_t *)value	= p_thr_s[row-1].val2_down;
+				return 4;
+			}
+			break;
+			default:
+				return 0;
+		}
+		memcpy(value,buff,strlen(buff));
+    return strlen(buff);
+}
+
+
+
+static s16_t thr_get_value(struct snmp_node_instance *instance, void *value)
+{
+    u32_t row = instance->reference.u32;
+    u32_t col = SNMP_TABLE_GET_COLUMN_FROM_OID(instance->instance_oid.id);
+		char buff[50]= {0};
+		switch (col)
+		{
+			case COLUMN_PDUCHANNELLIMITID:
+			{
+				*(s32_t *)value	= p_t_data[row-1].id;
+				return 4;
+			}
+				break;
+			case COLUMN_PDUCHANNELLIMITNAME:
+			{
+				sprintf(buff,"%s",p_t_data[row-1].name);
+			}
+			break;
+			case COLUMN_PDUCHANNELCURRENTLIMITUP:
+			{
+				sprintf(buff,"%.2f",p_t_data[row-1].i_max);
+			}
+			break;
+			case COLUMN_PDUCHANNELVOLTAGELIMITUP:
+			{
+				sprintf(buff,"%.2f",p_t_data[row-1].v_max);
+			}
+			break;
+			case COLUMN_PDUCHANNELVOLTAGELIMITDOWN:
+			{
+				sprintf(buff,"%.2f",p_t_data[row-1].v_min);
+			}
+			break;
+			case COLUMN_PDUCHANNELPOWERLIMITUP:
+			{
+				sprintf(buff,"%.2f",p_t_data[row-1].p_max);
+			}
+			break;
+			case COLUMN_PDUCHANNELCONSUMPTIONLIMITUP:
+			{
+				sprintf(buff,"%.2f",p_t_data[row-1].c_max);
+			}
+			break;
+			default:
+				return 0;
+		}
+		memcpy(value,buff,strlen(buff));
+    return strlen(buff);
+}
+
+
+
+static s16_t alarm_get_value(struct snmp_node_instance *instance, void *value)
+{
+    u32_t row = instance->reference.u32;
+    u32_t col = SNMP_TABLE_GET_COLUMN_FROM_OID(instance->instance_oid.id);
+		char buff[50]= {0};
+		switch (col)
+		{
+			case COLUMN_PDUALARMID:
+			{
+				*(s32_t *)value	= p_a_data[row-1].id;
+				return 4;
+			}
+			break;
+			case COLUMN_PDUALARMTYPE:
+			{
+				*(s32_t *)value	= p_a_data[row-1].type;
+				return 4;				
+			}
+			break;
+			case COLUMN_PDUALARMCONTEXT:
+			{
+				sprintf(buff,"%s",p_a_data[row-1].alarm_info);
+			}
+			break;
+			case COLUMN_PDUALARMACTION:
+			{
+				*(s32_t *)value	= p_a_data[row-1].alarm_action;
+				return 4;				
+			}
+			break;
+			case COLUMN_PDUALARMACTIONPARA:
+			{
+				*(s32_t *)value	= p_a_data[row-1].alarm_action_para;
+				return 4;					
+			}
+			break;
+			case COLUMN_PDUALARMDATE:
+			{
+				sprintf(buff,"%s",p_a_data[row-1].date);
+			}
+			break;
+			case COLUMN_PDUALARMTIME:
+			{
+				sprintf(buff,"%s",p_a_data[row-1].time);
+			}
+			break;
+			default:
+				return 0;
+		}
+		memcpy(value,buff,strlen(buff));
+		
+    return strlen(buff);
+}
+
+
+
+
+static snmp_err_t get_instance(const u32_t *column, const u32_t *row_oid, u8_t row_oid_len, struct snmp_node_instance *cell_instance)
 {
 	if (!snmp_oid_in_range(row_oid, row_oid_len, th_table_oid_ranges, LWIP_ARRAYSIZE(th_table_oid_ranges)))
         return SNMP_ERR_NOSUCHINSTANCE;
@@ -188,13 +528,15 @@ static snmp_err_t power_get_instance(const u32_t *column, const u32_t *row_oid,
 }
 
 
-static snmp_err_t power_get_next_instance(const u32_t *column, struct snmp_obj_id *row_oid, struct snmp_node_instance *cell_instance)
+static snmp_err_t get_next_instance(const u32_t *column, struct snmp_obj_id *row_oid, struct snmp_node_instance *cell_instance)
 {
     u8_t i = 0;
     struct snmp_next_oid_state state;
     u32_t next_oid = 0;
 
     snmp_next_oid_init(&state, row_oid->id, row_oid->len, &next_oid, 1);
+//		power_all_t all;
+//    power_data_get(&all);
     for (i = 0; i < POWER_VALUE; i++)
     {
         u32_t test_oid = i + 1;
@@ -215,18 +557,6 @@ static s16_t power_get_value(struct snmp_node_instance *instance, void *value)
 {
     u32_t row = instance->reference.u32;
     u32_t col = SNMP_TABLE_GET_COLUMN_FROM_OID(instance->instance_oid.id);
-    //s32_t *value_s32 = (s32_t *)value;
-
-    /* 第一列索引 */
-//    if (col == 1)
-//    {
-//        *(s32_t *)value = row;
-//        return sizeof(s32_t);
-//    } 
-//    if (col < 4)
-//         th_value[row - 1][col - 2] = row * 100 + col * 10 + rand() % 10 + th_value[row - 1][col];
-
-//    *value_s32 = p_data[row - 1][col - 2];
 		char buff[100]= {0};
 		switch (col)
 		{
@@ -296,7 +626,7 @@ static s16_t power_get_value(struct snmp_node_instance *instance, void *value)
 		
     return strlen(buff);
 }
-static snmp_err_t th_set_test(struct snmp_node_instance *instance, u16_t len, void *value)
+static snmp_err_t set_test(struct snmp_node_instance *instance, u16_t len, void *value)
 {
 	LOGD("write test\n");
 	return SNMP_ERR_NOERROR;
@@ -318,7 +648,42 @@ static snmp_err_t  power_set_value (struct snmp_node_instance *instance, u16_t l
 		}
 		return SNMP_ERR_NOERROR;
 }
-
+static snmp_err_t thr_set_value(struct snmp_node_instance *instance,u16_t len, void *value)
+{
+	  u32_t row = instance->reference.u32;
+    u32_t col = SNMP_TABLE_GET_COLUMN_FROM_OID(instance->instance_oid.id);
+		switch(col)
+		{
+			case COLUMN_PDUCHANNELCURRENTLIMITUP:
+			{
+				p_t_data[row-1].i_max = (float)atof((char *)value);
+			}
+			break;
+			case COLUMN_PDUCHANNELVOLTAGELIMITUP:
+			{
+				p_t_data[row-1].v_max = (float)atof((char *)value);
+			}
+			break;
+			case COLUMN_PDUCHANNELVOLTAGELIMITDOWN:
+			{
+				p_t_data[row-1].v_min = (float)atof((char *)value);
+			}
+			break;
+			case COLUMN_PDUCHANNELPOWERLIMITUP:
+			{
+				p_t_data[row-1].p_max = (float)atof((char *)value);
+			}
+			break;
+			case COLUMN_PDUCHANNELCONSUMPTIONLIMITUP:
+			{
+				p_t_data[row-1].c_max = (float)atof((char *)value);
+			}
+			break;
+			default:
+				return SNMP_ERR_INCONSISTENTNAME;
+		}
+		return SNMP_ERR_NOERROR;		
+}
 
 static const struct snmp_scalar_array_node_def sysinfo_scalars_nodes[] = {
     {1, SNMP_ASN1_TYPE_OCTET_STRING, SNMP_NODE_INSTANCE_READ_ONLY}, 				/* product id  */
@@ -330,69 +695,126 @@ static const struct snmp_scalar_array_node_def sysinfo_scalars_nodes[] = {
 		{0,0,0},
 };
 
+static const struct snmp_table_col_def power_table_channels[]={
+	{COLUMN_PDUCHANNELID,											SNMP_ASN1_TYPE_INTEGER,								SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUCHANNELNAME,										SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUCHANNELSTATUS,									SNMP_ASN1_TYPE_INTEGER,								SNMP_NODE_INSTANCE_READ_WRITE},
+	{COLUMN_PDUCHANNELVOLTAGE,								SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUCHANNELCURRENT,								SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUCHANNELFREQUENCY,							SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUCHANNELCONSUMPTION,						SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUCHANNELPOWERFACTOR,						SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUCHANNELPACTIVEPOWER,						SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUCHANNELREACTIVEPOWER,					SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUCHANNELAPPARENTPOWER,					SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_ONLY},
+	{0,0,0},
+};
 
 
-static const struct snmp_table_col_def power_table_channels[]={
-	{COLUMN_PDUCHANNELID,SNMP_ASN1_TYPE_INTEGER,SNMP_NODE_INSTANCE_READ_ONLY},
-	{COLUMN_PDUCHANNELNAME,SNMP_ASN1_TYPE_OCTET_STRING,SNMP_NODE_INSTANCE_READ_ONLY},
-	{COLUMN_PDUCHANNELSTATUS,SNMP_ASN1_TYPE_INTEGER,SNMP_NODE_INSTANCE_READ_ONLY},
-	{COLUMN_PDUCHANNELVOLTAGE,SNMP_ASN1_TYPE_OCTET_STRING,SNMP_NODE_INSTANCE_READ_ONLY},
-	{COLUMN_PDUCHANNELCURRENT,SNMP_ASN1_TYPE_OCTET_STRING,SNMP_NODE_INSTANCE_READ_ONLY},
-	{COLUMN_PDUCHANNELFREQUENCY,SNMP_ASN1_TYPE_OCTET_STRING,SNMP_NODE_INSTANCE_READ_ONLY},
-	{COLUMN_PDUCHANNELCONSUMPTION,SNMP_ASN1_TYPE_OCTET_STRING,SNMP_NODE_INSTANCE_READ_ONLY},
-	{COLUMN_PDUCHANNELPOWERFACTOR,SNMP_ASN1_TYPE_OCTET_STRING,SNMP_NODE_INSTANCE_READ_ONLY},
-	{COLUMN_PDUCHANNELPACTIVEPOWER,SNMP_ASN1_TYPE_OCTET_STRING,SNMP_NODE_INSTANCE_READ_ONLY},
-	{COLUMN_PDUCHANNELREACTIVEPOWER,SNMP_ASN1_TYPE_OCTET_STRING,SNMP_NODE_INSTANCE_READ_ONLY},
-	{COLUMN_PDUCHANNELAPPARENTPOWER,SNMP_ASN1_TYPE_OCTET_STRING,SNMP_NODE_INSTANCE_READ_ONLY},
+
+static const struct snmp_table_col_def alarm_history_table[]={
+	{COLUMN_PDUALARMID,												SNMP_ASN1_TYPE_INTEGER,								SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUALARMTYPE,											SNMP_ASN1_TYPE_INTEGER,								SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUALARMCONTEXT,									SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUALARMACTION,										SNMP_ASN1_TYPE_INTEGER,								SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUALARMACTIONPARA,								SNMP_ASN1_TYPE_INTEGER,								SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUALARMDATE,											SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUALARMTIME,											SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_ONLY},
 	{0,0,0},
 };
 
+static const struct snmp_table_col_def threshold_limit_table[] = {
+	{COLUMN_PDUCHANNELLIMITID,								SNMP_ASN1_TYPE_INTEGER,               SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUCHANNELLIMITNAME,							SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_ONLY},
+	{COLUMN_PDUCHANNELCURRENTLIMITUP,					SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_WRITE},
+	{COLUMN_PDUCHANNELVOLTAGELIMITUP,					SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_WRITE},
+	{COLUMN_PDUCHANNELVOLTAGELIMITDOWN,				SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_WRITE},
+	{COLUMN_PDUCHANNELPOWERLIMITUP,						SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_WRITE},
+	{COLUMN_PDUCHANNELCONSUMPTIONLIMITUP,			SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_WRITE},
+	{0,0,0},
+};
+
+static const struct snmp_table_col_def 	sensor_limit_table[] = {
+	{COLUMN_PDUSENSORLIMITID,									SNMP_ASN1_TYPE_INTEGER,								SNMP_NODE_INSTANCE_READ_ONLY,},
+	{COLUMN_PDUSENSORLIMITNAME,								SNMP_ASN1_TYPE_OCTET_STRING,					SNMP_NODE_INSTANCE_READ_ONLY,},
+	{COLUMN_PDUSENSORLIMITVALUE1UP,						SNMP_ASN1_TYPE_INTEGER,								SNMP_NODE_INSTANCE_READ_WRITE,},
+	{COLUMN_PDUSENSORLIMITVALUE2UP,						SNMP_ASN1_TYPE_INTEGER,								SNMP_NODE_INSTANCE_READ_WRITE,},
+	{COLUMN_PDUSENSORLIMITVALUE1DOWN,					SNMP_ASN1_TYPE_INTEGER,								SNMP_NODE_INSTANCE_READ_WRITE,},
+	{COLUMN_PDUSENSORLIMITVALUE2DOWN,					SNMP_ASN1_TYPE_INTEGER,								SNMP_NODE_INSTANCE_READ_WRITE,},
+	{0,0,0},
+};
+
+
 
 const struct snmp_scalar_array_node sysinfo_scalars = SNMP_SCALAR_CREATE_ARRAY_NODE(1, sysinfo_scalars_nodes, sysinfo_get_value, NULL, NULL);
-static const struct snmp_table_node power_table = SNMP_TABLE_CREATE(9, power_table_channels, power_get_instance, power_get_next_instance, \
-	power_get_value, th_set_test, power_set_value);
 
 
+static const struct snmp_table_node power_table = SNMP_TABLE_CREATE(9, power_table_channels, get_instance, get_next_instance, \
+							power_get_value, set_test, power_set_value);
+
+static const struct snmp_table_node alarm_table = SNMP_TABLE_CREATE(1, alarm_history_table, get_instance, get_next_instance, \
+							alarm_get_value, set_test, NULL);
+
+static const struct snmp_table_node thr_table = SNMP_TABLE_CREATE(6, threshold_limit_table, get_instance, get_next_instance, \
+							thr_get_value, set_test, thr_set_value);
+
+static const struct snmp_table_node thr_s_table = SNMP_TABLE_CREATE(1, sensor_limit_table, get_instance, get_next_instance, \
+							thr_s_get_value, set_test, thr_s_set_value);
 
 
 
 
 
+
+static const struct snmp_node *const alarm_subnodes[]={
+	&alarm_table.node.node,
+};
 static const struct snmp_node *const power_subnodes[] = {
     &power_table.node.node,
 };
+static const struct snmp_node *const thr_subnodes[] = {
+    &thr_table.node.node,
+};
+
+static const struct snmp_node *const thr_s_subnodes[] = {
+    &thr_s_table.node.node,
+};
+
+const struct snmp_tree_node power_treenode 	= SNMP_CREATE_TREE_NODE(3, power_subnodes);
+const struct snmp_tree_node alarm_treenode 	= SNMP_CREATE_TREE_NODE(6, alarm_subnodes);
+const struct snmp_tree_node thr_treenode 		= SNMP_CREATE_TREE_NODE(2, thr_subnodes);
+const struct snmp_tree_node thr_s_treenode 		= SNMP_CREATE_TREE_NODE(3, thr_s_subnodes);
+
+
 
 
-const struct snmp_tree_node power_treenode = SNMP_CREATE_TREE_NODE(3, power_subnodes);
 
 static const struct snmp_node *const mib2_nodes_dev[] =
 {
     &sysinfo_scalars.node.node,
 		&power_treenode.node,
+		&alarm_treenode.node,
+		//&thr_treenode.node,
 };
 
-//static const struct snmp_node *const mib2_nodes_pw_dev[] ={
-//		&power_treenode.node,
-//};
 
+static const struct snmp_node *const mib2_nodes_dev_2[]={
+	&thr_treenode.node,
+	&thr_s_treenode.node,
+};
 
 
 static const struct snmp_tree_node snmp_mib2_root_dev = SNMP_CREATE_TREE_NODE(1, mib2_nodes_dev);
-
-//static const struct snmp_tree_node snmp_mib2_pw_dev = SNMP_CREATE_TREE_NODE(11, mib2_nodes_pw_dev);
-
-
+static const struct snmp_tree_node snmp_mib2_thr_dev = SNMP_CREATE_TREE_NODE(7, mib2_nodes_dev_2);
 
 
 static const u32_t prvmib_base_oid[] = SNMP_SMARTPDU_DEVICE_OID;
-//static const u32_t power_base_oid[] = SNMP_SMARTPDU_CHANNEL_TABLE;
-
+static const u32_t thr_base_oid[] = SNMP_SMARTPDU_THR_TABLE_IOD;
 
 const struct snmp_mib mib2_dev = SNMP_MIB_CREATE(prvmib_base_oid, &snmp_mib2_root_dev.node);
-//const struct snmp_mib mib2_pw_dev = SNMP_MIB_CREATE(power_base_oid, &snmp_mib2_pw_dev.node);
-
+const struct snmp_mib mib2_th_dev = SNMP_MIB_CREATE(thr_base_oid, &snmp_mib2_thr_dev.node);
 
-static const struct snmp_mib *dev_mibs[] = {&mib2, &mib2_dev};
+static const struct snmp_mib *dev_mibs[] = {&mib2, &mib2_dev,&mib2_th_dev};
 
 
 

+ 48 - 0
f407/applications/snmp.h

@@ -16,8 +16,56 @@
        #define COLUMN_PDUCHANNELREACTIVEPOWER		10
        #define COLUMN_PDUCHANNELAPPARENTPOWER		11
 
+/* column number definitions for table pduAlarmHistoryTable */
+       #define COLUMN_PDUALARMID			1
+       #define COLUMN_PDUALARMTYPE		2
+       #define COLUMN_PDUALARMCONTEXT		3
+       #define COLUMN_PDUALARMACTION		4
+       #define COLUMN_PDUALARMACTIONPARA		5
+       #define COLUMN_PDUALARMDATE		6
+       #define COLUMN_PDUALARMTIME		7
+			 
+/* column number definitions for table pduChannelLimitTable */		 
+       #define COLUMN_PDUCHANNELLIMITID		1
+       #define COLUMN_PDUCHANNELLIMITNAME		2
+       #define COLUMN_PDUCHANNELCURRENTLIMITUP		3
+       #define COLUMN_PDUCHANNELVOLTAGELIMITUP		4
+       #define COLUMN_PDUCHANNELVOLTAGELIMITDOWN		5
+       #define COLUMN_PDUCHANNELPOWERLIMITUP		6
+       #define COLUMN_PDUCHANNELCONSUMPTIONLIMITUP		7
 
 
+/* column number definitions for table pduSensorLimitTable */
+       #define COLUMN_PDUSENSORLIMITID		1
+       #define COLUMN_PDUSENSORLIMITNAME		2
+       #define COLUMN_PDUSENSORLIMITVALUE1UP		3
+       #define COLUMN_PDUSENSORLIMITVALUE2UP		4
+       #define COLUMN_PDUSENSORLIMITVALUE1DOWN		5
+       #define COLUMN_PDUSENSORLIMITVALUE2DOWN		6
+			 
+			 
+/* column number definitions for table pduSensorTable */
+       #define COLUMN_PDUSENSORID			1
+       #define COLUMN_PDUSENSORNAME		2
+       #define COLUMN_PDUSENSORTYPE		3
+       #define COLUMN_PDUSENSORDATACHENNEL		4
+       #define COLUMN_PDUSENSORMODBUSADDRESS		5
+       #define COLUMN_PDUSENSORSTATUS		7
+       #define COLUMN_PDUSENSORVALUENUM		8
+       #define COLUMN_PDUSENSORVALUE1		9
+       #define COLUMN_PDUSENSORVALUE2		10
+			 
+			 
+			 
+/* column number definitions for table pduSensorLimitTable */
+       #define COLUMN_PDUSENSORLIMITID		1
+       #define COLUMN_PDUSENSORLIMITNAME		2
+       #define COLUMN_PDUSENSORLIMITVALUE1UP		3
+       #define COLUMN_PDUSENSORLIMITVALUE2UP		4
+       #define COLUMN_PDUSENSORLIMITVALUE1DOWN		5
+       #define COLUMN_PDUSENSORLIMITVALUE2DOWN		6
+			 
+			 
 
 int snmp2_init(void);
 int snmp2_deinit(void);

+ 1 - 1
pro/src/Cellular.c

@@ -54,7 +54,7 @@
 #define MQTT_CHUNCK_SIZE            1500
 
 
-#define SMS_SEND_MAX                    100
+#define SMS_SEND_MAX                    500
 
 #define UNLINK_MAX                    3
 

+ 3 - 1
pub

@@ -42,7 +42,7 @@ PRJS="PRJ_Malaysia_AC_I3_O1"
 #PRJS="PRJ_IP_YUNNAN_AC_I1_O1"
 #PRJS="PRJ_IP_CHONGQING_AC_I1_O1"
 #PRJS="PRJ_IP_AOSENS_AC_I1_O1"
-PRJS="PRJ_IP_AOSENS_DC_I_O"
+#PRJS="PRJ_IP_AOSENS_DC_I_O"
 
 fulldir=$(realpath $0)
 curdir=$(dirname $fulldir)
@@ -196,6 +196,8 @@ function do_copy()
     elif [ "$1" = "PRJ_Malaysia_AC_I3_O1" ];then
         name=ac_Malaysia_in3_out1_release
 	cp -f $custdir/logo/logo_litech.png $appdir/image/logo.png
+       	cp -f $custdir/qt/rgb_lcd/Qt_Test        $appdir/
+        cp -f $custdir/qt/rgb_lcd/S90PDUApp      $rootdir/etc/init.d/
     else
         echo error! $RPJ not define!!!
         exit 1

+ 1 - 1
truing_control/PDU-AC_ADA_NEW_6/common/common.c

@@ -105,7 +105,7 @@ void read_config_from_eeprom(void)
 				board->con_da.row = 0;
 			}
 			board->con_da.index++;		//point next write consumer index
-			if(board->con_da.index > UINT64_MAX)
+			if(board->con_da.index >= UINT64_MAX)
 			{
 				iic_data chache1={0};
 				board->con_da.index = 0;

+ 22 - 0
truing_control/PDU-AC_ADA_NEW_6/hardware/key/key.c

@@ -1,3 +1,5 @@
+#ifndef __KEY_H_
+#define __KEY_H_
 
 
 
@@ -6,3 +8,23 @@
 
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+#endif
+
+
+
+
+
+

+ 9 - 0
truing_control/PDU-AC_ADA_NEW_6/hardware/relay/relay.c

@@ -26,6 +26,10 @@
 	#if (RelaySlaveChaNum >= 3)
 		#define RELAY_3           GPIO_PIN_10
 	#endif
+
+#if SUPPORT_4_ON_FLASH
+		#define RELAY_4           GPIO_PIN_11
+#endif
 	
 	#if (RelaySlaveChaNum >= 4)
 		#define RELAY_4           GPIO_PIN_11
@@ -102,6 +106,11 @@ void relay_init(void)
 		gpio_output_options_set(RELAY_GPIO, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, RELAY_3);
 		gpio_bit_reset(RELAY_GPIO, RELAY_3);
 	#endif
+#if SUPPORT_4_ON_FLASH
+		gpio_mode_set(RELAY_GPIO,GPIO_MODE_OUTPUT,GPIO_PUPD_NONE,RELAY_4);
+		gpio_output_options_set(RELAY_GPIO, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, RELAY_4);
+		gpio_bit_set(RELAY_GPIO, RELAY_4);	
+#endif
 	#if (RelaySlaveChaNum >=4)
 		gpio_mode_set(RELAY_GPIO,GPIO_MODE_OUTPUT,GPIO_PUPD_NONE,RELAY_4);
 		gpio_output_options_set(RELAY_GPIO, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, RELAY_4);

+ 35 - 3
truing_control/PDU-AC_ADA_NEW_6/user/board_cfg.h

@@ -56,9 +56,11 @@
 #define   PRJ_3_2                   0
 #define 	PRJ_DC_8									0
 #define   PRJ_6_NEW                 0
-#define   PRJ_3_NEW                 1
-
-
+#define   PRJ_3_NEW                 0
+#define 	PRJ_5_NEW									0
+#define 	PRJ_4_SELF_LOCK       	  0
+#define   PRJ_4_BASE                0
+#define   PRJ_1_BASE                1
 
 #if PRJ_8					
 	#define   POWER_TYPE                (POWER_AC)
@@ -94,6 +96,36 @@
 	#define   PT_SUB_COUNT              (RelaySlaveChaNum)
 	#define   SUPPORT_DETECTION         1
 	#define   SUPPORT_RELAY_REMENBER		1
+	#define   SUPPORT_4_ON_FLASH        1
+#elif PRJ_5_NEW
+	#define 	RelaySlaveChaNum 					5
+	#define 	ACSingCurrid 							1 
+	#define   SURPPORT_2_PT             0
+	#define   PT_SUB_COUNT              (RelaySlaveChaNum)
+	#define   SUPPORT_DETECTION         1
+	#define   SUPPORT_RELAY_REMENBER		1
+#elif PRJ_4_SELF_LOCK
+	#define 	RelaySlaveChaNum 					4
+	#define 	ACSingCurrid 							2 
+	#define   SURPPORT_2_PT             0
+	#define   PT_SUB_COUNT              (RelaySlaveChaNum)
+	#define   SUPPORT_DETECTION         1
+	#define   SUPPORT_RELAY_REMENBER		1
+	#define   SUPPORT_SELF_LOCK         1
+#elif PRJ_4_BASE
+	#define 	RelaySlaveChaNum 					4
+	#define 	ACSingCurrid 							2 
+	#define   SURPPORT_2_PT             0
+	#define   PT_SUB_COUNT              (RelaySlaveChaNum)
+	#define   SUPPORT_DETECTION         1
+	#define   SUPPORT_RELAY_REMENBER		1
+#elif PRJ_1_BASE              
+	#define 	RelaySlaveChaNum 					1
+	#define 	ACSingCurrid 							2 
+	#define   SURPPORT_2_PT             0
+	#define   PT_SUB_COUNT              (RelaySlaveChaNum)
+	#define   SUPPORT_DETECTION         1
+	#define   SUPPORT_RELAY_REMENBER		1
 #endif
 
 

+ 1 - 1
truing_control/PDU-AC_ADA_NEW_6/user/main.c

@@ -175,7 +175,7 @@ static void task_10s(void)
 		{
 			ac_board.con_da.row = 0;
 		}
-		if(ac_board.con_da.index > UINT64_MAX)
+		if(ac_board.con_da.index >= UINT64_MAX)
 		{
 			iic_data chache1={0};
 			ac_board.con_da.index = 0;