| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996 | 
							- /*
 
-  * private_mib_bt6709.c
 
-  *
 
-  *  Created on: 03.10.2018
 
-  *      Author: balbekova
 
-  */
 
- #if defined HARDWARE_BT6711
 
- #include "stm32f4xx.h"
 
- #include "private_mib.h"
 
- #include "parameters.h"
 
- #include "settings_api.h"
 
- #include "log.h"
 
- #include "megatec.h"
 
- #include "control_symbol.h"
 
- #include "sntp_api.h"
 
- #include "web_params_api.h"
 
- #include "hal.h"
 
- #include "FreeRTOS.h"
 
- #include "task.h"
 
- #include <ctype.h>
 
- #ifdef PRINTF_STDLIB
 
- #include <stdio.h>
 
- #endif
 
- #ifdef PRINTF_CUSTOM
 
- #include "tinystdio.h"
 
- #endif
 
- #include "lwip/apps/snmp_scalar.h"
 
- #include "lwip/apps/snmp.h"
 
- //#include "snmp_core.h"
 
- #define MUL100          100
 
- #define MUL10           10
 
- extern struct snmp_mib mib2;
 
- /**
 
-   * @brief  Общая структура настроек
 
-   */
 
- extern SETTINGS_t sSettings;
 
- static s16_t signal_get_value(struct snmp_node_instance *instance, void *value);
 
- static snmp_err_t signal_set_value(struct snmp_node_instance *instance, u16_t len, void *value);
 
- static snmp_err_t signal_set_test(struct snmp_node_instance *instance, u16_t len, void *value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.48  */
 
- static const struct snmp_scalar_node signal48 = SNMP_SCALAR_CREATE_NODE_READONLY(48, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.47  */
 
- static const struct snmp_scalar_node signal47 = SNMP_SCALAR_CREATE_NODE_READONLY(47, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.46  */
 
- static const struct snmp_scalar_node signal46 = SNMP_SCALAR_CREATE_NODE_READONLY(46, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.45  */
 
- static const struct snmp_scalar_node signal45 = SNMP_SCALAR_CREATE_NODE_READONLY(45, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.44  */
 
- static const struct snmp_scalar_node signal44 = SNMP_SCALAR_CREATE_NODE_READONLY(44, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.43  */
 
- static const struct snmp_scalar_node signal43 = SNMP_SCALAR_CREATE_NODE(43, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.42  */
 
- static const struct snmp_scalar_node signal42 = SNMP_SCALAR_CREATE_NODE(42, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.41  */
 
- static const struct snmp_scalar_node signal41 = SNMP_SCALAR_CREATE_NODE(41, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.40  */
 
- static const struct snmp_scalar_node signal40 = SNMP_SCALAR_CREATE_NODE(40, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.39  */
 
- static const struct snmp_scalar_node signal39 = SNMP_SCALAR_CREATE_NODE(39, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.38  */
 
- static const struct snmp_scalar_node signal38 = SNMP_SCALAR_CREATE_NODE(38, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.37  */
 
- static const struct snmp_scalar_node signal37 = SNMP_SCALAR_CREATE_NODE(37, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.36  */
 
- static const struct snmp_scalar_node signal36 = SNMP_SCALAR_CREATE_NODE(36, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.35  */
 
- static const struct snmp_scalar_node signal35 = SNMP_SCALAR_CREATE_NODE(35, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.10.1.34  */
 
- static const struct snmp_scalar_node signal34 = SNMP_SCALAR_CREATE_NODE(34, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.33  */
 
- static const struct snmp_scalar_node signal33 = SNMP_SCALAR_CREATE_NODE(33, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.32  */
 
- static const struct snmp_scalar_node signal32 = SNMP_SCALAR_CREATE_NODE(32, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.31  */
 
- static const struct snmp_scalar_node signal31 = SNMP_SCALAR_CREATE_NODE(31, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.30  */
 
- static const struct snmp_scalar_node signal30 = SNMP_SCALAR_CREATE_NODE(30, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.29  */
 
- static const struct snmp_scalar_node signal29 = SNMP_SCALAR_CREATE_NODE(29, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.28  */
 
- static const struct snmp_scalar_node signal28 = SNMP_SCALAR_CREATE_NODE(28, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.27  */
 
- static const struct snmp_scalar_node signal27 = SNMP_SCALAR_CREATE_NODE_READONLY(27, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.26  */
 
- static const struct snmp_scalar_node signal26 = SNMP_SCALAR_CREATE_NODE_READONLY(26, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.25  */
 
- static const struct snmp_scalar_node signal25 = SNMP_SCALAR_CREATE_NODE_READONLY(25, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.24  */
 
- static const struct snmp_scalar_node signal24 = SNMP_SCALAR_CREATE_NODE_READONLY(24, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.23  */
 
- static const struct snmp_scalar_node signal23 = SNMP_SCALAR_CREATE_NODE_READONLY(23, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.22  */
 
- static const struct snmp_scalar_node signal22 = SNMP_SCALAR_CREATE_NODE(22, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.21  */
 
- static const struct snmp_scalar_node signal21 = SNMP_SCALAR_CREATE_NODE(21, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.20  */
 
- static const struct snmp_scalar_node signal20 = SNMP_SCALAR_CREATE_NODE(20, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.19  */
 
- static const struct snmp_scalar_node signal19 = SNMP_SCALAR_CREATE_NODE(19, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.18  */
 
- static const struct snmp_scalar_node signal18 = SNMP_SCALAR_CREATE_NODE(18, SNMP_NODE_INSTANCE_READ_WRITE,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, signal_get_value, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.17  */
 
- static const struct snmp_scalar_node signal17 = SNMP_SCALAR_CREATE_NODE_READONLY(17, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.16  */
 
- static const struct snmp_scalar_node signal16 = SNMP_SCALAR_CREATE_NODE_READONLY(16, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.15  */
 
- static const struct snmp_scalar_node signal15 = SNMP_SCALAR_CREATE_NODE_READONLY(15, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.14  */
 
- static const struct snmp_scalar_node signal14 = SNMP_SCALAR_CREATE_NODE_READONLY(14, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.13  */
 
- static const struct snmp_scalar_node signal13 = SNMP_SCALAR_CREATE_NODE_READONLY(13, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.12  */
 
- static const struct snmp_scalar_node signal12 = SNMP_SCALAR_CREATE_NODE_READONLY(12, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.11  */
 
- static const struct snmp_scalar_node signal11 = SNMP_SCALAR_CREATE_NODE_READONLY(11, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.10  */
 
- static const struct snmp_scalar_node signal10 = SNMP_SCALAR_CREATE_NODE_READONLY(10, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.9  */
 
- static const struct snmp_scalar_node signal9 = SNMP_SCALAR_CREATE_NODE_READONLY(9, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.8  */
 
- static const struct snmp_scalar_node signal8 = SNMP_SCALAR_CREATE_NODE(8, SNMP_NODE_INSTANCE_WRITE_ONLY,
 
-         SNMP_ASN1_TYPE_OCTET_STRING, NULL, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.7  */
 
- static const struct snmp_scalar_node signal7 = SNMP_SCALAR_CREATE_NODE(7, SNMP_NODE_INSTANCE_WRITE_ONLY,
 
-         SNMP_ASN1_TYPE_INTEGER, NULL, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.6  */
 
- static const struct snmp_scalar_node signal6 = SNMP_SCALAR_CREATE_NODE_READONLY(6, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.5  */
 
- static const struct snmp_scalar_node signal5 = SNMP_SCALAR_CREATE_NODE_READONLY(5, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.4  */
 
- static const struct snmp_scalar_node signal4 = SNMP_SCALAR_CREATE_NODE_READONLY(4, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.3  */
 
- static const struct snmp_scalar_node signal3 = SNMP_SCALAR_CREATE_NODE(3, SNMP_NODE_INSTANCE_WRITE_ONLY,
 
-         SNMP_ASN1_TYPE_INTEGER, NULL, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.2  */
 
- static const struct snmp_scalar_node signal2 = SNMP_SCALAR_CREATE_NODE(2, SNMP_NODE_INSTANCE_WRITE_ONLY,
 
-         SNMP_ASN1_TYPE_INTEGER, NULL, signal_set_test, signal_set_value);
 
- /* signal .1.3.6.1.4.1.41752.911.11.1.1  */
 
- static const struct snmp_scalar_node signal1 = SNMP_SCALAR_CREATE_NODE_READONLY(1, SNMP_ASN1_TYPE_OCTET_STRING,
 
-         signal_get_value);
 
- // signals .1.3.6.1.4.1.41752.911.11.1
 
- static const struct snmp_node *const signals_nodes[] = {
 
-     &signal1.node.node,
 
-     &signal2.node.node,
 
-     &signal3.node.node,
 
-     &signal4.node.node,
 
-     &signal5.node.node,
 
-     &signal6.node.node,
 
-     &signal7.node.node,
 
-     &signal8.node.node,
 
-     &signal9.node.node,
 
-     &signal10.node.node,
 
-     &signal11.node.node,
 
-     &signal12.node.node,
 
-     &signal13.node.node,
 
-     &signal14.node.node,
 
-     &signal15.node.node,
 
-     &signal16.node.node,
 
-     &signal17.node.node,
 
-     &signal18.node.node,
 
-     &signal19.node.node,
 
-     &signal20.node.node,
 
-     &signal21.node.node,
 
-     &signal22.node.node,
 
-     &signal23.node.node,
 
-     &signal24.node.node,
 
-     &signal25.node.node,
 
-     &signal26.node.node,
 
-     &signal27.node.node,
 
-     &signal28.node.node,
 
-     &signal29.node.node,
 
-     &signal30.node.node,
 
-     &signal31.node.node,
 
-     &signal32.node.node,
 
-     &signal33.node.node,
 
-     &signal34.node.node,
 
-     &signal35.node.node,
 
-     &signal36.node.node,
 
-     &signal37.node.node,
 
-     &signal38.node.node,
 
-     &signal39.node.node,
 
-     &signal40.node.node,
 
-     &signal41.node.node,
 
-     &signal42.node.node,
 
-     &signal43.node.node,
 
-     &signal44.node.node,
 
-     &signal45.node.node,
 
-     &signal46.node.node,
 
-     &signal47.node.node,
 
-     &signal48.node.node,
 
- };
 
- static const struct snmp_tree_node signals_node = SNMP_CREATE_TREE_NODE(1, signals_nodes);
 
- // bt_6703 .1.3.6.1.4.1.41752.911.11
 
- static const struct snmp_node *const bt6711_nodes[] = {
 
-     &signals_node.node
 
- };
 
- static const struct snmp_tree_node bt6711_node = SNMP_CREATE_TREE_NODE(11, bt6711_nodes);
 
- // swt .1.3.6.1.4.1.41752.911
 
- static const struct snmp_node *const swt_nodes[] = {
 
-     &bt6711_node.node
 
- };
 
- static const struct snmp_tree_node swt_node = SNMP_CREATE_TREE_NODE(911, swt_nodes);
 
- // rotek .1.3.6.1.4.1.41752
 
- static const struct snmp_node *const rotek_nodes[] = {
 
-     &swt_node.node
 
- };
 
- static const struct snmp_tree_node rotek_node = SNMP_CREATE_TREE_NODE(41752, rotek_nodes);
 
- // enterprises .1.3.6.1.4.1
 
- static const struct snmp_node *const enterprises_nodes[] = {
 
-     &rotek_node.node
 
- };
 
- static const struct snmp_tree_node enterprises_node = SNMP_CREATE_TREE_NODE(1, enterprises_nodes);
 
- // private .1.3.6.1.4
 
- static const struct snmp_node *const private_nodes[] = {
 
-     &enterprises_node.node
 
- };
 
- static const struct snmp_tree_node private_root = SNMP_CREATE_TREE_NODE(0, private_nodes);
 
- static const u32_t prvmib_base_oid[] = { 1, 3, 6, 1, 4 };
 
- static const struct snmp_mib private_mib = SNMP_MIB_CREATE(prvmib_base_oid, &private_root.node);
 
- void lwip_privmib_init(void)
 
- {
 
-     static const struct snmp_mib *my_snmp_mibs[] = {&mib2, &private_mib};
 
-     snmp_set_mibs(my_snmp_mibs, LWIP_ARRAYSIZE(my_snmp_mibs));
 
- }
 
- uint32_t check_netsettings(char *addr, uint8_t len)
 
- {
 
-     uint32_t val = 0;
 
-     uint8_t i, j;
 
-     uint8_t cnt_dot = 0;
 
-     uint8_t digit = 0;
 
-     uint8_t c = *addr;
 
-     for (j = 0; j <= len; j ++) {
 
-         if (isdigit(c)) {
 
-             val = (val * 10) + (int)(c - '0');
 
-         } else if (c == '.' || c == 0) {
 
-             if (val > 0xff) {
 
-                 return 0;
 
-             }
 
-             cnt_dot ++;
 
-             val = 0;
 
-         } else {
 
-             return 0;
 
-         }
 
-         c = *++addr;
 
-     }
 
-     if (cnt_dot != 4) {
 
-         return 0;
 
-     }
 
-     return 1;
 
- }
 
- static s16_t signal_get_value(struct snmp_node_instance *instance, void *value)
 
- {
 
-     u8_t *paramStr = (u8_t *)value;
 
-     s32_t *paramInt = (u8_t*)value;
 
-     u8_t paramLength = 0;
 
-     float val = 0;
 
-     int32_t int_val = 0;
 
-     u32_t oid = instance->node->oid; // id сигнала
 
-     switch (oid) {
 
-         case 1: /* FWVersion */
 
-             GetVersionStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 4: /* UPSModel*/
 
-             GetUPSModelStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 5: /* UPSSerial*/
 
-             GetUPSSerialStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 6: /* UPSVersion*/
 
-             GetUPSVersionStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 9: /* IntTemp */
 
-             GetInternalTempStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 10: /* InFreq */
 
-             GetInputFreqStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 11: /* InVoltVAC */
 
-             GetInputVoltageStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 12: /* OutVoltVAC */
 
-             GetOutputVoltageStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 13: /* Power */
 
-             GetPowerStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 14: /* BatCap */
 
-             GetBatCapacityStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 15: /* BatTime */
 
-             GetRuntimeStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 16: /* ConnectMonitor */
 
-             GetConnectMonitorStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 17: /* Alarms */
 
-             GetAlarmStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 18: /* IP server1 (traps) */
 
-             GetManagerIp((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 19: /* IP server2 (traps) */
 
-             GetManagerIp2((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 20: /* IP server3 (traps) */
 
-             GetManagerIp3((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 21: /* IP server4 (traps) */
 
-             GetManagerIp4((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 22: /* IP server5 (traps) */
 
-             GetManagerIp5((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 23: /* WhiteList range 1 */
 
-             GetWhiteListSTR((char *)paramStr, ¶mLength, 0);
 
-             break;
 
-         case 24: /* WhiteList range 2 */
 
-             GetWhiteListSTR((char *)paramStr, ¶mLength, 1);
 
-             break;
 
-         case 25: /* WhiteList range 3 */
 
-             GetWhiteListSTR((char *)paramStr, ¶mLength, 2);
 
-             break;
 
-         case 26: /* WhiteList range 4 */
 
-             GetWhiteListSTR((char *)paramStr, ¶mLength, 3);
 
-             break;
 
-         case 27: /* WhiteList range 5 */
 
-             GetWhiteListSTR((char *)paramStr, ¶mLength, 4);
 
-             break;
 
-         case 28: /* UPSVoltCellMin */
 
-             GetUPSVoltCellMinStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 29: /* UPSVoltCellMax */
 
-             GetUPSVoltCellMaxStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 30: /* VACAlarmHighRange */
 
-             GetVACAlarmHighRangeStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 31: /* VACAlarmLowRange */
 
-             GetVACAlarmLowRangeStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 32: /* VACAlarmHistRange */
 
-             GetVACAlarmHisteStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 33: /* TemperatureAlarmHighRange */
 
-             GetTemperatureAlarmHighRangeStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 34: /* TemperatureAlarmLowRange */
 
-             GetTemperatureAlarmLowRangeStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 35: /* TemperatureAlarmHistRange */
 
-             GetTemperatureAlarmHisteStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 36: /* LoadAlarmHighRange */
 
-             GetLoadAlarmHighRangeStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 37: /* LoadAlarmHistRange */
 
-             GetLoadAlarmHisteStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 38: /* SntpTimeZone */
 
-             GetSntpTimeZoneStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 39: /* SntpState */
 
-             GetSntpStateStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 40: /* SntpServerIp */
 
-             GetSntpServerIpStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 41: /* SntpLastData */
 
-             GetSntpLastDataStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 42: /* Date */
 
-             GetDateStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 43: /* Time */
 
-             GetTimeStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 44: /* AKBTimeWork */
 
-             GetAKBWorktimeStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 45: /* InputCurrent */
 
-             GetInputCurrentStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 46: /* OutputCurrent */
 
-             GetOutputCurrentStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 47: /* VoltageAKB */
 
-             GetVoltageAKBtStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         case 48: /*  CapacityNominalAKB*/
 
-             GetCapacityNominalAKBStr((char *)paramStr, ¶mLength);
 
-             break;
 
-         default:
 
-             break;
 
-     }
 
-     return paramLength;
 
- }
 
- static snmp_err_t signal_set_value(struct snmp_node_instance *instance, u16_t len, void *value)
 
- {
 
-     u32_t oid = instance->node->oid; // id сигнала
 
-     char *val_string;
 
-     char str[20];
 
-     int8_t res = 0;
 
-     s32_t val;
 
-     float setVal;
 
-     bool enable_old_sntp;
 
-     memset(str, 0, 20);
 
-     switch (oid) {
 
-         case 2: /* RestoreSignal */
 
-             val = *(s32_t *)value;
 
-             if (val == 1) {
 
-                 //    SNMP_SendUserTrap(DEVICE_RESTORED);
 
-                 log_event_data(LOG_SYSTEM_DEFCONFIG, "Администратор");
 
-                 vTaskDelay(500);
 
-                 SETTINGS_SetPartDefault();
 
-                 SETTINGS_Save();
 
-             }
 
-             break;
 
-         case 3: /* RebootSignal */
 
-             val = *(s32_t *)value;
 
-             if (val == 1) {
 
-                 HTTP_StartResetTask(false);
 
-             }
 
-             break;
 
-         case 7: /* BatTest */
 
-             val = *(s32_t *)value;
 
-             if (val == 0) {
 
-                 res = ups_metac_service_pdu(ups_cancel_test);
 
-                 if (res == 1) {
 
-                     log_event_data(LOG_TEST_UPS, "Администратор (Останов)");
 
-                 }
 
-             } else if (val > 0 && val < 100) {
 
-                 TimeParam = val;
 
-                 res = ups_metac_service_pdu(ups_test_time);
 
-                 set_act_source(SNMP_ACT);
 
-             } else if (val == 100) {
 
-                 res = ups_metac_service_pdu(ups_test_10sec);
 
-                 set_act_source(SNMP_ACT);
 
-             } else if (val == 999) {
 
-                 res = ups_metac_service_pdu(ups_test_low_bat);
 
-                 set_act_source(SNMP_ACT);
 
-             }
 
-             break;
 
-         case 8: /* Shutdown UPS */
 
-             val_string = (char *)value;
 
-             float shtdn_val = atof(val_string);
 
-             if (shtdn_val == 0) {
 
-                 res = ups_metac_service_pdu(ups_cancel_shut_down);
 
-                 if (res == 1) {
 
-                     log_event_data(LOG_SHUTDOWN_UPS, "Администратор (Останов)");
 
-                 }
 
-             } else {
 
-                 TimeParamFloat = shtdn_val;
 
-                 res = ups_metac_service_pdu(ups_shutdown);
 
-                 if (res == 1) {
 
-                     log_event_data(LOG_SHUTDOWN_UPS, "Администратор");
 
-                 }
 
-             }
 
-             break;
 
-         case 18:
 
-             val_string = (char *)value;
 
-             SetManagerIp(val_string);
 
-             break;
 
-         case 19:
 
-             val_string = (char *)value;
 
-             SetManagerIp2(val_string);
 
-             break;
 
-         case 20:
 
-             val_string = (char *)value;
 
-             SetManagerIp3(val_string);
 
-             break;
 
-         case 21:
 
-             val_string = (char *)value;
 
-             SetManagerIp4(val_string);
 
-             break;
 
-         case 22:
 
-             val_string = (char *)value;
 
-             SetManagerIp5(val_string);
 
-             break;
 
-         case 28:
 
-             val_string = (char *)value;
 
-             SetUPSVoltCellMinStr(val_string);
 
-             break;
 
-         case 29:
 
-             val_string = (char *)value;
 
-             SetUPSVoltCellMaxStr(val_string);
 
-             break;
 
-         case 30:
 
-             val_string = (char *)value;
 
-             SetVACAlarmHighRangeStr(val_string);
 
-             break;
 
-         case 31:
 
-             val_string = (char *)value;
 
-             SetVACAlarmLowRangeStr(val_string);
 
-             break;
 
-         case 32:
 
-             val_string = (char *)value;
 
-             SetVACAlarmHisteStr(val_string);
 
-             break;
 
-         case 33:
 
-             val_string = (char *)value;
 
-             SetTemperatureAlarmHighRangeStr(val_string);
 
-             break;
 
-         case 34:
 
-             val_string = (char *)value;
 
-             SetTemperatureAlarmLowRangeStr(val_string);
 
-             break;
 
-         case 35:
 
-             val_string = (char *)value;
 
-             SetTemperatureAlarmHisteStr(val_string);
 
-             break;
 
-         case 36:
 
-             val_string = (char *)value;
 
-             SetLoadAlarmHighRangeStr(val_string);
 
-             break;
 
-         case 37:
 
-             val_string = (char *)value;
 
-             SetLoadAlarmHistStr(val_string);
 
-             break;
 
-         case 38:
 
-             val_string = (char *)value;
 
-             SetSntpTimeZoneStr(val_string);
 
-             break;
 
-         case 39:
 
-             enable_old_sntp = sSettings.sSNTP.sntpEnable;
 
-             val_string = (char *)value;
 
-             SetSntpStateStr(val_string);
 
-             if (sSettings.sSNTP.sntpEnable != enable_old_sntp) {
 
-                 SETTINGS_Save();
 
-                 log_event_data(LOG_SETTING_SAVE, "Администратор (SNMP)");
 
-             }
 
-             break;
 
-         case 40:
 
-             val_string = (char *)value;
 
-             if (strncmp(val_string, sSettings.sSNTP.ip, strlen(val_string)) != 0) {
 
-                 SetSntpServerIpStr(val_string);
 
-                 SETTINGS_Save();
 
-                 log_event_data(LOG_SETTING_SAVE, "Администратор (SNMP)");
 
-                 SNTP_Init();
 
-                 //vTaskDelay(7000);
 
-                 SNTP_Poll();
 
-             }
 
-             break;
 
-         case 41:
 
-             break;
 
-         case 42:
 
-             val_string = (char *)value;
 
-             SetDateStr(val_string);
 
-             break;
 
-         case 43:
 
-             val_string = (char *)value;
 
-             SetTimeStr(val_string);
 
-             break;
 
-         default :
 
-             return SNMP_ERR_GENERROR;
 
-             break;
 
-     };
 
-     if ((oid >= 18 && oid <= 22)
 
-         || (oid >= 28 && oid <= 38)) {
 
-         SETTINGS_Save();
 
-         log_event_data(LOG_SETTING_SAVE, "Администратор (SNMP)");
 
-     }
 
-     return SNMP_ERR_NOERROR;
 
- }
 
- static snmp_err_t signal_set_test(struct snmp_node_instance *instance, u16_t len, void *value)
 
- {
 
-     snmp_err_t ret = SNMP_ERR_WRONGVALUE;
 
-     char *val_string;
 
-     int32_t val;
 
-     float tmp_value;
 
-     uint8_t j;
 
-     u32_t oid = instance->node->oid; // id сигнала
 
-     bool fail = false;
 
-     switch (oid) {
 
-         case 2:
 
-         case 3:
 
-             if ( len == sizeof(s32_t) ) {
 
-                 val = *((s32_t *)value);
 
-                 if (val == 1) {
 
-                     ret = SNMP_ERR_NOERROR;
 
-                 }
 
-             }
 
-             break;
 
-         case 7: /* BatTest */
 
-             val = *((s32_t *)value);
 
-             if ((val >= 0 && val <= 100) || val == 999) {
 
-                 ret = SNMP_ERR_NOERROR;
 
-             }
 
-             break;
 
-         case 8: /* Shutdown UPS */
 
-             if ( len <= 3 ) {
 
-                 val_string = (char *)value;
 
-                 val_string[len] = 0;
 
-                 if (atof(val_string) <= 10) {
 
-                     ret = SNMP_ERR_NOERROR;
 
-                 }
 
-             }
 
-             break;
 
-         case 18:
 
-         case 19:
 
-         case 20:
 
-         case 21:
 
-         case 22:
 
-         case 40:
 
-             if ( len <= 15 ) {
 
-                 val_string = (char *)value;
 
-                 val_string[len] = 0;
 
-                 if (check_netsettings(val_string, len)) {
 
-                     ret = SNMP_ERR_NOERROR;
 
-                 }
 
-             }
 
-             break;
 
-         case 28:
 
-             val_string = (char *)value;
 
-             val_string[len] = 0;
 
-             for (j = 0; j < len; j ++) {
 
-                 if (!isfloatdigit(val_string[j])) {
 
-                     return ret;
 
-                 }
 
-             }
 
-             tmp_value = atof(val_string);
 
-             if (tmp_value < sSettings.UPS_Setting.Ucellmax && tmp_value > MIN_VOLT_CELL_RANGE) {
 
-                 ret = SNMP_ERR_NOERROR;
 
-             }
 
-             break;
 
-         case 29:
 
-             val_string = (char *)value;
 
-             val_string[len] = 0;
 
-             for (j = 0; j < len; j ++) {
 
-                 if (!isfloatdigit(val_string[j])) {
 
-                     return ret;
 
-                 }
 
-             }
 
-             tmp_value = atof(val_string);
 
-             if (tmp_value > sSettings.UPS_Setting.Ucellmin && tmp_value <= MAX_VOLT_CELL_RANGE) {
 
-                 ret = SNMP_ERR_NOERROR;
 
-             }
 
-             break;
 
-         case 30:
 
-             val_string = (char *)value;
 
-             val_string[len] = 0;
 
-             for (j = 0; j < len; j ++) {
 
-                 if (!isdigit_int(val_string[j])) {
 
-                     return ret;
 
-                 }
 
-             }
 
-             tmp_value = atof(val_string);
 
-             if (tmp_value >= MAX_VAC_MIN_RANGE && tmp_value <= MAX_VAC_MAX_RANGE) {
 
-                 ret = SNMP_ERR_NOERROR;
 
-             }
 
-             break;
 
-         case 31:
 
-             val_string = (char *)value;
 
-             val_string[len] = 0;
 
-             for (j = 0; j < len; j ++) {
 
-                 if (!isdigit_int(val_string[j])) {
 
-                     return ret;
 
-                 }
 
-             }
 
-             tmp_value = atof(val_string);
 
-             if (tmp_value >= MIN_VAC_MIN_RANGE && tmp_value <= MIN_VAC_MAX_RANGE) {
 
-                 ret = SNMP_ERR_NOERROR;
 
-             }
 
-             break;
 
-         case 32:
 
-             val_string = (char *)value;
 
-             val_string[len] = 0;
 
-             for (j = 0; j < len; j ++) {
 
-                 if (!isdigit_int(val_string[j])) {
 
-                     return ret;
 
-                 }
 
-             }
 
-             tmp_value = atof(val_string);
 
-             if (tmp_value >= HIST_VAC_MIN_RANGE && tmp_value <= HIST_VAC_MAX_RANGE) {
 
-                 ret = SNMP_ERR_NOERROR;
 
-             }
 
-             break;
 
-         case 33:
 
-             val_string = (char *)value;
 
-             val_string[len] = 0;
 
-             for (j = 0; j < len; j ++) {
 
-                 if (!isdigit_int(val_string[j])) {
 
-                     return ret;
 
-                 }
 
-             }
 
-             tmp_value = atof(val_string);
 
-             if (tmp_value >= MAX_TEMP_MIN_RANGE && tmp_value <= MAX_TEMP_MAX_RANGE) {
 
-                 ret = SNMP_ERR_NOERROR;
 
-             }
 
-             break;
 
-         case 34:
 
-             val_string = (char *)value;
 
-             val_string[len] = 0;
 
-             for (j = 0; j < len; j ++) {
 
-                 if (!isdigit_int(val_string[j])) {
 
-                     if (j == 0 && val_string[j] == '-') {
 
-                         continue;
 
-                     } else {
 
-                         return ret;
 
-                     }
 
-                 }
 
-             }
 
-             tmp_value = atof(val_string);
 
-             if (tmp_value >= MIN_TEMP_MIN_RANGE && tmp_value <= MIN_TEMP_MAX_RANGE) {
 
-                 ret = SNMP_ERR_NOERROR;
 
-             }
 
-             break;
 
-         case 35:
 
-             val_string = (char *)value;
 
-             val_string[len] = 0;
 
-             for (j = 0; j < len; j ++) {
 
-                 if (!isfloatdigit(val_string[j])) {
 
-                     return ret;
 
-                 }
 
-             }
 
-             tmp_value = atof(val_string);
 
-             if (tmp_value >= HIST_TEMP_MIN_RANGE && tmp_value <= HIST_TEMP_MAX_RANGE) {
 
-                 ret = SNMP_ERR_NOERROR;
 
-             }
 
-             break;
 
-         case 36:
 
-             val_string = (char *)value;
 
-             val_string[len] = 0;
 
-             for (j = 0; j < len; j ++) {
 
-                 if (!isdigit_int(val_string[j])) {
 
-                     return ret;
 
-                 }
 
-             }
 
-             tmp_value = atof(val_string);
 
-             if (tmp_value >= MAX_LOAD_MIN_RANGE && tmp_value <= MAX_LOAD_MAX_RANGE) {
 
-                 ret = SNMP_ERR_NOERROR;
 
-             }
 
-             break;
 
-         case 37:
 
-             val_string = (char *)value;
 
-             val_string[len] = 0;
 
-             for (j = 0; j < len; j ++) {
 
-                 if (!isfloatdigit(val_string[j])) {
 
-                     return ret;
 
-                 }
 
-             }
 
-             tmp_value = atof(val_string);
 
-             if (tmp_value >= HIST_LOAD_MIN_RANGE && tmp_value <= HIST_LOAD_MAX_RANGE) {
 
-                 ret = SNMP_ERR_NOERROR;
 
-             }
 
-             break;
 
-         case 38:
 
-             val_string = (char *)value;
 
-             val_string[len] = 0;
 
-             if (len > 1 && len < 5) {
 
-                 bool fail = false;
 
-                 if (val_string[0] != '-' && val_string[0] != '+') {
 
-                     fail = true;
 
-                 }
 
-                 if (!isdigit_int(val_string[1]) && (!isdigit_int(val_string[2]) && val_string[2] != '.')
 
-                     && (!isdigit_int(val_string[3]) && val_string[3] != '.')) {
 
-                     fail = true;
 
-                 }
 
-                 if (len == 5) {
 
-                     if (!isdigit_int(val_string[4])) {
 
-                         fail = true;
 
-                     }
 
-                 }
 
-                 if (!fail) {
 
-                     tmp_value = atof(val_string);
 
-                     if (tmp_value >= -12.0 && tmp_value <= 12.0) {
 
-                         ret = SNMP_ERR_NOERROR;
 
-                     }
 
-                 }
 
-             }
 
-             break;
 
-         case 39:
 
-             val_string = (char *)value;
 
-             val_string[len] = 0;
 
-             if (len == 1) {
 
-                 if (val_string[0] == '0' || val_string[0] == '1') {
 
-                     ret = SNMP_ERR_NOERROR;
 
-                 }
 
-             }
 
-             break;
 
-         case 42:
 
-             val_string = (char *)value;
 
-             val_string[len] = 0;
 
-             if (len == 10) {
 
-                 for (j = 0; j < len; j++) {
 
-                     if (j != 4 && j != 7) {
 
-                         if (val_string[j] > 0x39 || val_string[j] < 0x30) {
 
-                             fail = true;
 
-                             break;
 
-                         }
 
-                     } else if (j == 4 || j == 7) {
 
-                         if (val_string[j] != '-') {
 
-                             fail = true;
 
-                             break;
 
-                         }
 
-                     }
 
-                 }
 
-                 if (!fail) {
 
-                     uint16_t temp = 0;
 
-                     temp = 1000 * (val_string[0] - 0x30) + 100 * (val_string[1] - 0x30) + 10 * (val_string[2] - 0x30) + val_string[3] -
 
-                         0x30;
 
-                     if (temp > 2099 || temp < 2000) {
 
-                         fail = true;
 
-                     }
 
-                     temp = 0;
 
-                     temp = 10 * (val_string[5] - 0x30) + (val_string[6] - 0x30);
 
-                     if (temp > 12) {
 
-                         fail = true;
 
-                     }
 
-                     temp = 0;
 
-                     temp = 10 * (val_string[8] - 0x30) + (val_string[9] - 0x30);
 
-                     if (temp > 31) {
 
-                         fail = true;
 
-                     }
 
-                 }
 
-                 if (!fail) {
 
-                     ret = SNMP_ERR_NOERROR;
 
-                 }
 
-             }
 
-             break;
 
-         case 43:
 
-             val_string = (char *)value;
 
-             val_string[len] = 0;
 
-             if (len == 5) {
 
-                 for (j = 0; j < len; j++) {
 
-                     if (j != 2) {
 
-                         if (val_string[j] > 0x39 || val_string[j] < 0x30) {
 
-                             fail = true;
 
-                             break;
 
-                         }
 
-                     } else if (j == 2) {
 
-                         if (val_string[j]  != ':') {
 
-                             fail = true;
 
-                             break;
 
-                         }
 
-                     }
 
-                 }
 
-                 if (!fail) {
 
-                     uint16_t temp = 0;
 
-                     temp = 10 * (val_string[0] - 0x30) + (val_string[1] - 0x30);
 
-                     if (temp > 23) {
 
-                         fail = true;
 
-                     }
 
-                     temp = 0;
 
-                     temp = 10 * (val_string[3] - 0x30) + (val_string[4] - 0x30);
 
-                     if (temp > 59) {
 
-                         fail = true;
 
-                     }
 
-                 }
 
-                 if (!fail) {
 
-                     ret = SNMP_ERR_NOERROR;
 
-                 }
 
-             }
 
-             break;
 
-     };
 
-     return ret;
 
- }
 
- #endif
 
 
  |