Parcourir la source

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

guohui il y a 1 an
Parent
commit
f863e2ff3b

+ 6 - 0
cust_data/smartPDU.ini

@@ -28,6 +28,12 @@ nwire       = "0"
 ipv4        = "1"
 ipv6        = "1"
 
+[CellularWIFIcfg]
+Cellular = "0"
+WIFI = "0"
+WIFI_ssid= "-"
+WIFI_pw= "-"
+
 [misc]
 watchdog    = "0"
 fliptime    = "5"

+ 15 - 3
f407/applications/cascade.c

@@ -478,12 +478,14 @@ static int master_cmd(cascade_handle_t *cas,uint8_t cur_dev_addr ,cmd_data_t *cm
             if(r == 1)
 						{
 							uint8_t chanels = value & 0xff;
-							if(chanels == 0)
+							if(chanels == 0 || chanels > 100)
 							{
 								cas->info->channels = 0;
-								LOGD("can not get cannes!!!\n");
+								LOGD("get slave channels %d!!!\n",chanels);
 							}else
 							{
+								if(chanels >= SLAVE_CH_MAX)
+										chanels = SLAVE_CH_MAX;
 								cas->info->channels = chanels;
 								//rdata.dlen = sizeof(slave_info_t) -sizeof(power_ch_t)*(SLAVE_CH_MAX - cas->info.channels);
                 rdata.dlen = sizeof(power_ch_t)*cas->info->channels;
@@ -606,6 +608,16 @@ uint8_t cascade_deinit()
     mb_handle_t *handle = (mb_handle_t *)(slave_info.mb);
     lock_deinit(slave_info.lock);
     mb_deinit(slave_info.mb);
+		if(slave_info.north)
+		{
+			free(slave_info.north);
+			slave_info.north = 0;
+		}
+		if(slave_info.info)
+		{
+			free(slave_info.info);
+			slave_info.info = 0;
+		}
     return 0;
 }
 
@@ -833,7 +845,7 @@ void cascade_reinit(uint8_t mode,uint8_t addr,uint32_t baud)
 			return;
 		}
 		mb_handle_t *handle=(mb_handle_t *)(&slave_info.mb);
-		handle->quit = 1;
+
 		slave_info.quit = 1;
 		sleep(1);
 		cascade_deinit();

+ 1 - 0
pro/CMakeLists.txt

@@ -109,6 +109,7 @@ set(PDU_SRC_LIST
 	${PROJECT_SOURCE_DIR}/src/md5.c
 	${PROJECT_SOURCE_DIR}/src/netswitch.c
 	${PROJECT_SOURCE_DIR}/src/main.c
+	${PROJECT_SOURCE_DIR}/src/Cellular.c
 
 	${PROJECT_SOURCE_DIR}/src/language_hashmap.c
 	${PROJECT_SOURCE_DIR}/src/ntpclient.c

+ 4 - 0
pro/src/app.c

@@ -28,6 +28,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include "pduMIB_trap.h"
+#include "Cellular.h"
 
 
 
@@ -2603,6 +2604,9 @@ int app_init(void)
     websocket_init();
     appweb_init();
 
+    //Cellular_init();
+   // WIFI_init();
+
     upg_init();
     dev_Alarm_Run_message(_globalDeviceManager,language_alarm_Init_Success[0],"Server Thread");
     

+ 24 - 2
pro/src/appweb_handle.c

@@ -3878,7 +3878,28 @@ static void communicationManagement(void *conn)
 
         ack_str = ctrl_sts_ack_to_json();
     }
-    
+    else if (strcmp(reqInfo.type, "listfourgPZQuery") == 0) // 4G网络处理
+    {
+        ack_str = communication_4G_ack_to_json(&_globalCellularManager,0);
+    }
+    else if (strcmp(reqInfo.type, "fourgPZSave") == 0) // 4G网络处理
+    {
+        _globalCellularManager.mode = reqInfo._4g_wifi_info.Cellular_mode;
+        CellularWIFI_paras_save();
+         ack_str = ctrl_sts_ack_to_json(); 
+    }
+    else if(strcmp(reqInfo.type,"listWIFIPZQuery")==0) // WIFI处理
+    {
+        ack_str = communication_WIFI_ack_to_json(&_globalWIFIManager,0);
+    }
+     else if (strcmp(reqInfo.type, "WIFIPZSave") == 0) // WIFI处理
+    {
+        _globalWIFIManager.mode = reqInfo._4g_wifi_info.WIFI_mode;
+         strcpy(_globalWIFIManager.WIFI_name, reqInfo._4g_wifi_info.WIFI_name);
+         strcpy(_globalWIFIManager.WIFI_code, reqInfo._4g_wifi_info.WIFI_code);
+         CellularWIFI_paras_save();
+         ack_str = ctrl_sts_ack_to_json(); 
+    }
     cJSON_Delete(cjson);
     http_reply(conn, 200, ack_str);
     cJSON_free((void*)ack_str); 
@@ -3944,7 +3965,8 @@ static void serviceManagement(void *conn)
                 }
             }
             else {
-                memset(send, 0, sizeof(mail_send_t));;
+                //memset(send, 0, sizeof(mail_send_t));;
+                send->mode = atoi(info->mode);
             }
             
             if(memcmp(&mailInfo.send, &gdm->mailInfo.send, sizeof(mail_send_t))) {

+ 38 - 0
pro/src/common.c

@@ -30,6 +30,9 @@ char _GlobalUserToken[64];
 MenuAuthority _GlobalMenuAuthority;
 NTPManager _globalNTPManager;
 SNMPManager _globalSNMPManager;
+CellularManager  _globalCellularManager;
+WIFIManager _globalWIFIManager;
+
 
 void printf_global_device_info(GlobalDeviceInfo* _globalDeviceInfo)
 {
@@ -808,6 +811,8 @@ void SetMenuAuthority(int RoleID)
         // 6、通信管理菜单
         _GlobalMenuAuthority.WkszEnabled = true;
         _GlobalMenuAuthority.RsszEnabled = true;
+        _GlobalMenuAuthority.CellularEnabled = false;
+        _GlobalMenuAuthority.WifiEnabled = false;
         // 7、服务管理菜单
         _GlobalMenuAuthority.SmtpszEnabled = true;
         _GlobalMenuAuthority.SnmpszEnabled = true;
@@ -868,6 +873,8 @@ void SetMenuAuthority(int RoleID)
         // 6、通信管理菜单
         _GlobalMenuAuthority.WkszEnabled = false;
         _GlobalMenuAuthority.RsszEnabled = true;
+        _GlobalMenuAuthority.CellularEnabled = false;
+        _GlobalMenuAuthority.WifiEnabled = false;
         // 7、服务管理菜单
         _GlobalMenuAuthority.SmtpszEnabled = false;
         _GlobalMenuAuthority.SnmpszEnabled = false;
@@ -928,6 +935,8 @@ void SetMenuAuthority(int RoleID)
         // 6、通信管理菜单
         _GlobalMenuAuthority.WkszEnabled = false;
         _GlobalMenuAuthority.RsszEnabled = false;
+        _GlobalMenuAuthority.CellularEnabled = false;
+        _GlobalMenuAuthority.WifiEnabled = false;
         // 7、服务管理菜单
         _GlobalMenuAuthority.SmtpszEnabled = false;
         _GlobalMenuAuthority.SnmpszEnabled = false;
@@ -947,4 +956,33 @@ void SetMenuAuthority(int RoleID)
         _GlobalMenuAuthority.GysbEnabled = false;
     }
     
+}
+
+void InitCellularManager()
+{
+    //_globalCellularManager.mode = 0;
+    _globalCellularManager.Link_status = false; // 4G网络连接状态
+    _globalCellularManager.Signal_strength = 0; // 4G信号强度
+    sprintf(_globalCellularManager.Cellular_name, "-");
+    sprintf(_globalCellularManager.Cellular_Num, "-");
+    //_globalCellularManager.Cellular_IMEI[64]="-"; // IMEI号
+
+   // _globalCellularManager.GPS_status = false;  // GPS功能启用
+    _globalCellularManager.GPS_latitude = 0.0;  // GPS��度
+    _globalCellularManager.GPS_longitude = 0.0; // GPS经度
+    _globalCellularManager.GPS_altitude = 0.0;  // GPS海��高度
+    _globalCellularManager.GPS_speed = 0.0;     // GPS速度,单位km/h
+    _globalCellularManager.GPS_nsat = 0;        // GPS��星数量
+    sprintf(_globalCellularManager.GPS_utc, "-");
+
+    //_globalCellularManager.SMS_status = false; // 短信功能启用
+}
+
+void InitWIFIManager()
+{
+    //_globalWIFIManager.mode = 0;
+    _globalWIFIManager.Link_status = false; // wifi网络连接状态
+    sprintf(_globalWIFIManager.WIFI_ip, "0.0.0.0");
+    //sprintf(_globalWIFIManager.WIFI_name, "-");
+    //sprintf(_globalWIFIManager.WIFI_code, "-");
 }

+ 38 - 0
pro/src/common.h

@@ -543,6 +543,36 @@ typedef struct
     struct list_head    list;  
 }GroupInfo;
 
+// 4G网络及GPS信息
+typedef struct
+{
+    int mode;         // 4G模块启用状态
+    bool Link_status; // 4G网络连接状态
+    float Signal_strength; // 信号强度
+    char Cellular_name[64];// 4G网络名称
+    char Cellular_Num[64];// 电话号码
+	
+	bool GPS_status; // GPS功能启用
+    char GPS_utc[64];// UTC时间
+    float GPS_latitude;// 纬度,范围-89.99999~89.99999
+    float GPS_longitude;// 精度,范围-179.99999~179.99999
+    float GPS_altitude;// 海拔高度,单位m
+    float GPS_speed;//地面速率,单位km/h
+    int GPS_nsat;//卫星数量
+
+    bool SMS_status; // 短信功能启用
+
+} CellularManager;
+
+// WIFI信息
+typedef struct
+{
+    int mode;         // WIFI模块启用状态
+    bool Link_status; // wifi网络连接状态
+    char WIFI_ip[64]; // wifi ip address
+    char WIFI_name[64];// WIFI网络SSID名称
+    char WIFI_code[64];// WIFI密码
+} WIFIManager;
 
 //电源部分
 typedef struct 
@@ -888,6 +918,8 @@ typedef struct MenuAuthority{
     //6、通信管理菜单
     bool WkszEnabled;
     bool RsszEnabled;
+    bool CellularEnabled;
+    bool WifiEnabled;
     //7、服务管理菜单
     bool SmtpszEnabled;
     bool SnmpszEnabled;
@@ -1250,6 +1282,10 @@ extern MenuAuthority _GlobalMenuAuthority;////角色菜单权限
 extern NTPManager _globalNTPManager;
 extern SNMPManager _globalSNMPManager;
 
+extern CellularManager  _globalCellularManager;
+extern WIFIManager _globalWIFIManager;
+
+
 void initLogger(void);
 
 //打印设备信息结构
@@ -1298,4 +1334,6 @@ void add_day_to_date(char *date_str, int *year, int *month, int *day);
 
 void SetMenuAuthority(int RoleID);
 
+void InitCellularManager();
+void InitWIFIManager();
 #endif

+ 197 - 0
pro/src/json_handle.c

@@ -607,6 +607,30 @@ char* user_routers_info_to_json(void)
     cJSON_AddStringToObject(children5_meta2_data1_filed,"link","");    
     cJSON_AddItemToObject(children5_data2_filed, "meta", children5_meta2_data1_filed);
     if(_GlobalMenuAuthority.RsszEnabled)cJSON_AddItemToObject(children5_data_array, "children", children5_data2_filed);
+    cJSON* children5_data3_filed = cJSON_CreateObject(); 
+    cJSON_AddStringToObject(children5_data3_filed,"name","Fourgsz");    
+    cJSON_AddStringToObject(children5_data3_filed,"path","fourgsz");  
+    cJSON_AddBoolToObject(children5_data3_filed,"hidden",false); 
+    cJSON_AddStringToObject(children5_data3_filed,"component","txgl/fourgsz/index");  
+    cJSON* children5_meta3_data1_filed = cJSON_CreateObject(); 
+    cJSON_AddStringToObject(children5_meta3_data1_filed,"title",language_4G_install[__globalDeviceManage._globalDevInfo.product.language]);   
+    cJSON_AddStringToObject(children5_meta3_data1_filed,"icon","build");   
+    cJSON_AddBoolToObject(children5_meta3_data1_filed,"noCache",false); 
+    cJSON_AddStringToObject(children5_meta3_data1_filed,"link","");    
+    cJSON_AddItemToObject(children5_data3_filed, "meta", children5_meta3_data1_filed);
+    if(_GlobalMenuAuthority.CellularEnabled)cJSON_AddItemToObject(children5_data_array, "children", children5_data3_filed);
+    cJSON* children5_data4_filed = cJSON_CreateObject(); 
+    cJSON_AddStringToObject(children5_data4_filed,"name","Wifisz");    
+    cJSON_AddStringToObject(children5_data4_filed,"path","wifisz");  
+    cJSON_AddBoolToObject(children5_data4_filed,"hidden",false); 
+    cJSON_AddStringToObject(children5_data4_filed,"component","txgl/wifisz/index");  
+    cJSON* children5_meta4_data1_filed = cJSON_CreateObject(); 
+    cJSON_AddStringToObject(children5_meta4_data1_filed,"title",language_WIFI_install[__globalDeviceManage._globalDevInfo.product.language]);   
+    cJSON_AddStringToObject(children5_meta4_data1_filed,"icon","build");   
+    cJSON_AddBoolToObject(children5_meta4_data1_filed,"noCache",false); 
+    cJSON_AddStringToObject(children5_meta4_data1_filed,"link","");    
+    cJSON_AddItemToObject(children5_data4_filed, "meta", children5_meta4_data1_filed);
+    if(_GlobalMenuAuthority.WifiEnabled)cJSON_AddItemToObject(children5_data_array, "children", children5_data4_filed);
     cJSON_AddItemToObject(data5_filed, "children", children5_data_array);
     if(_GlobalMenuAuthority.CommEnabled)cJSON_AddItemToObject(data_array, "data", data5_filed);
 
@@ -4599,6 +4623,156 @@ char* communication_rs_ack_to_json(ModbusInfo_t* _modbusInfo_t)
     return str;
 }
 
+/// @brief 返回RS485信息
+/// @param _networkInfo_t 
+/// @return 
+char* communication_4G_ack_to_json(CellularManager* _CellularManagerTemp,int nWSType)
+{
+    char temp[32] = {0};
+    char* str = NULL;
+    // 创建 JSON 对象
+    cJSON* root = cJSON_CreateObject();   
+
+    //创建数据
+    memset(temp, 0, sizeof(temp));
+
+    cJSON* sdata_filed = cJSON_CreateObject();
+    // 创建数据
+    cJSON *data_root_array = cJSON_CreateObject();
+    if (nWSType)
+    {
+        cJSON_AddNumberToObject(sdata_filed, "code", 200);
+    }
+    else
+    {
+        cJSON_AddNumberToObject(root, "code", 200);
+    }
+
+    if ( !_CellularManagerTemp->mode)
+    {
+        sprintf(temp,"0");
+    }
+    else
+    {
+        sprintf(temp,"1");
+    }
+    cJSON_AddStringToObject(data_root_array, "czmode", temp);
+
+    cJSON_AddStringToObject(data_root_array, "yys", _CellularManagerTemp->Cellular_name);
+    cJSON_AddStringToObject(data_root_array, "tel", _CellularManagerTemp->Cellular_Num);
+
+    memset(temp, 0, sizeof(temp));
+    if (!_CellularManagerTemp->Link_status)
+    {
+        sprintf(temp, "未连接");
+    }
+    else
+        sprintf(temp, "已连接");
+    cJSON_AddStringToObject(data_root_array, "ljzt", temp);
+
+    memset(temp, 0, sizeof(temp));
+    sprintf(temp, "%0.2f dBm", _CellularManagerTemp->Signal_strength);
+    cJSON_AddStringToObject(data_root_array, "xhqd", temp);
+
+    if (nWSType)
+    {
+        // 添加汇总
+        cJSON_AddItemToObject(sdata_filed, "data", data_root_array);
+        // 添加结果
+        cJSON_AddStringToObject(sdata_filed, "msg", language_Operation_Success[__globalDeviceManage._globalDevInfo.product.language]);
+        cJSON_AddItemToObject(root, "data", sdata_filed);
+        // 添加内容
+        cJSON_AddStringToObject(root, "message", language_Operation_Success[__globalDeviceManage._globalDevInfo.product.language]);
+        cJSON_AddStringToObject(root, "socketIdx", "PDU-WebSocket");
+        cJSON_AddBoolToObject(root, "success", true);
+        cJSON_AddStringToObject(root, "type", "fourgStatus");
+    }else
+    {
+        cJSON_AddItemToObject(root, "data", data_root_array);
+        // 添加内容
+        cJSON_AddStringToObject(root, "msg", language_Operation_Success[__globalDeviceManage._globalDevInfo.product.language]);
+    }
+
+    //转换
+    str = cJSON_Print(root);    
+    //释放资源
+    cJSON_Delete(root);
+    return str;
+}
+
+/// @brief 返回RS485信息
+/// @param _networkInfo_t 
+/// @return 
+char* communication_WIFI_ack_to_json(WIFIManager* _WIFIManagertemp,int nWSType)
+{
+    char temp[32] = {0};
+    char* str = NULL;
+    // 创建 JSON 对象
+    cJSON* root = cJSON_CreateObject();   
+    //创建数据
+    memset(temp, 0, sizeof(temp));
+
+    cJSON *sdata_filed = cJSON_CreateObject();
+    // 创建数据
+    cJSON *data_root_array = cJSON_CreateObject();
+    if (nWSType)
+    {
+        cJSON_AddNumberToObject(sdata_filed, "code", 200);
+    }
+    else
+    {
+        cJSON_AddNumberToObject(root, "code", 200);
+    }
+    
+    if ( !_WIFIManagertemp->mode)
+    {
+        sprintf(temp,"0");
+    }
+    else
+    {
+        sprintf(temp,"1");
+    }
+    cJSON_AddStringToObject(data_root_array, "czmode", temp);
+
+    cJSON_AddStringToObject(data_root_array, "password", _WIFIManagertemp->WIFI_code);
+    cJSON_AddStringToObject(data_root_array, "IPadress", _WIFIManagertemp->WIFI_ip);
+
+    memset(temp, 0, sizeof(temp));
+    if (!_WIFIManagertemp->Link_status)
+    {
+        sprintf(temp, "未连接");
+    }
+    else
+        sprintf(temp, "已连接");
+    cJSON_AddStringToObject(data_root_array, "ljzt", temp);
+
+    cJSON_AddStringToObject(data_root_array, "ssid", _WIFIManagertemp->WIFI_name);
+
+    if (nWSType)
+    {
+        // 添加汇总
+        cJSON_AddItemToObject(sdata_filed, "data", data_root_array);
+        // 添加结果
+        cJSON_AddStringToObject(sdata_filed, "msg", language_Operation_Success[__globalDeviceManage._globalDevInfo.product.language]);
+        cJSON_AddItemToObject(root, "data", sdata_filed);
+        // 添加内容
+        cJSON_AddStringToObject(root, "message", language_Operation_Success[__globalDeviceManage._globalDevInfo.product.language]);
+        cJSON_AddStringToObject(root, "socketIdx", "PDU-WebSocket");
+        cJSON_AddBoolToObject(root, "success", true);
+        cJSON_AddStringToObject(root, "type", "wifiStatus");
+    }else
+    {
+        cJSON_AddItemToObject(root, "data", data_root_array);
+        // 添加内容
+        cJSON_AddStringToObject(root, "msg", language_Operation_Success[__globalDeviceManage._globalDevInfo.product.language]);
+    }
+    //转换
+    str = cJSON_Print(root);    
+    //释放资源
+    cJSON_Delete(root);
+    return str;
+}
+
 /// @brief 返回定时设置
 /// @param chn_name 
 /// @param chn_id 
@@ -5012,6 +5186,29 @@ cJSON* json_to_communication_manage(const char* str,_CommunicationManageRequestI
         if(cjson_rs_addr!=NULL)
             _communicationRequestInfo->_rs_info.addr = cjson_rs_addr->valuestring ;
     }
+    //4G和wifi配置
+    if(strcmp(_communicationRequestInfo->type,"fourgPZSave")==0)
+    { 
+        cJSON* cjson_4g_mode = cJSON_GetObjectItem(cjson,"czmode");
+        if(cjson_4g_mode!=NULL)
+            _communicationRequestInfo->_4g_wifi_info.Cellular_mode = atoi(cjson_4g_mode->valuestring);
+    }
+    // 4G和wifi配置
+    if (strcmp(_communicationRequestInfo->type, "WIFIPZSave") == 0)
+    {
+        cJSON *cjson_wifi_mode = cJSON_GetObjectItem(cjson, "czmode");
+        if (cjson_wifi_mode != NULL)
+            _communicationRequestInfo->_4g_wifi_info.WIFI_mode = atoi(cjson_wifi_mode->valuestring);
+
+        cJSON *cjson_wifi_ssid = cJSON_GetObjectItem(cjson, "ssid");
+        if (cjson_wifi_ssid != NULL)
+            sprintf(_communicationRequestInfo->_4g_wifi_info.WIFI_name, "%s", cjson_wifi_ssid->valuestring);
+
+        cJSON *cjson_wifi_password = cJSON_GetObjectItem(cjson, "password");
+        if (cjson_wifi_password != NULL)
+            sprintf(_communicationRequestInfo->_4g_wifi_info.WIFI_code, "%s", cjson_wifi_password->valuestring);
+    }
+
     return cjson;
 }
 

+ 13 - 0
pro/src/json_handle.h

@@ -487,6 +487,14 @@ typedef struct
     char* addr;
 }_RS_CommunicationRequestInfo;
 
+/// @brief  4G和WiFi参数配置
+typedef struct 
+{
+    int  Cellular_mode;
+    int WIFI_mode;
+    char WIFI_name[64];
+    char WIFI_code[64];
+}_4G_WIFI_CommunicationRequestInfo;
 
 /// @brief 通信信息查询
 typedef struct
@@ -495,6 +503,7 @@ typedef struct
     char* type;
     _NET_CommunicationRequestInfo _net_info;
     _RS_CommunicationRequestInfo _rs_info;
+    _4G_WIFI_CommunicationRequestInfo _4g_wifi_info;
 }_CommunicationManageRequestInfo;
 
 
@@ -623,6 +632,10 @@ char* communication_net_ack_to_json(NetworkInfo_t* _networkInfo_t);
 
 char* communication_rs_ack_to_json(ModbusInfo_t* _modbusInfo_t);
 
+char* communication_4G_ack_to_json(CellularManager* _CellularManagerTemp,int nWSType);
+
+char* communication_WIFI_ack_to_json(WIFIManager* _WIFIManagertemp,int nWSType);
+
 char* service_ds_ack_to_json(char* chn_name,char* chn_id,_PowerDSManage_t* __powerDSManage_t);
 char* service_ds_all_ack_to_json(char* pDate,char* Name,char* nchID,GlobalPowerManger* __powerDSManage_t);
 char* service_sx_ack_to_json(int product_id, GlobalPowerManger * __PowerManage_t);

+ 29 - 0
pro/src/language_common.c

@@ -300,6 +300,35 @@ const char* language_RS485_install[LANG_MAX] =
     "RS485設定",
 } ;
 
+const char* language_4G_install[LANG_MAX] = 
+{
+    "4G设置",
+    "4G settings",
+    "Настройки 4G",
+    "Configuración de 4G",
+    "Configuração de 4G",
+    "4G-Einstellungen",
+    "Configuration 4G",
+    "Impostazione 4G",
+    "4G設定",
+} ;
+
+
+const char* language_WIFI_install[LANG_MAX] = 
+{
+    "Wifi设置",
+    "Wifi settings",
+    "Настройки Wifi",
+    "Configuración de Wifi",
+    "Configuração de Wifi",
+    "Wifi-Einstellungen",
+    "Configuration Wifi",
+    "Impostazione Wifi",
+    "Wifi設定",
+} ;
+
+
+
 const char* language_serve_manage[LANG_MAX] = 
 {
     "服务管理",

+ 2 - 0
pro/src/language_common.h

@@ -27,6 +27,8 @@ extern const char* language_log_running[LANG_MAX];
 extern const char* language_communication_management[LANG_MAX];
 extern const char* language_net_install[LANG_MAX];
 extern const char* language_RS485_install[LANG_MAX];
+extern const char* language_4G_install[LANG_MAX] ;
+extern const char* language_WIFI_install[LANG_MAX];
 extern const char* language_serve_manage[LANG_MAX];
 extern const char* language_SMTP_install[LANG_MAX];
 extern const char* language_SNMP_install[LANG_MAX];

+ 138 - 0
pro/src/paras.c

@@ -965,6 +965,118 @@ static int proc_misc(dictionary *dic, int op, MiscInfo_t *misc)
 }
 
 
+static int proc_CellularWIFIcfg(dictionary *dic, int op, CellularManager *pcellularManager,WIFIManager *pWIFIManager)
+{
+    int r=0;
+    char temp[100];
+    char *p,*token=NULL;
+
+    if(op==PARAS_CHECK) {
+        if(pcellularManager->mode<0 || pcellularManager->mode>1) {
+            LOGE("___ check CellularManager, mode is invalid, correct value is 0/1\n");
+            r = -1; 
+        }
+
+        if (pWIFIManager->mode < 0 || pWIFIManager->mode > 1)
+        {
+            LOGE("___ check WIFIManager, mode is invalid, correct value is 0/1\n");
+            r = -1;
+        }
+        return r;
+    }
+    else if (op==PARAS_CREATE) {
+
+    }
+    else if (op==PARAS_WRITE) {
+        r = proc_CellularWIFIcfg(dic, PARAS_CHECK, pcellularManager,pWIFIManager);
+        if(r) {
+            return -1;
+        }
+
+    }
+
+    token = "CellularWIFIcfg:Cellular";
+    if(op==PARAS_READ) {
+        r = iniparser_getint(dic, token, -1);
+        if(r==-1) {
+            LOGE("___ iniparser_getint %s failed\n", token);
+            return -1;
+        } else {
+            pcellularManager->mode = r;
+        }
+    }
+    else {
+        sprintf(temp, "%d",  pcellularManager->mode);
+        r = iniparser_set(dic, token, temp);
+        if(r) {
+            LOGE("___ iniparser_set %s failed\n", token);
+            return -1;
+        }
+    }
+
+    token = "CellularWIFIcfg:WIFI";
+    if(op==PARAS_READ) {
+        r = iniparser_getint(dic, token, -1);
+        if(r==-1) {
+            LOGE("___ iniparser_getint %s failed\n", token);
+            return -1;
+        } else {
+            pWIFIManager->mode = r;
+        }
+    }
+    else {
+        sprintf(temp, "%d", pWIFIManager->mode);
+        r = iniparser_set(dic, token, temp);
+        if(r) {
+            LOGE("___ iniparser_set %s failed\n", token);
+            return -1;
+        }
+    }
+
+    token = "CellularWIFIcfg:WIFI_ssid";
+    if(op==PARAS_READ) {
+        p = (char*)iniparser_getstring(dic, token, NULL);
+        if(!p) {
+            LOGE("___ iniparser_getstring %s failed\n", token);
+            return -1;
+        } else {
+            strcpy(pWIFIManager->WIFI_name, p);
+        }
+    }
+    else {
+        r = iniparser_set(dic, token, pWIFIManager->WIFI_name);
+        if(r) {
+            LOGE("___ iniparser_set %s failed\n", token);
+            return -1;
+        }
+    }
+
+    token = "CellularWIFIcfg:WIFI_pw";
+    if(op==PARAS_READ) {
+        p = (char*)iniparser_getstring(dic, token, NULL);
+        if(!p) {
+            LOGE("___ iniparser_getstring %s failed\n", token);
+            return -1;
+        } else {
+            strcpy(pWIFIManager->WIFI_code, p);
+        }
+    }
+    else {
+        r = iniparser_set(dic, token, pWIFIManager->WIFI_code);
+        if(r) {
+            LOGE("___ iniparser_set %s failed\n", token);
+            return -1;
+        }
+    }
+
+    r = 0;
+    if(op==PARAS_READ) {
+        r = proc_CellularWIFIcfg(dic, PARAS_CHECK, pcellularManager,pWIFIManager);
+    }
+
+    return r;
+}
+
 static int proc_ntp(char *path, int op, NTPManager *ntp)
 {
     int r=0;
@@ -3318,6 +3430,11 @@ static dictionary* ini_load(char *path, GlobalDeviceInfo *info)
         LOGE("___proc_webcfg failed\n");
     }
 
+    r = proc_CellularWIFIcfg(dic, PARAS_READ, &_globalCellularManager,&_globalWIFIManager);
+    if(r) {
+        LOGE("___proc_CellularWIFI failed\n");
+    }
+
     r = proc_misc(dic, PARAS_READ, &info->misc);
     if(r) {
         LOGE("___proc_misc failed\n");
@@ -3539,7 +3656,28 @@ int paras_save(void)
     
     return r;
 }
+int CellularWIFI_paras_save(void)
+{
+    int r = 0;
+    paras_handle_t *h = &paraHandle;
 
+    r = proc_CellularWIFIcfg(h->dic, PARAS_WRITE, &_globalCellularManager, &_globalWIFIManager);
+    if (r)
+    {
+        LOGE("___ini_w_dev failed\n");
+    }
+
+    FILE *fp = fopen(h->path, "w");
+    if (!fp)
+    {
+        LOGE("___%s open failed\n", h->path);
+        return -1;
+    }
+    iniparser_dump_ini(h->dic, fp);
+    fclose(fp);
+
+    return r;
+}
 
 int paras_serv_xport(char *path, int io)
 {

+ 1 - 0
pro/src/paras.h

@@ -31,6 +31,7 @@ int paras_load(char *path);
 int paras_reset(void);
 int paras_copy(char *dst, char *src);
 int paras_save(void);
+int CellularWIFI_paras_save(void);
 
 int paras_serv_xport(char *path, int io);
 int paras_alarm_xport(char *path, int io);

+ 2 - 1
pro/src/sqlite_handle.c

@@ -3248,7 +3248,8 @@ int dev_get_snmp_info(sqlite3 *db, SNMPManager* _globalSNMPInfo)
     _globalSNMPInfo->mode = atoi(pResult[rowIndex*ncolumn+2]); 
     strcpy(_globalSNMPInfo->public,pResult[rowIndex*ncolumn+3]);
     _globalSNMPInfo->trapmode = atoi(pResult[rowIndex*ncolumn+4]);
-    if(_globalSNMPInfo->version==2) {
+    //if(_globalSNMPInfo->version==2) 
+    {
         if(pResult[rowIndex*ncolumn+5]) strcpy(_globalSNMPInfo->crypt.user,pResult[rowIndex*ncolumn+5]);
         if(pResult[rowIndex*ncolumn+6]) strcpy(_globalSNMPInfo->crypt.auth.alg,pResult[rowIndex*ncolumn+6]);
         if(pResult[rowIndex*ncolumn+7]) strcpy(_globalSNMPInfo->crypt.auth.passwd,pResult[rowIndex*ncolumn+7]);

+ 1 - 0
pro/src/thread.c

@@ -21,6 +21,7 @@ static thread_attr_t thdAttrs[THREAD_ID_MAX]={
     {"modbus_tcp",  NULL,           NULL,           8*MB,           1},
     {"board",       NULL,           NULL,           8*MB,           1},
     {"ui",          NULL,           NULL,           8*MB,           1},
+    {"Cellular",          NULL,           NULL,           8*MB,           1},
 };
 static thread_handle_t thdHandles[THREAD_ID_MAX]={0};
 

+ 2 - 1
pro/src/thread.h

@@ -32,7 +32,8 @@ enum {
     THREAD_ID_TCP,
     THREAD_ID_BOARD,        //board upgrade
     THREAD_ID_UI,
-    
+    THREAD_ID_Cellular,
+
     THREAD_ID_MAX
 };
 

+ 34 - 0
pro/src/websocket_handle.c

@@ -239,6 +239,34 @@ static int ws_upg_update(ws_handle_t *h)
 
     return 0;
 }
+
+static int ws_Cellular_update(ws_handle_t *h)
+{
+    char *json;
+
+    json = communication_4G_ack_to_json(&_globalCellularManager,1);
+    if(json) {
+        ws_send_data(h, json, strlen(json));
+        cJSON_free(json);
+    }
+
+    return 0;
+}
+
+static int ws_WIFI_update(ws_handle_t *h)
+{
+    char *json;
+
+    json = communication_WIFI_ack_to_json(&_globalWIFIManager,1);
+    if(json) {
+        ws_send_data(h, json, strlen(json));
+        cJSON_free(json);
+    }
+
+    return 0;
+}
+
+
 /////////////////////////////////////////////////////////////
 
 static int ws_update(ws_handle_t *h)
@@ -264,6 +292,12 @@ static int ws_update(ws_handle_t *h)
     //threshold update
     //r = ws_threshold_update();
 
+    //cellular refresh
+    r = ws_Cellular_update(h);
+
+    //wifi refresh
+    r = ws_WIFI_update(h);
+
     //upgrade refresh
     r = ws_upg_update(h);