Sfoglia il codice sorgente

处理腾讯云与短信发送与模版参数对应的关系,以及无开关监测显示的bug。

liyi 8 mesi fa
parent
commit
89301a939b

+ 33 - 0
pro/config/cfg.h

@@ -58,6 +58,8 @@
 //#define PRJ_IP_GANGKEDA_AC_I3_O1
 //#define PRJ_709_AC_I3_O1_OLED
 
+//#define PRJ_TCT_AC_I3_O1
+
 #define USE_MAIL
 #define MAIL_SEND_BUILTIN
 
@@ -245,6 +247,10 @@
     #define USE_NF_CTRL
 
     #define PROD_POWER_TYPE                     3
+    #define SENSOR_ACCESS_NONE
+    #define USE_BEEP                            1
+    #define USE_LED                             1
+
 #elif defined PRJ_HYPERTEC_AC_I3_O1
     //ac_in3_out1_36ch_nologo_en_hypertec
 
@@ -314,6 +320,9 @@
     #define CHANNEL_DELAY                       8
 
     #define PROD_POWER_TYPE                     0
+    #define SENSOR_ACCESS_NONE
+    #define USE_BEEP                            1
+    #define USE_LED                             1
     //#define IN_INDEX_MAP                        {2,3,1,0}
 #elif defined PRJ_2405_AC_I1_O1_OLED
     #define LANGUAGE                            0           //chinese
@@ -431,6 +440,29 @@
     #define CHANNEL_DELAY                       8
 
     #define PROD_POWER_TYPE                     5
+    #define SENSOR_ACCESS_NONE
+#elif defined PRJ_TCT_AC_I3_O1
+    #define LANGUAGE 1      // //english
+    #define SMPLE_TIME 30   // ms
+    #define SAVE_TIME 60000 // ms
+    #define CASCADE_CNT 0
+
+    #define PHASE_GROUP 6
+    #define CHANNEL_DELAY 6
+
+    #define PROD_POWER_TYPE 5
+
+    #define USE_WATCHDOG
+    //#define USE_LOGO_GOWONE
+    #define ROTATE 180
+
+    #define USE_BEEP                            1
+    #define USE_LED                             1
+
+    #define BRD_MAX                             3               
+
+    #define SENSOR_ACCESS_NONE
+
 #elif defined PRJ_TEST_AC_I3_O3
     #define LANGUAGE                            0           //chinese
     #define SMPLE_TIME                          30          //ms
@@ -465,6 +497,7 @@
     #define BRD_MAX                             10                
 
     #define SENSOR_ACCESS_NONE
+    #define DRY_NONE                            1
 
 #elif defined PRJ_Malaysia_AC_I3_O1
     #define LANGUAGE 1      // //english

+ 160 - 5
pro/src/app.c

@@ -38,7 +38,7 @@
 #include "broadcast.h"
 #include "radius.h"
 #include "tencent_sms.h"
-
+static void set_shm_sms_sensor_info(GlobalDeviceManager* globalDeviceManger,GlobalSensorManger* __sensorTemp,uint8_t sms_temp_type);
 
 static void* power_thread(void* arg)
 {
@@ -1845,6 +1845,75 @@ void sensor_alarm(GlobalSensorManger *_globalSensorMangerTemp, int nAlarmType,in
             if (!*pSave)
             {
                 *pSave = true;
+
+                switch(_globalSensorMangerTemp->sensor_type)
+                {
+                    case SENSOR_TYPE_TEMP_HUMI:
+                    {
+                        if(nAlarmType == SENSOR_VAL2_UPPER)
+                        {
+                            set_shm_sms_sensor_info(&__globalDeviceManage,_globalSensorMangerTemp,SMS_PDU_HUMI);
+                        }else
+                        {
+                            set_shm_sms_sensor_info(&__globalDeviceManage,_globalSensorMangerTemp,SMS_PDU_TEMP);
+                        }
+                    }
+                    break;
+                    case SENSOR_TYPE_SMOKE:
+                    {
+                        set_shm_sms_sensor_info(&__globalDeviceManage,_globalSensorMangerTemp,SMS_PDU_SMOKE);
+                    }
+                    break;
+                    case SENSOR_TYPE_WATER:
+                    {
+                        set_shm_sms_sensor_info(&__globalDeviceManage,_globalSensorMangerTemp,SMS_PDU_WATER);
+                    }
+                    break;
+                    case SENSOR_TYPE_ACCESS:
+                    {
+                        set_shm_sms_sensor_info(&__globalDeviceManage,_globalSensorMangerTemp,SMS_PDU_ACCESS);
+                    }
+                    break;
+                    case SENSOR_TYPE_GAS:
+                    {
+//                        set_shm_sms_sensor_info(&__globalDeviceManage,_globalSensorMangerTemp,SMS_PD);
+                    }
+                    break;
+                    case SENSOR_TYPE_AIR_PRESS:
+                    {
+
+                    }
+                    break;
+                    case    SENSOR_TYPE_AIR_COND:
+                    break;
+                    case    SENSOR_TYPE_LEAK:
+                    {
+
+                    }
+                    break;
+                    case SENSOR_TYPE_TEMP:
+                    {
+
+                    }
+                    break;
+                    case SENSOR_TYPE_TEMP_DOUBLE:
+                    {
+                        // if(nAlarmType == SENSOR_VAL2_UPPER)
+                        // {
+                        //     set_shm_sms_sensor_info(&__globalDeviceManage,_globalSensorMangerTemp,SMS_PDU_HUMI);
+                        // }else
+                        // {
+                            set_shm_sms_sensor_info(&__globalDeviceManage,_globalSensorMangerTemp,SMS_PDU_TEMP);
+//                        }
+                    }
+                    break;
+                    case SENSOR_TYPE_PRESS:
+                    break;
+                    default:
+                        break;
+                }
+
+                
                 log_d("Sensor_Alarm CtrlType=%d,value=%s",*nCtrlType,strCtrlValue);
                 dev_sensor_Alarm_send_message(&__globalDeviceManage, _globalSensorMangerTemp, nAlarmType);
                 //保存
@@ -2169,6 +2238,92 @@ static int compare_uint8_s(const void *a,const void *b)
 }
 
 
+static void set_shm_sms_sensor_info(GlobalDeviceManager* globalDeviceManger,GlobalSensorManger* __sensorTemp,uint8_t sms_temp_type)
+{
+#if 0
+    tencentcloud_sms_t *sms = &globalDeviceManger->g_shm_Data->cloud_sms;
+    //cloud_mesage_t cloud_shm = {0};
+    cloud_mesage_t *cloud = &sms->c_msg;
+
+    int isLastIndex=-1;//判断最后一个空闲的索引位置
+    for (size_t i = 0; i < 10; i++)
+    {
+        if (cloud->status[i] == 0 || cloud->status[i] == 2)
+        {
+            isLastIndex = i;
+            break;
+        }
+    }    
+    if(isLastIndex == -1)
+    {
+        
+        if (globalDeviceManger->g_cloud_sms_lastIndex < 9 && globalDeviceManger->g_cloud_sms_lastIndex >= 0)
+        {
+            globalDeviceManger->g_cloud_sms_lastIndex++;
+        }
+        else
+        {
+            globalDeviceManger->g_cloud_sms_lastIndex = 0;
+        }
+        isLastIndex = globalDeviceManger->g_cloud_sms_lastIndex;
+    }
+    char temp[64] = {0};
+    sprintf(temp,"%s %s",globalDeviceManger->_globalDevInfo.product.pnumber,globalDeviceManger->_globalDevInfo.product.number);
+    strcpy(cloud->cloud_msg[isLastIndex].pdu_name,temp);        // pdu name
+    switch(sms_temp_type)
+    {
+        case SMS_PDU_AIR_PRESSURE:
+        case SMS_PDU_AIR_FLOW:
+        {
+            cloud->cloud_msg[isLastIndex].sms_type = sms_temp_type;
+            memset(cloud->cloud_msg[isLastIndex].info.air.name,0,64);
+            strcpy(cloud->cloud_msg[isLastIndex].info.air.name,__sensorTemp->sensor_name);
+            cloud->cloud_msg[isLastIndex].info.air.over = __sensorTemp->Cur_sensor_info.val1 
+                    -  __sensorTemp->over_manager.sensor_val1_upper_threshold;
+            cloud->cloud_msg[isLastIndex].info.air.limit = __sensorTemp->over_manager.sensor_val1_upper_threshold;
+            cloud->cloud_msg[isLastIndex].info.air.current =  __sensorTemp->Cur_sensor_info.val1;            
+        }
+            break;
+        case SMS_PDU_ACCESS:
+        case SMS_PDU_WATER:
+        case SMS_PDU_SMOKE:
+        {
+            cloud->cloud_msg[isLastIndex].sms_type = sms_temp_type;
+            memset(cloud->cloud_msg[isLastIndex].info.dry.name,0,64); 
+            strcpy(cloud->cloud_msg[isLastIndex].info.dry.name,__sensorTemp->sensor_name);
+        }
+            break; 
+        case SMS_PDU_HUMI:
+        {
+            cloud->cloud_msg[isLastIndex].sms_type = sms_temp_type;
+            memset(cloud->cloud_msg[isLastIndex].info.humi_temp.name,0,64);
+            strcpy(cloud->cloud_msg[isLastIndex].info.humi_temp.name,__sensorTemp->sensor_name);
+            cloud->cloud_msg[isLastIndex].info.humi_temp.over = __sensorTemp->Cur_sensor_info.val2 
+                    -  __sensorTemp->over_manager.sensor_val1_upper_threshold;
+            cloud->cloud_msg[isLastIndex].info.humi_temp.limit = __sensorTemp->over_manager.sensor_val2_upper_threshold;
+            cloud->cloud_msg[isLastIndex].info.humi_temp.current =  __sensorTemp->Cur_sensor_info.val2;   
+        }
+        break;
+        case SMS_PDU_TEMP:
+        {
+            cloud->cloud_msg[isLastIndex].sms_type = sms_temp_type;
+            memset(cloud->cloud_msg[isLastIndex].info.humi_temp.name,0,64);
+            strcpy(cloud->cloud_msg[isLastIndex].info.humi_temp.name,__sensorTemp->sensor_name);
+            cloud->cloud_msg[isLastIndex].info.humi_temp.over = __sensorTemp->Cur_sensor_info.val1 
+                    -  __sensorTemp->over_manager.sensor_val1_upper_threshold;
+            cloud->cloud_msg[isLastIndex].info.humi_temp.limit = __sensorTemp->over_manager.sensor_val1_upper_threshold;
+            cloud->cloud_msg[isLastIndex].info.humi_temp.current =  __sensorTemp->Cur_sensor_info.val1;             
+        }
+        break;
+        default:
+        return;
+    }
+    cloud->status[isLastIndex] = 1;    
+#endif
+}
+
+
+
 /// @brief 传感器采集线程
 /// @param arg 
 /// @return 
@@ -2350,7 +2505,7 @@ static void* sensor_thread(void* arg)
             case SENSOR_TYPE_WATER: // 水浸
             case SENSOR_TYPE_ACCESS: // 门禁 IO信号
             {
-#if DRY_NONE
+#ifndef DRY_NONE
                 if (_globalSensorMangerTemp->sensor_interface_type==2)//干节点传感器
                 {
                     int nStatus=-1;
@@ -2654,7 +2809,7 @@ static void* sensor_thread(void* arg)
             {
                 _globalSensorMangerTemp->Cur_sensor_info.product_log_time = now;
                 // 插入数据库
-#if DRY_NONE
+#ifndef DRY_NONE
                     if(_globalSensorMangerTemp->sensor_interface_type!=2)
                     {
                         ret = dev_insert_sensor_info(_globalDeviceManager->db, &_globalSensorMangerTemp->Cur_sensor_info, &nSaveIndex);
@@ -2673,7 +2828,7 @@ static void* sensor_thread(void* arg)
             }
             if (_globalSensorMangerTemp->sensor_status == 0)
             {
-#if (defined DRY_NONE)
+#ifdef DRY_NONE
             if(_globalSensorMangerTemp->sensor_interface_type!=2)
             {
                 sensor_alarm(_globalSensorMangerTemp, SENSOR_VAL1_UPPER,&nSaveIndex);
@@ -3748,7 +3903,7 @@ int app_init(void)
 
     broadcast_init();
 
-#if 0
+#if 1
     tencent_sms_init();
 #endif
     

+ 10 - 2
pro/src/appweb_handle.c

@@ -4757,6 +4757,7 @@ static void serviceManagement(void *conn)
             }
         }
     }
+#if 0
     else if(strcmp(_serviceManageRequestInfo.type,"listCloudSms")==0)
     {
         ack_str = service_cloud_ack_to_json(&gdm->tencent_sms);
@@ -4866,6 +4867,7 @@ static void serviceManagement(void *conn)
         }
         ack_str = ctrl_sts_ack_to_json();
     }  
+#endif
     else if(strcmp(_serviceManageRequestInfo.type,"listRadius")==0)
     {
         radius_config_t conf = radius_get();                //802.1X
@@ -6113,7 +6115,7 @@ static void systemManagent(void *conn)
             dev_delete_user_info(__globalDeviceManage.db, _UserRoleManageRequestInfo.userIds);
             //  pUserlist = strtok_r(NULL, ",", &pUserListSave);
             // }
-
+            
             char temp[100];
             // sprintf(temp, "$删除$|$用户$|%d", _UserRoleManageRequestInfo.userIds);
 
@@ -6168,6 +6170,7 @@ static void systemManagent(void *conn)
 
             if (existFlag)
             {
+                free(new_user);
                 ack_str = ctrl_breaker_err_ack_to_json("User already exists!");
             }
             else
@@ -6193,10 +6196,15 @@ static void systemManagent(void *conn)
                 char *user = getUserNamebyToken(_UserRoleManageRequestInfo.user_token);
                 dev_insert_alarm_ctrl(__globalDeviceManage.db, __globalDeviceManage._globalDevInfo.product.id, ALARM_TYPE_OPRATION, temp,user);
                 
+                list_add_tail(&new_user->list,&_g_User_list.list);
+
+
                 ack_str=ctrl_sts_ack_to_json();
+
+                
             }
         }       
-        free(new_user);
+        
         UserInfo *node;
         UserInfo *next;
         list_for_each_entry_safe(node, next, &User_list.list, list)

+ 82 - 0
pro/src/common.h

@@ -513,6 +513,86 @@ typedef struct
 ///////////////////////////////////////////////////////////////////////////////////
 //自定义共享内存类
 
+enum{
+    SMS_PDU_NETWORK,
+    SMS_PDU_AIR_PRESSURE,
+    SMS_PDU_AIR_FLOW,
+    SMS_PDU_ACCESS,
+    SMS_PDU_WATER,
+    SMS_PDU_SMOKE,
+    SMS_PDU_HUMI,
+    SMS_PDU_TEMP,
+    SMS_PDU_3_LEAK,
+    SMS_PDU_CONSUMER,
+    SMS_PDU_POWER,
+    SMS_PDU_CURRENT,
+    SMS_PDU_VOLTAGE_UP,
+    SMS_PDU_VOLTAGE_LOW,
+};
+
+
+typedef struct
+{
+    char wanning[64];
+}sms_network_t;
+
+typedef struct{
+    char name[64];
+    float over;
+    float current;
+    float limit;
+}sms_air_t;
+
+
+
+typedef struct{
+    char name[64];
+}sms_dry_t;
+
+typedef struct{
+    char name[64];
+}sms_leak_t;
+
+typedef struct{
+    char name[64];
+    float over;
+    float current;
+    float limit;
+}sms_humi_temp_t;
+
+typedef struct {
+    char name[64];
+    float ele_val1;
+    float ele_val2;
+}sms_ele_t;
+
+
+typedef union {
+    sms_network_t        network;
+    sms_air_t            air;
+    sms_dry_t            dry;
+    sms_humi_temp_t      humi_temp;
+    sms_ele_t            elec;
+    sms_leak_t           leak;
+}sms_info_t;
+
+
+typedef struct
+{
+    char pdu_name[64];
+    uint8_t sms_type;
+    sms_info_t   info;
+}cloud_sms_info_t;
+
+
+typedef struct {
+    uint8_t status[10];
+    //char    cloudMSG[10][64];
+    cloud_sms_info_t cloud_msg[10];
+}cloud_mesage_t;
+
+
+
 typedef struct{
     uint8_t status;                     
     uint8_t phone_cnt;
@@ -525,6 +605,7 @@ typedef struct{
     char country[64];
     char region[64];
     char phone[20][64];
+    cloud_mesage_t c_msg; 
 }tencentcloud_sms_t;
 
 
@@ -1465,6 +1546,7 @@ typedef struct
     cascade_north_user_t north_user;
 #endif
     cloud_info_t        tencent_sms;
+    int                 g_cloud_sms_lastIndex; //最后一次报警索引位置
 }GlobalDeviceManager;
 
 extern GlobalDeviceManager __globalDeviceManage;

+ 1 - 1
pro/src/dflt.c

@@ -175,7 +175,7 @@ tencent_cloud_info_t DFLT_TENCENT_CLOUD_INFO={
     .secret_key ="",
     .signature = "",
     .app_id = "",
-    .country_code = "+86",
+    .country_code = "86",
     .url = "sms.tencentcloudapi.com",
     .template="",
     .region="",

+ 9 - 9
pro/src/json_handle.c

@@ -3184,15 +3184,15 @@ char* over_all_breaker_switch_info_to_json(_OverBreakerSwitchInfo* _over_all_bre
         cJSON_AddItemToObject(data_root_array, "data", data_filed);
     }
 
-    if(list_empty(&_over_all_breaker_switch_info->list))
-    {
-        cJSON* data_filed = cJSON_CreateObject();
-        // cJSON_AddStringToObject(data_filed, "productName",_temp->productName);
-        // cJSON_AddNumberToObject(data_filed,"productId",_temp->product_id);
-        // cJSON_AddStringToObject(data_filed, "productNumber",_temp->product_number);
-        // cJSON_AddStringToObject(data_filed, "productChNames",_temp->product_ch_name);
-        cJSON_AddItemToObject(data_root_array, "data", data_filed);
-    }
+    // if(list_empty(&_over_all_breaker_switch_info->list))
+    // {
+    //     cJSON* data_filed = cJSON_CreateObject();
+    //     // cJSON_AddStringToObject(data_filed, "productName",_temp->productName);
+    //     // cJSON_AddNumberToObject(data_filed,"productId",_temp->product_id);
+    //     // cJSON_AddStringToObject(data_filed, "productNumber",_temp->product_number);
+    //     // cJSON_AddStringToObject(data_filed, "productChNames",_temp->product_ch_name);
+    //     cJSON_AddItemToObject(data_root_array, "data", data_filed);
+    // }
     if (nWSType)
     {
         // 添加汇总

+ 131 - 7
pro/src/sqlite_handle.c

@@ -2969,7 +2969,11 @@ static void AlarmToShm(char* strData)
                 _globalDeviceManager->g_shm_Data->nTypeCtrlType[_globalDeviceManager->g_lastAlarmIndex]=1;//设置更新了一个报警
                 memset(_globalDeviceManager->g_shm_Data->strMSG[_globalDeviceManager->g_lastAlarmIndex],0,nMAXLens);
                 strcpy(_globalDeviceManager->g_shm_Data->strMSG[_globalDeviceManager->g_lastAlarmIndex], strSave);
-
+#if(CHIP_TYPE == CHIP_T113i)
+//                _globalDeviceManager->g_shm_Data->cloud_sms.c_msg.status[_globalDeviceManager->g_lastAlarmIndex]=1;//设置更新了一个报警
+//                memset(_globalDeviceManager->g_shm_Data->cloud_sms.c_msg.cloudMSG[_globalDeviceManager->g_lastAlarmIndex],0,nMAXLens);
+//                strcpy(_globalDeviceManager->g_shm_Data->cloud_sms.c_msg.cloudMSG[_globalDeviceManager->g_lastAlarmIndex], strSave);
+#endif
             }
             else // 未被全部占满则使用空闲位置添加
             {
@@ -2978,12 +2982,28 @@ static void AlarmToShm(char* strData)
                     _globalDeviceManager->g_shm_Data->nTypeCtrlType[isLastIndex] = 1; // 设置更新了一个报警
                     strcpy(_globalDeviceManager->g_shm_Data->strMSG[isLastIndex], strSave);
                     _globalDeviceManager->g_lastAlarmIndex = isLastIndex;
+#if(CHIP_TYPE == CHIP_T113i)            //cloud mesaage
+//                _globalDeviceManager->g_shm_Data->cloud_sms.c_msg.status[isLastIndex]=1;//设置更新了一个报警
+//                memset(_globalDeviceManager->g_shm_Data->cloud_sms.c_msg.cloudMSG[isLastIndex],0,nMAXLens);
+//                strcpy(_globalDeviceManager->g_shm_Data->cloud_sms.c_msg.cloudMSG[isLastIndex], strSave);
+#endif
                 }
             }
         }
     }
 }
 
+/////////////////////////////////////////////////////////////////
+
+
+
+
+
+
+
+
+
+
 /// @brief 插入一条告警信息
 /// @param db 
 /// @param product_id 
@@ -4061,6 +4081,103 @@ void get_message_CtrlType(int nCtrlType,char* message)
     }
 }
 
+static void set_shm_sms_ele_info(GlobalDeviceManager* globalDeviceManger,GlobalPowerManger* __globalPowerTemp,uint8_t sms_temp_type)
+{
+#if 0
+    tencentcloud_sms_t *sms = &globalDeviceManger->g_shm_Data->cloud_sms;
+    //cloud_mesage_t cloud_shm = {0};
+    cloud_mesage_t *cloud = &sms->c_msg;
+
+    int isLastIndex=-1;//判断最后一个空闲的索引位置
+    for (size_t i = 0; i < 10; i++)
+    {
+        if (cloud->status[i] == 0 || cloud->status[i] == 2)
+        {
+            isLastIndex = i;
+            break;
+        }
+    }    
+    if(isLastIndex == -1)
+    {
+        
+        if (globalDeviceManger->g_cloud_sms_lastIndex < 9 && globalDeviceManger->g_cloud_sms_lastIndex >= 0)
+        {
+            globalDeviceManger->g_cloud_sms_lastIndex++;
+        }
+        else
+        {
+            globalDeviceManger->g_cloud_sms_lastIndex = 0;
+        }
+        isLastIndex = globalDeviceManger->g_cloud_sms_lastIndex;
+    }
+    char temp[64] = {0};
+    sprintf(temp,"%s %s",globalDeviceManger->_globalDevInfo.product.pnumber,globalDeviceManger->_globalDevInfo.product.number);
+    strcpy(cloud->cloud_msg[isLastIndex].pdu_name,temp);        // pdu name
+    switch(sms_temp_type)
+    {
+        case SMS_PDU_3_LEAK:
+        {
+            cloud->cloud_msg[isLastIndex].sms_type = sms_temp_type;
+            memset(cloud->cloud_msg[isLastIndex].info.leak.name,0,64);
+            strcpy(cloud->cloud_msg[isLastIndex].info.leak.name,__globalPowerTemp->product_ch_name);        //chn name;
+        }
+        break;
+        case SMS_PDU_CONSUMER:
+        {
+            cloud->cloud_msg[isLastIndex].sms_type = sms_temp_type;
+            memset(cloud->cloud_msg[isLastIndex].info.elec.name,0,64);
+            strcpy(cloud->cloud_msg[isLastIndex].info.elec.name,__globalPowerTemp->product_ch_name);        //chn name;
+            cloud->cloud_msg[isLastIndex].info.elec.ele_val1 = __globalPowerTemp->_PowerInfo.consumption;
+            cloud->cloud_msg[isLastIndex].info.elec.ele_val2 = __globalPowerTemp->global_over_manager.product_pwrcon_upper_threshold;
+        }
+        break;
+        case SMS_PDU_POWER:
+        {
+            cloud->cloud_msg[isLastIndex].sms_type = sms_temp_type;
+            memset(cloud->cloud_msg[isLastIndex].info.elec.name,0,64);
+            strcpy(cloud->cloud_msg[isLastIndex].info.elec.name,__globalPowerTemp->product_ch_name);        //chn name;
+            cloud->cloud_msg[isLastIndex].info.elec.ele_val1 = __globalPowerTemp->_PowerInfo.power;
+            cloud->cloud_msg[isLastIndex].info.elec.ele_val2 = __globalPowerTemp->global_over_manager.product_pwr_upper_threshold;           
+        }
+        break;
+        case SMS_PDU_CURRENT:
+        {
+            cloud->cloud_msg[isLastIndex].sms_type = sms_temp_type;
+            memset(cloud->cloud_msg[isLastIndex].info.elec.name,0,64);
+            strcpy(cloud->cloud_msg[isLastIndex].info.elec.name,__globalPowerTemp->product_ch_name);        //chn name;
+            cloud->cloud_msg[isLastIndex].info.elec.ele_val1 = __globalPowerTemp->_PowerInfo.current;
+            cloud->cloud_msg[isLastIndex].info.elec.ele_val2 = __globalPowerTemp->global_over_manager.product_cur_upper_threshold;  
+        }
+        break;
+        case SMS_PDU_VOLTAGE_UP:
+        {
+            cloud->cloud_msg[isLastIndex].sms_type = sms_temp_type;
+            memset(cloud->cloud_msg[isLastIndex].info.elec.name,0,64);
+            strcpy(cloud->cloud_msg[isLastIndex].info.elec.name,__globalPowerTemp->product_ch_name);        //chn name;
+            cloud->cloud_msg[isLastIndex].info.elec.ele_val1 = __globalPowerTemp->_PowerInfo.voltage;
+            cloud->cloud_msg[isLastIndex].info.elec.ele_val2 = __globalPowerTemp->global_over_manager.product_vol_upper_threshold;  
+        }
+        break;
+        case SMS_PDU_VOLTAGE_LOW:
+        {
+            cloud->cloud_msg[isLastIndex].sms_type = sms_temp_type;
+            memset(cloud->cloud_msg[isLastIndex].info.elec.name,0,64);
+            strcpy(cloud->cloud_msg[isLastIndex].info.elec.name,__globalPowerTemp->product_ch_name);        //chn name;
+            cloud->cloud_msg[isLastIndex].info.elec.ele_val1 = __globalPowerTemp->_PowerInfo.voltage;
+            cloud->cloud_msg[isLastIndex].info.elec.ele_val2 = __globalPowerTemp->global_over_manager.product_vol_lower_threshold;                       
+        }
+        break;
+        default:
+        return;
+    }
+    cloud->status[isLastIndex] = 1;
+#endif
+}
+
+
+
+
+
 /**
  * @brief 发送设备告警信息
  *
@@ -4093,6 +4210,7 @@ int dev_Alarm_send_message(GlobalDeviceManager* globalDeviceManger,GlobalPowerMa
         if(pwr->_PowerInfo.voltage>LIMIT_HOF(pwr->global_over_manager.product_vol_upper_threshold)) {
             limit_flag = 1;
         }
+        set_shm_sms_ele_info(globalDeviceManger,__globalPowerTemp,SMS_PDU_VOLTAGE_UP);
     }
         break;
     case WARNING_V_DOWN:
@@ -4103,6 +4221,7 @@ int dev_Alarm_send_message(GlobalDeviceManager* globalDeviceManger,GlobalPowerMa
         if(pwr->_PowerInfo.voltage<LIMIT_LOF(pwr->global_over_manager.product_vol_lower_threshold)) {
             limit_flag = 1;
         }
+        set_shm_sms_ele_info(globalDeviceManger,__globalPowerTemp,SMS_PDU_VOLTAGE_LOW);
     }
         break;
     case WARNING_A_UP:
@@ -4113,6 +4232,7 @@ int dev_Alarm_send_message(GlobalDeviceManager* globalDeviceManger,GlobalPowerMa
         if(pwr->_PowerInfo.current>LIMIT_HOF(pwr->global_over_manager.product_cur_upper_threshold)) {
             limit_flag = 1;
         }
+        set_shm_sms_ele_info(globalDeviceManger,__globalPowerTemp,SMS_PDU_CURRENT);
     }        
         break;
     case WARNING_W_UP:
@@ -4123,6 +4243,7 @@ int dev_Alarm_send_message(GlobalDeviceManager* globalDeviceManger,GlobalPowerMa
         if(pwr->_PowerInfo.consumption>LIMIT_HOF(pwr->global_over_manager.product_pwrcon_upper_threshold)) {
             limit_flag = 1;
         }
+        set_shm_sms_ele_info(globalDeviceManger,__globalPowerTemp,SMS_PDU_CONSUMER);
     }
         break;
     case WARNING_P_UP:
@@ -4133,6 +4254,7 @@ int dev_Alarm_send_message(GlobalDeviceManager* globalDeviceManger,GlobalPowerMa
         if(pwr->_PowerInfo.power>LIMIT_HOF(pwr->global_over_manager.product_pwr_upper_threshold)) {
             limit_flag = 1;
         }
+        set_shm_sms_ele_info(globalDeviceManger,__globalPowerTemp,SMS_PDU_POWER);
     }
     break;
     case 0:
@@ -4962,7 +5084,7 @@ int dev_tencent_cloud_get(sqlite3 *db, cloud_info_t *info)
         log_e("sqlite handle error: %s \n%s\n", temp, err_msg); sqlite3_free(err_msg);
         return -1 ;
     }
-
+#if 1
     if(info && ncol>0) {
         tencent_cloud_info_t *info_info=&info->info; 
         memset(info_info, 0, sizeof(tencent_cloud_info_t));
@@ -4977,6 +5099,7 @@ int dev_tencent_cloud_get(sqlite3 *db, cloud_info_t *info)
         strcpy(info_info->country_code, pResult[ncol+8]);
         strcpy(info_info->region, pResult[ncol+9]);
     }
+#endif
     ////////////////////////////////////////////////////////////////////////
 
     table = TENCENT_CLOUD_SMS_PHONE;
@@ -5045,7 +5168,7 @@ int dev_tencent_cloud_init(sqlite3 *db, cloud_info_t *info)
                             "signature TEXT,"
                             "template TEXT,"
                             "countryCode TEXT,"
-                            "region TEXT;", table);    
+                            "region TEXT);", table);    
         r = sqlite3_exec(db, temp, 0, 0, &err_msg);
         if(r!=SQLITE_OK) {
             log_e("___ %s create failed, %s\n%s\n", table, temp, err_msg); sqlite3_free(err_msg);
@@ -5059,7 +5182,7 @@ int dev_tencent_cloud_init(sqlite3 *db, cloud_info_t *info)
     {
         sprintf(temp, "CREATE TABLE IF NOT EXISTS %s("
                             "id INTEGER PRIMARY KEY,"
-                            "phonenumber TEXT,", table);    
+                            "phonenumber TEXT);", table);    
         r = sqlite3_exec(db, temp, 0, 0, &err_msg);
         if(r!=SQLITE_OK) {
             log_e("___ %s create failed, %s\n%s\n", table, temp, err_msg); sqlite3_free(err_msg);
@@ -5070,6 +5193,7 @@ int dev_tencent_cloud_init(sqlite3 *db, cloud_info_t *info)
     
     r = dev_tencent_cloud_get(db, info);
 
+
     return 0;
 }
 
@@ -5127,8 +5251,8 @@ int dev_tencent_cloud_update_info(sqlite3 *db, tencent_cloud_info_t *info)
 
     cnt = get_count(db, table);
     if(cnt>0) {
-        sprintf(temp, "UPDATE %s SET id=%d,status=%d,secretId='%s',secretKey='%s',url='%s',appid='%s',siqnature='%s',template='%s',countryCode='%s' WHERE id=%d;", 
-                table, info->id,info->status,info->secret_id,info->secret_key,info->url,info->app_id,info->signature,info->template,info->country_code,info->id);
+        sprintf(temp, "UPDATE %s SET id=%d,status=%d,secretId='%s',secretKey='%s',url='%s',appid='%s',signature='%s',template='%s',countryCode='%s' region='%s' WHERE id=%d;", 
+                table, info->id,info->status,info->secret_id,info->secret_key,info->url,info->app_id,info->signature,info->template,info->country_code,info->region,info->id);
         r = sqlite3_exec(db, temp, NULL, 0, &err_msg);
         if(r != SQLITE_OK) {
             log_e("dev_tencent_cloud_update_info failed, %s, %s\n\n", temp, err_msg);
@@ -5140,7 +5264,7 @@ int dev_tencent_cloud_update_info(sqlite3 *db, tencent_cloud_info_t *info)
     }
 
     if(exist==0) {
-        sprintf(temp, "INSERT INTO %s (id,status,secretId,secretKey,url,appid,siqnature,template,countryCode) VALUES (?,?,?,?,?,?,?,?,?);", table);
+        sprintf(temp, "INSERT INTO %s (id,status,secretId,secretKey,url,appid,signature,template,countryCode,region) VALUES (?,?,?,?,?,?,?,?,?,?);", table);
         r = sqlite3_prepare_v2(db, temp, -1, &stmt, 0);
         if (r != SQLITE_OK) {
             log_e("dev_tencent_cloud_update_info, sqlite3_prepare_v2 failed, %s\n", sqlite3_errmsg(db));

+ 3 - 0
pro/src/tencent_sms.c

@@ -17,6 +17,7 @@ static tencent_sms_handle_t tsHandle;
 
 int tencent_sms_init()
 {
+#if 0
     tencent_sms_handle_t *h=&tsHandle;
     GlobalDeviceManager *dm=&__globalDeviceManage;
     h->dm = dm;
@@ -48,6 +49,8 @@ int tencent_sms_init()
     strcpy(cloud_sms->template,h->info->info.template);
     strcpy(cloud_sms->url,h->info->info.url);
     strcpy(cloud_sms->region,h->info->info.region);
+
+#endif
     return 0;
 }
 

+ 2 - 1
pro/src/websocket_handle.c

@@ -234,6 +234,7 @@ static int ws_threshold_update(ws_handle_t *h)
     GlobalDeviceManager* dm= &__globalDeviceManage;
     
     if(cur_dev_addr==0) { 
+//        printf("send status!!!!\n");
         json = threshold_status_ack_to_json(dm);
         ws_send_data(h, json, strlen(json));
         cJSON_free(json);
@@ -349,7 +350,7 @@ static int ws_update(ws_handle_t *h)
     r = ws_breaker_update(h);
 
     //threshold update
-    //r = ws_threshold_update();
+    r = ws_threshold_update(h);
 
     //cellular refresh
     r = ws_Cellular_update(h);