Explorar o código

[portgw]add get/set function

balbekova %!s(int64=5) %!d(string=hai) anos
pai
achega
aa4ac045c7
Modificáronse 2 ficheiros con 235 adicións e 0 borrados
  1. 155 0
      modules/parameters.c
  2. 80 0
      modules/parameters.h

+ 155 - 0
modules/parameters.c

@@ -1069,6 +1069,85 @@ void GetWhiteListIP(uint32_t *value, uint8_t num)
 
 #endif
 
+#ifdef PORTGW_ENABLE
+// ************************************************************************** //
+//                             Параметры прозрачного порта
+
+/**
+  * @brief  Включен/Выключен
+  */
+void GetPortGwEnabledStr(char *str, uint8_t *len)
+{
+    if (sSettings.sPortGw.enabled) {
+        sprintf(str, "%s", "true");
+    } else {
+        sprintf(str, "%s", "false");
+    }
+    *len = strlen(str);
+}
+
+/**
+  * @brief  IP-адрес
+  */
+void GetPortGwIpStr(char *str, uint8_t *len)
+{
+    sprintf(str, "%s", sSettings.sPortGw.ip);
+    *len = strlen(str);
+}
+
+/**
+  * @brief  Сетевой порт
+  */
+void GetPortGwPortnumStr(char *str, uint8_t *len)
+{
+    sprintf(str, "%d", sSettings.sPortGw.port);
+    *len = strlen(str);
+}
+
+/**
+  * @brief Скорость передачи данных
+  */
+void GetPortGwBaudStr(char *str, uint8_t *len)
+{
+    sprintf(str, "%d", sSettings.sPortGw.baud);
+    *len = strlen(str);
+}
+
+/**
+  * @brief Четность
+  */
+void GetPortGwParityStr(char *str, uint8_t *len)
+{
+    if (sSettings.sPortGw.parity == GW_EVEN_PAR) {
+        sprintf(str, "%s", "ev");
+    } else if (sSettings.sPortGw.parity == GW_ODD_PAR) {
+        sprintf(str, "%s", "od");
+    } else {
+        sprintf(str, "%s", "no");
+    }
+
+    *len = strlen(str);
+}
+
+/**
+  * @brief Число бит данных
+  */
+void GetPortGwDatabitsStr(char *str, uint8_t *len)
+{
+    sprintf(str, "%d", sSettings.sPortGw.databits);
+    *len = strlen(str);
+}
+
+/**
+  * @brief Число стоп-бит
+  */
+void GetPortGwStopbitsStr(char *str, uint8_t *len)
+{
+    sprintf(str, "%d", sSettings.sPortGw.stopbits);
+    *len = strlen(str);
+}
+#endif
+
 // ************************************************************************** //
 //                             Параметры SNMP
 
@@ -1751,6 +1830,82 @@ void SetWhiteList5STR(char *str)
 
 #endif
 
+#ifdef PORTGW_ENABLE
+// ************************************************************************** //
+//                             Параметры прозрачного порта
+
+/**
+  * @brief  Включен/Выключен
+  */
+void SetPortGwEnabledStr(char *str)
+{
+    if (strncmp(str, "on", 2) == 0) {
+        sSettings.sPortGw.enabled = true;
+    } else {
+        sSettings.sPortGw.enabled = false;
+    }
+}
+
+/**
+  * @brief  IP-адрес
+  */
+void SetPortGwIpStr(char *str)
+{
+    char temp[16];
+
+    if (strlen(str) <= sizeof(temp)) {
+        ip_strip(str, temp);
+        SET_STR_VALUE(sSettings.sPortGw.ip, temp);
+    }
+}
+
+/**
+  * @brief  Сетевой порт
+  */
+void SetPortGwPortnumStr(char *str)
+{
+    sSettings.sPortGw.port = atoi(str);
+}
+
+/**
+  * @brief Скорость передачи данных
+  */
+void SetPortGwBaudStr(char *str)
+{
+    sSettings.sPortGw.baud = atoi(str);
+}
+
+/**
+  * @brief Четность
+  */
+void SetPortGwParityStr(char *str)
+{
+    if (strncmp(str, "no", 2) == 0) {
+        sSettings.sPortGw.parity = GW_NO_PAR;
+    } else if (strncmp(str, "od", 2) == 0) {
+        sSettings.sPortGw.parity = GW_ODD_PAR;
+    } else if (strncmp(str, "ev", 2) == 0) {
+        sSettings.sPortGw.parity = GW_EVEN_PAR;
+    }
+}
+
+/**
+  * @brief Число бит данных
+  */
+void SetPortGwDatabitsStr(char *str)
+{
+    sSettings.sPortGw.databits = atoi(str);
+}
+
+/**
+  * @brief Число стоп-бит
+  */
+void SetPortGwStopbitsStr(char *str)
+{
+    sSettings.sPortGw.stopbits = atoi(str);
+}
+#endif
+
 // ************************************************************************** //
 //                             Параметры SNMP
 

+ 80 - 0
modules/parameters.h

@@ -337,6 +337,46 @@ void GetWhiteListIP(uint32_t *value, uint8_t num);
 
 #endif
 
+#ifdef PORTGW_ENABLE
+// ************************************************************************** //
+//                             Параметры прозрачного порта
+
+/**
+  * @brief  Включен/Выключен
+  */
+void GetPortGwEnabledStr(char *str, uint8_t *len);
+
+/**
+  * @brief  IP-адрес
+  */
+void GetPortGwIpStr(char *str, uint8_t *len);
+
+/**
+  * @brief  Сетевой порт
+  */
+void GetPortGwPortnumStr(char *str, uint8_t *len);
+
+/**
+  * @brief Скорость передачи данных
+  */
+void GetPortGwBaudStr(char *str, uint8_t *len);
+
+/**
+  * @brief Четность
+  */
+void GetPortGwParityStr(char *str, uint8_t *len);
+
+/**
+  * @brief Число бит данных
+  */
+void GetPortGwDatabitsStr(char *str, uint8_t *len);
+
+/**
+  * @brief Число стоп-бит
+  */
+void GetPortGwStopbitsStr(char *str, uint8_t *len);
+#endif
+
 // ************************************************************************** //
 //                             Параметры SNMP
 /**
@@ -755,6 +795,46 @@ void SetWhiteList5STR(char *str);
 
 #endif
 
+#ifdef PORTGW_ENABLE
+// ************************************************************************** //
+//                             Параметры прозрачного порта
+
+/**
+  * @brief  Включен/Выключен
+  */
+void SetPortGwEnabledStr(char *str);
+
+/**
+  * @brief  IP-адрес
+  */
+void SetPortGwIpStr(char *str);
+
+/**
+  * @brief  Сетевой порт
+  */
+void SetPortGwPortnumStr(char *str);
+
+/**
+  * @brief Скорость передачи данных
+  */
+void SetPortGwBaudStr(char *str);
+
+/**
+  * @brief Четность
+  */
+void SetPortGwParityStr(char *str);
+
+/**
+  * @brief Число бит данных
+  */
+void SetPortGwDatabitsStr(char *str);
+
+/**
+  * @brief Число стоп-бит
+  */
+void SetPortGwStopbitsStr(char *str);
+#endif
+
 // ************************************************************************** //
 //                             Параметры SNMP