|
|
@@ -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));
|