Browse Source

add surppot new ups

ekat-ok 3 months ago
parent
commit
f9e57ce65f

+ 2 - 1
.vscode/settings.json

@@ -56,5 +56,6 @@
         "initializer_list": "c",
         "initializer_list": "c",
         "board_bt6711_v1.h": "c",
         "board_bt6711_v1.h": "c",
         "freertos.h": "c"
         "freertos.h": "c"
-    }
+    },
+    "cmake.sourceDirectory": "/home/ebalbekova/my_project/bt-67xx_universal_hw/thirdparty/PolarSSL"
 }
 }

+ 66 - 0
modules/MegaTec/crc_calc.c

@@ -0,0 +1,66 @@
+
+#include "crc_calc.h"
+
+static const uint8_t CRC_HI[] = {
+	 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
+	 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
+	 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
+	 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
+	 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
+	 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
+	 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
+	 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
+	 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
+	 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
+	 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
+	 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
+	 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
+	 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
+	 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
+	 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
+	 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
+	 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,
+	 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
+	 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,
+	 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,
+	 0x00, 0xC1, 0x81, 0x40
+};
+
+static const uint8_t CRC_LO[] = {
+	 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7,
+	 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E,
+	 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9,
+	 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC,
+	 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3,
+	 0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32,
+	 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D,
+	 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38,
+	 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF,
+	 0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26,
+	 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1,
+	 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4,
+	 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB,
+	 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA,
+	 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5,
+	 0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0,
+	 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97,
+	 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C, 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E,
+	 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89,
+	 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C,
+	 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83,
+	 0x41, 0x81, 0x80, 0x40
+};
+
+uint16_t calc_crc16(uint8_t *data, uint16_t len) {
+	uint8_t crc_hi, crc_lo;
+	crc_hi = crc_lo = 0xff;
+	int idx;
+
+	while (len--)
+	{
+		idx = crc_lo ^ (uint8_t)*(data++);
+		crc_lo = (uint8_t)(crc_hi ^ CRC_HI[idx] );
+		crc_hi = CRC_LO[idx];
+	}
+	return ((uint16_t)crc_hi << 8) | (uint8_t)crc_lo;
+}

+ 12 - 0
modules/MegaTec/crc_calc.h

@@ -0,0 +1,12 @@
+#ifndef CRC_CALC_H_
+#define CRC_CALC_H_
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+
+uint16_t calc_crc16(uint8_t *data, uint16_t len);
+
+
+#endif

+ 119 - 18
modules/MegaTec/megatec.c

@@ -17,6 +17,7 @@
 #include "parameters.h"
 #include "parameters.h"
 #include "hal.h"
 #include "hal.h"
 #include "rtc.h"
 #include "rtc.h"
+#include "crc_calc.h"
 #ifdef PRINTF_STDLIB
 #ifdef PRINTF_STDLIB
 #include <stdio.h>
 #include <stdio.h>
 #endif
 #endif
@@ -38,6 +39,7 @@ TimerHandle_t AutoTestTimer;
 extern SETTINGS_t sSettings;
 extern SETTINGS_t sSettings;
 
 
 #define UPS_PDU_MAX_LEN 80
 #define UPS_PDU_MAX_LEN 80
+#define UPS_PDU_MIN_LEN 5
 
 
 float TimeParamFloat = 0;
 float TimeParamFloat = 0;
 uint16_t TimeParam = 0;
 uint16_t TimeParam = 0;
@@ -158,6 +160,46 @@ float power_load_average(void)
 {
 {
     return (Pload_sum / Period_testing);
     return (Pload_sum / Period_testing);
 }
 }
+
+bool ups_additional_prtcl_rx_pdu(void)
+{
+    int c = 0;
+    uint8_t cnt_answer = 0;
+
+    ups_pdu.len = 0;
+
+    /* Check empty responce (UART has no data) */
+    if ((c = ups_getchar(1000)) < 0) {
+        DBG printf("no data\r\n");
+        return false;
+    } else {
+        ups_pdu.len = 0;
+        ups_pdu.data[ups_pdu.len++] = c;
+    }
+    while ((ups_pdu.len < UPS_PDU_MAX_LEN) && ((c = ups_getchar(10)) >= 0)) {
+        ups_pdu.data[ups_pdu.len++] = c;
+    }
+
+    DBG printf("rx %d bytes from 0x%X\r\n", ups_pdu.len, ups_pdu.data[0]);
+    if (ups_pdu.len < UPS_PDU_MIN_LEN ||
+        ups_pdu.data[0] != 0x01) {
+        return false;
+    }
+#if 1
+    uint16_t crc = (uint16_t)(ups_pdu.data[ups_pdu.len - 2] | ((uint16_t)(ups_pdu.data[ups_pdu.len - 1]) << 8));
+    if (crc != calc_crc16(ups_pdu.data, ups_pdu.len - 2)) {
+        DBG {
+            printf("bad crc:");
+            for (uint16_t i = 0; i < ups_pdu.len; i++) {
+                printf(" 0x%X", ups_pdu.data[i]);
+            }
+            printf("\r\n");
+        }
+        return false;
+    }
+#endif
+    return true;
+}
  
  
 
 
 void send_MegaTec_cmd(cmdMegaTecEnums_t command)
 void send_MegaTec_cmd(cmdMegaTecEnums_t command)
@@ -372,12 +414,20 @@ void ups_status_response(char *data)
     if(UPS.Status & 0x04) {
     if(UPS.Status & 0x04) {
         UPS.SOC_prev = UPS.SOC;
         UPS.SOC_prev = UPS.SOC;
     }
     }
-    if (UPS.Vcell_curr < 7) {
-        UPS.SOC = round(100 * (UPS.Vcell_curr - sSettings.UPS_Setting.Ucellmin) / (sSettings.UPS_Setting.Ucellmax -
-                  sSettings.UPS_Setting.Ucellmin));
-    } else {
-        UPS.SOC = round(100 * (UPS.Vcell_curr / AKB_NUM_CELL - sSettings.UPS_Setting.Ucellmin) /
-                  (sSettings.UPS_Setting.Ucellmax - sSettings.UPS_Setting.Ucellmin));
+#ifdef HARDWARE_BT6721
+    if(UPS.Mode == 'B') {
+        UPS.SOC = round(100 * (UPS.Vcell_curr / AKB_NUM_CELL - 1.96) /
+                    (2.13 - 1.96));
+    } else
+#endif    
+    {
+        if (UPS.Vcell_curr < 7) {
+            UPS.SOC = round(100 * (UPS.Vcell_curr - sSettings.UPS_Setting.Ucellmin) / (sSettings.UPS_Setting.Ucellmax -
+                    sSettings.UPS_Setting.Ucellmin));
+        } else {
+            UPS.SOC = round(100 * (UPS.Vcell_curr / AKB_NUM_CELL - sSettings.UPS_Setting.Ucellmin) /
+                    (sSettings.UPS_Setting.Ucellmax - sSettings.UPS_Setting.Ucellmin));
+        }
     }
     }
  //   }
  //   }
 
 
@@ -497,6 +547,15 @@ void ups_general_status_response(char *data)
 */
 */
 }
 }
 
 
+void ups_specific_response_sn(uint8_t *data)
+{
+    uint8_t len = data[4] - 3;
+    if(len >= sizeof(UPS.serial)) {
+        len = sizeof(UPS.serial) - 1;
+    }
+    strncpy(UPS.serial, &data[8], len);
+}
+
 void ups_info_response(char *data)
 void ups_info_response(char *data)
 {
 {
     uint8_t i = 0, j = 0;
     uint8_t i = 0, j = 0;
@@ -540,10 +599,32 @@ void ups_info_response(char *data)
         }
         }
     }
     }
     data += (KSTAR_MODEL_LENGTH + 1);
     data += (KSTAR_MODEL_LENGTH + 1);
-    strncpy(UPS.serial, data, 8);
-    data += 8;
+    if (UPS.serial[0] == 0 && data[0] != ' '){
+        strncpy(UPS.serial, data, 8);
+        data += 8;
+    } else {
+        while (*data == ' '){
+            data += 1;       
+        }
+    }
+    
+    memset(value, 0, sizeof(value));
+    j = 0;
+    while (*data != '\r'){
+        value[j] = *data;
+        j++;
+            data += 1;       
+    }
+
+    if( (sSettings.UPS_Setting.type_ups == ups_kestar || sSettings.UPS_Setting.type_ups == ups_offline) && strlen(UPS.serial) == 0){
+        uint8_t specific_req_sn[7] = {0x01, 0x06, 0x95, 0x00, 0x0f, 0x49, 0x60};
+        ups_send_block(specific_req_sn, 7);
+        if (ups_additional_prtcl_rx_pdu()) {
+            ups_specific_response_sn(ups_pdu.data);
+        }
+    }
 
 
-    strncpy(UPS.vertion, data, 2);
+    strncpy(UPS.vertion, value, (j+1));
     SNMP_SetObjDescr();
     SNMP_SetObjDescr();
 }
 }
 
 
@@ -1093,6 +1174,8 @@ void ups_temperature_response(char *data)
 }
 }
 
 
 
 
+
+
 void ups_megatec_process_pdu(cmdMegaTecEnums_t command)
 void ups_megatec_process_pdu(cmdMegaTecEnums_t command)
 {
 {
     switch (command) {
     switch (command) {
@@ -1168,6 +1251,8 @@ int ups_metac_service_pdu(cmdMegaTecEnums_t command)
         megatec_send = false;
         megatec_send = false;
         if (command == ups_shutdown) {//sSettings.UPS_Setting.type_ups == ups_offline && 
         if (command == ups_shutdown) {//sSettings.UPS_Setting.type_ups == ups_offline && 
             TimeParam2 = 1;
             TimeParam2 = 1;
+            xTimerChangePeriod(UPSRestoreTimer, (TimeParamFloat + 0.1)*60*configTICK_RATE_HZ, 0);
+            xTimerStart(UPSRestoreTimer, 0);
             send_MegaTec_cmd(ups_shutdown_restore);
             send_MegaTec_cmd(ups_shutdown_restore);
         } else {
         } else {
             if((UPS.Status >> 2) & 0x01) {
             if((UPS.Status >> 2) & 0x01) {
@@ -1232,17 +1317,25 @@ int ups_metac_service_pdu(cmdMegaTecEnums_t command)
                 init_var_for_testing();
                 init_var_for_testing();
                 return 1;
                 return 1;
             }
             }
+
+            if  ((((UPS.Status >> 1) & 0x01) != ((UPS_Status_prev >> 1) & 0x01))
+             && ((UPS.Status >> 1) & 0x01)) {
+                return 1;
+            }
         }
         }
 
 
         megatec_send = true;
         megatec_send = true;
     }
     }
+    if (command == ups_shutdown) {
+        return 1;
+    }
     return -1;
     return -1;
 }
 }
 
 
 void kstar_mode(void)
 void kstar_mode(void)
 {
 {
     uint8_t mode = UPS.Mode;
     uint8_t mode = UPS.Mode;
-#if 0    
+#if 1    
     if((UPS.Status >> 4) & 0x01) {
     if((UPS.Status >> 4) & 0x01) {
         UPS.Mode = 'F';
         UPS.Mode = 'F';
     } else if(!((UPS.Status >> 4) & 0x01) && UPS.VAC_out == 0) {
     } else if(!((UPS.Status >> 4) & 0x01) && UPS.VAC_out == 0) {
@@ -1257,7 +1350,7 @@ void kstar_mode(void)
         UPS.Mode = 'T';
         UPS.Mode = 'T';
     }
     }
 #endif
 #endif
-
+#if 0
     if((UPS.Status >> 4) & 0x01) {
     if((UPS.Status >> 4) & 0x01) {
         UPS.Mode = 'F';
         UPS.Mode = 'F';
     } else if(!((UPS.Status >> 4) & 0x01) && UPS.VAC_out == 0) {
     } else if(!((UPS.Status >> 4) & 0x01) && UPS.VAC_out == 0) {
@@ -1269,7 +1362,7 @@ void kstar_mode(void)
     } else if((UPS.Status >> 2) & 0x01) {
     } else if((UPS.Status >> 2) & 0x01) {
         UPS.Mode = 'T';
         UPS.Mode = 'T';
     }
     }
-
+#endif
 
 
     if (UPS.Mode != mode) {
     if (UPS.Mode != mode) {
 #ifdef UPS_MODE_MONITOR
 #ifdef UPS_MODE_MONITOR
@@ -1288,8 +1381,7 @@ void kstar_mode(void)
 //void request_task(void)
 //void request_task(void)
 void request_task(void *params)
 void request_task(void *params)
 {
 {
-    //uint8_t kestar_req[4] = { ups_status_req, ups_remain_time_reg, ups_info, ups_kstar_status};
-    uint8_t kestar_req[1] = { ups_status_req};
+    uint8_t kestar_req[4] = { ups_status_req, ups_remain_time_reg, ups_info, ups_kstar_status};
     uint8_t voltronic_req[9] = {ups_temperature, ups_status_req, ups_akb_info, ups_model_req, ups_mode_req, ups_version_req, ups_version2_req, ups_serial_req, ups_warning_status};//
     uint8_t voltronic_req[9] = {ups_temperature, ups_status_req, ups_akb_info, ups_model_req, ups_mode_req, ups_version_req, ups_version2_req, ups_serial_req, ups_warning_status};//
     uint8_t num_req = 0;
     uint8_t num_req = 0;
     uint8_t *req;
     uint8_t *req;
@@ -1405,6 +1497,13 @@ void request_task(void *params)
                         megatec_send = true;
                         megatec_send = true;
                     }
                     }
                 }
                 }
+            } else if( sSettings.UPS_Setting.type_ups == ups_kestar || sSettings.UPS_Setting.type_ups == ups_offline){
+                uint8_t specific_req_sn[7] = {0x01, 0x06, 0x95, 0x00, 0x0f, 0x49, 0x60};
+                vTaskDelay(1000);
+                ups_send_block(specific_req_sn, 7);
+                if (ups_additional_prtcl_rx_pdu()) {
+                    ups_specific_response_sn(ups_pdu.data);
+                }
             }
             }
 #ifdef CHECK_LOAD_ENABLE
 #ifdef CHECK_LOAD_ENABLE
             xTimerStart(AutoTestTimer, 0);
             xTimerStart(AutoTestTimer, 0);
@@ -1430,12 +1529,13 @@ void request_task(void *params)
             }
             }
         }
         }
 
 
+        
+
         // printf("UPS.Flag_Present: %u\r\n", (uint8_t)UPS.Flag_Present);
         // printf("UPS.Flag_Present: %u\r\n", (uint8_t)UPS.Flag_Present);
         // printf("UPS_Setting.type_ups: %u\r\n", sSettings.UPS_Setting.type_ups);
         // printf("UPS_Setting.type_ups: %u\r\n", sSettings.UPS_Setting.type_ups);
-        kstar_mode();
 
 
 
 
-        if(UPS.Flag_Present && (sSettings.UPS_Setting.type_ups == ups_kestar 
+        if(UPS.Present == UPS_CONNECTED && (sSettings.UPS_Setting.type_ups == ups_kestar 
             || sSettings.UPS_Setting.type_ups == ups_offline)) {
             || sSettings.UPS_Setting.type_ups == ups_offline)) {
                 kstar_mode();
                 kstar_mode();
         }
         }
@@ -1483,9 +1583,10 @@ void UPSRestoreCallback(TimerHandle_t pxTimer)
         memset(ups_pdu.data, 0, UPS_PDU_MAX_LEN);
         memset(ups_pdu.data, 0, UPS_PDU_MAX_LEN);
         megatec_send = false;
         megatec_send = false;
         //UPS.Flag_Present = false;
         //UPS.Flag_Present = false;
-        send_MegaTec_cmd(ups_remote_turn_on);
+        //send_MegaTec_cmd(ups_remote_turn_on);
+        send_MegaTec_cmd(ups_cancel_shut_down);
         if (ups_megatec_rx_pdu()) {
         if (ups_megatec_rx_pdu()) {
-            ups_megatec_process_pdu(ups_remote_turn_on);
+            //ups_megatec_process_pdu(ups_remote_turn_on);
         }
         }
         megatec_send = true;
         megatec_send = true;
     }
     }

+ 1 - 1
modules/settings_api_bt6711.c

@@ -9,7 +9,7 @@
  * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
  * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
  *******************************************************************************
  *******************************************************************************
  */
  */
-#if HARDWARE_BT6711 || HARDWARE_BT6711_V1 || HARDWARE_BT6721
+#if HARDWARE_BT6711 || HARDWARE_BT6711_V1
 #include "stm32f4xx.h"  
 #include "stm32f4xx.h"  
 #include "settings_api.h"
 #include "settings_api.h"
 #include "common_config.h"
 #include "common_config.h"

+ 316 - 0
modules/settings_api_bt6721.c

@@ -0,0 +1,316 @@
+/********************************* (C) ROTEK ***********************************
+ * @module  settings_api
+ * @file    settings_api.c
+ * @version 1.0.0
+ * @date    XX.XX.XXXX
+ * $brief   Settings
+ *******************************************************************************
+ * @history     Version  Author         Comment
+ * XX.XX.XXXX   1.0.0    Telenkov D.A.  First release.
+ *******************************************************************************
+ */
+#if HARDWARE_BT6721
+#include "stm32f4xx.h"  
+#include "settings_api.h"
+#include "common_config.h"
+#ifndef BT6702_SERVICE
+#include "snmp_api.h"
+#include "trap_api.h"
+#include "log.h"
+#endif
+#include "sys_api.h"
+
+#include "main.h"
+#include "parameters.h"
+
+#include <string.h>
+#include <stdlib.h>
+#ifdef PRINTF_STDLIB
+#include <stdio.h>
+#endif
+#ifdef PRINTF_CUSTOM
+#include "tinystdio.h"
+#endif
+
+//#define DBG if(0)
+
+const char* logsStrShortRu[] =
+{
+	  "Перезагрузка контроллера",
+    "Сброс настроек",
+    "Обновление ПО",
+    "Включение",
+    "Смена пароля",
+    "Сохранение настроек",
+    "Авторизация (Telnet)",
+    "Авторизация",
+    "Режим работы ИБП",
+    "Тест ИБП",
+    "Откл. нагрузки ИБП",
+    "Низкое вых. напряжение",
+    "Высокое вых. напряжение",
+    "Высокая температура",
+    "Низкая температура",
+    "Авария вх. напряжения",
+    "Низкий заряд АКБ",
+    "Авария нагрузки",
+    "Авария связи с ИБП",
+    "Авария отключения АКБ",
+    "Ёмкость АКБ",
+    "Ош. подкл. вх. напряжения",
+    "Срабатывание EPO",
+};
+
+const char* name_traps[] =
+{
+  "",
+	"Начало обновл. ПО",
+  "Успешное обновл. ПО",
+  "Сброс настроек",
+  "Перезагрузка",
+  "Режим работы ИБП",
+  "Норм. темп. АКБ по верх. границы",
+  "Авария темп. АКБ по верх. границы",
+  "Норм. темп. АКБ по ниж. границы",
+  "Авария темп. АКБ по ниж. границы",
+  "Авария на линии",
+  "Нормализация линии",
+  "Авария вых. напряжения по ниж. границы",
+  "Норм. вых. напряжения по ниж. границы",
+  "Авария вых. напряжения по верх. границы",
+  "Норм. вых. напряжения по верх. границы",
+  "Низкий заряд АКБ",
+  "Тест АКБ запущен",
+  "Тест АКБ завершен",
+  "Отказ АКБ",
+  "АКБ в норме",
+  "Нормализация заряда АКБ",
+  "Отключение АКБ",
+  "Подключение АКБ",
+  "Авария нагрузки",
+  "Нагрузка в норме",
+  "Авария соединения с ИБП",
+  "Норм. соединения с ИБП",
+  "Ош. подкл. вх. напряжения",
+  "Норм. подкл. вх. напряжения",
+  "Срабатывание EPO",
+  "EPO норма",
+};
+
+/**
+  * @brief  Установить параметры SNMP по умолчанию
+  */
+void SETTINGS_SetSnmpDef(void)
+{
+  strcpy(sSettings.sSnmp.sysDesc.description, "");
+  sSettings.sSnmp.sysDesc.len = 0;
+  strcpy(sSettings.sSnmp.readCommunity, "public");
+  strcpy(sSettings.sSnmp.writeCommunity, "public");
+  strcpy(sSettings.sSnmp.sysContact.contact, "");
+  sSettings.sSnmp.sysContact.len = 0;
+  strcpy(sSettings.sSnmp.sysName.name, "");
+  sSettings.sSnmp.sysName.len = 0;
+  strcpy(sSettings.sSnmp.sysLocation.location, "");
+  sSettings.sSnmp.sysLocation.len = 0;
+  strcpy(sSettings.sSnmp.managerIP, "0.0.0.0");
+  strcpy(sSettings.sSnmp.managerIP2, "0.0.0.0");
+  strcpy(sSettings.sSnmp.managerIP3, "0.0.0.0");
+  strcpy(sSettings.sSnmp.managerIP4, "0.0.0.0");
+  strcpy(sSettings.sSnmp.managerIP5, "0.0.0.0");
+}
+
+/**
+  * @brief  Настройки ИБП по умолчанию
+  */
+void SETTINGS_SetUPSSettingsDef(void)
+{
+  sSettings.UPS_Setting.Ucellmin = 1.89;
+  sSettings.UPS_Setting.Ucellmax = 2.36;
+  sSettings.UPS_Setting.Uakb = 12;
+  sSettings.UPS_Setting.common_capacity = 15;
+  sSettings.UPS_Setting.ups_power = 500;
+  sSettings.UPS_Setting.set_data = 0;
+  sSettings.UPS_Setting.life_time = 5;
+  sSettings.UPS_Setting.type_ups = ups_kestar;
+}
+
+/**
+  * @brief  Настройки серийного номера ИБП по умолчанию
+  */
+void SETTINGS_SetUPSSerialSettingsDef(void)
+{
+  sSettings.UPS_Setting.serial = 0;
+}
+
+/**
+  * @brief  Установить наcтройки менеджера Аварий по умолчанию
+  */
+void SETTINGS_SetAlarmManagerDef(void)
+{
+	sSettings.sAlarmManager.load_range.high = 70.0;
+	sSettings.sAlarmManager.load_range.low = 0;
+	sSettings.sAlarmManager.load_range.hyst = 1;
+
+  sSettings.sAlarmManager.ac_input_range.high = 250.0;
+	sSettings.sAlarmManager.ac_input_range.low = 150.0;
+	sSettings.sAlarmManager.ac_input_range.hyst = 20.0;
+
+	sSettings.sAlarmManager.ac_output_range.high = 250.0;
+	sSettings.sAlarmManager.ac_output_range.low = 150.0;
+	sSettings.sAlarmManager.ac_output_range.hyst = 20.0;
+
+	sSettings.sAlarmManager.Temprature_range.high = 70.0;
+	sSettings.sAlarmManager.Temprature_range.low = -40.0;
+	sSettings.sAlarmManager.Temprature_range.hyst = 1;
+}
+
+/**
+  * @brief  Установить значение сервисных настроек по умолчанию
+  */
+void SETTINGS_SetServiceDef(void)
+{
+    uint8_t user_id;
+
+    for (user_id = 0; user_id < MAX_WEB_USERS; user_id++) {
+        switch (user_id) {
+        /* First users in the system is always ADMIN.
+         * Others are USER */
+        case 0:
+            sSettings.sAuth[user_id].level = ADMIN;
+            strcpy(sSettings.sAuth[user_id].login, "admin");
+            strcpy(sSettings.sAuth[user_id].password, "12345");
+            break;
+        case 1:
+        default:
+        	sSettings.sAuth[user_id].level = USER;
+            strcpy(sSettings.sAuth[user_id].login, "user");
+            strcpy(sSettings.sAuth[user_id].password, "1234");
+            break;
+        }
+    }
+}
+
+/**
+  * @brief  Установить параметры SNTP по умолчанию
+  */
+void SETTINGS_SetSntpDef(void)
+{
+  sSettings.sSNTP.sntpEnable = true;
+  strcpy(sSettings.sSNTP.ip, "88.147.254.235");
+  sSettings.sSNTP.timeZone = 3.0;
+  strcpy(sSettings.sSNTP.data, "none");
+}
+
+/**
+  * @brief  Установить параметры настроек реле по умолчанию
+  */
+void SETTINGS_SetRelaysDef(void)
+{
+
+}
+
+/**
+  * @brief  Установить параметры настроек сухих контактов по умолчанию
+  */
+void SETTINGS_SetDINSDef(void)
+{
+
+}
+
+/**
+  * @brief  Установить параметры RADIUS по умолчанию
+  */
+void SETTINGS_SetRADIUSDef(void)
+{
+  sSettings.sRADIUS.Auth_enable = true;
+  //sSettings.sRADIUS.RDSEnable = false;
+  // todo вернуть на значение false
+  sSettings.sRADIUS.RDSEnable = false;
+  strcpy(sSettings.sRADIUS.ServerIP, "0.0.0.0");
+  //strcpy(sSettings.sRADIUS.ServerIP, "192.168.14.234");
+  sSettings.sRADIUS.port = 1812;
+  sSettings.sRADIUS.key_access = 123;
+  strcpy(sSettings.sRADIUS.rds_password, "R02ekR4MP2");
+}
+
+/**
+  * @brief  Установить параметры сертификата сервера по умолчанию
+  */
+void SETTINGS_SetSSLcrtDef(void){
+
+}
+
+/**
+  * @brief  Установить параметры Telnet
+  */
+void SETTINGS_SetTelnetDef(void){
+	sSettings.sTelnet.TelnetEnable = true;
+	sSettings.sTelnet.port = 23;
+}
+
+/**
+  * @brief  Установить параметры SSH
+  */
+void SETTINGS_SetSSHDef(void){
+
+}
+
+/**
+  * @brief  Установить параметры списка доверительных хостов
+  */
+void SETTINGS_SetWhiteListDef(void){
+	for(uint8_t i = 0; i < MAX_WHITE_LIST; i++){
+		strcpy(sSettings.sWhiteListTemp[i].ip_range, "");
+		SetWhiteListSTR(sSettings.sWhiteListTemp[i].ip_range, i);
+		strcpy(sSettings.sWhiteList[i].ip_range, sSettings.sWhiteListTemp[i].ip_range);
+		sSettings.sWhiteList[i].ip = sSettings.sWhiteListTemp[i].ip;
+		sSettings.sWhiteList[i].mask = sSettings.sWhiteListTemp[i].mask;
+	}
+}
+
+/**
+  * @brief  Установить параметры разрешения уведомлений по умолчанию
+  */
+void SETTINGS_SetFlagNotificationDef(void)
+{
+    uint8_t i;
+
+    for(i = 0; i < ALL_TRAPS; i++ ) {
+        sSettings.sFlagNotification[i] = 1;
+    }
+}
+
+void SETTINGS_SetFTPUpdateDef(void)
+{
+  IP4_ADDR(&sSettings.sFTPUpdate.server_ip, 192,168,0,253);
+  sSettings.sFTPUpdate.server_port = 21;
+  strcpy(&sSettings.sFTPUpdate.remote_path, "BT_6711xx.bin");
+  strcpy(&sSettings.sFTPUpdate.user, "anonymous");
+  strcpy(&sSettings.sFTPUpdate.pass, "guest");
+}
+
+void SETTINGS_SetSyslogDef(void)
+{
+  sSettings.sSyslog.enabled = false;
+  IP4_ADDR(&sSettings.sSyslog.server_ip, 192,168,0,253);
+  sSettings.sSyslog.server_port = 514;
+}
+
+/**
+  * @brief  Установить значение настроек прозрачного порта по умолчанию
+  */
+void SETTINGS_SetPortGwDef(void)
+{
+
+}
+
+/**
+  * @brief  Установить параметры датчиков температуры
+  */
+void SETTINGS_SetTempControlDef(void)
+{
+
+}
+
+#endif
+/********************************* (C) ROTEK **********************************/