|
|
@@ -983,6 +983,15 @@ int sys_get_chip_id(int *id)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+int sys_ip_check(char *ip)
|
|
|
+{
|
|
|
+ return ip_check(ip);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
#define MAX_BUFFER_SIZE 4096
|
|
|
static void* plug_thread(void *arg)
|
|
|
@@ -1165,41 +1174,71 @@ static int get_range(struct tm *t, time_t *from, time_t *to, int days)
|
|
|
*to = x2;
|
|
|
return 0;
|
|
|
}
|
|
|
-static void send_check(void)
|
|
|
+struct tm* get_curtime(void)
|
|
|
{
|
|
|
- int r,cnt,type=0;
|
|
|
+ time_t cur = time(NULL);
|
|
|
+ return localtime(&cur);
|
|
|
+}
|
|
|
+static void send_power_data(struct tm *tm)
|
|
|
+{
|
|
|
+ int r,type=0;
|
|
|
char path[200],sub[100];
|
|
|
char tmp1[100],tmp2[100];
|
|
|
- static uint32_t send_cnt=0;
|
|
|
GlobalDeviceManager *dm=&__globalDeviceManage;
|
|
|
static time_t sended_id=0;
|
|
|
+
|
|
|
+ if(tm->tm_hour==0) {
|
|
|
+ time_t from,to;
|
|
|
+ get_range(tm, &from, &to, 1);
|
|
|
|
|
|
- send_cnt++;
|
|
|
- if(send_cnt%SEND_PERIOD==0) {
|
|
|
- time_t cur = time(NULL);
|
|
|
- struct tm *tm = localtime(&cur);
|
|
|
- if(tm->tm_hour==0) {
|
|
|
- time_t from,to;
|
|
|
- get_range(tm, &from, &to, 1);
|
|
|
-
|
|
|
- if(sended_id != from) {
|
|
|
- if(dm->_globalDevInfo.product.pwr_type>=SmartPDU_Tree_AC_Tree) {
|
|
|
- type = 1;
|
|
|
- }
|
|
|
- get_time_str2(tmp1,sizeof(tmp1),from);
|
|
|
- get_time_str2(tmp2,sizeof(tmp2),to);
|
|
|
- sprintf(path, "/tmp/power_%s_%s.csv", tmp1, tmp2);
|
|
|
- if(!file_exist(path)) {
|
|
|
- dev_power_xport(type, from, to, path);
|
|
|
+ if(sended_id != from) {
|
|
|
+ if(dm->_globalDevInfo.product.pwr_type>=SmartPDU_Tree_AC_Tree) {
|
|
|
+ type = 1;
|
|
|
+ }
|
|
|
+ get_time_str2(tmp1,sizeof(tmp1),from);
|
|
|
+ get_time_str2(tmp2,sizeof(tmp2),to);
|
|
|
+ sprintf(path, "/tmp/power_%s_%s.csv", tmp1, tmp2);
|
|
|
+ if(!file_exist(path)) {
|
|
|
+ dev_power_xport(type, from, to, path);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(file_exist(path)) {
|
|
|
+ sprintf(sub, "%s %d power data", dm->_globalDevInfo.product.name, dm->_globalDevInfo.product.id);
|
|
|
+ r = mail_send(sub, NULL, path);
|
|
|
+ if(r==0) {
|
|
|
+ file_remove(path);
|
|
|
+ sended_id = from;
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+static void send_log_data(struct tm *tm)
|
|
|
+{
|
|
|
+ int r,type=0;
|
|
|
+ char path[200],sub[100];
|
|
|
+ char tmp1[100],tmp2[100];
|
|
|
+ GlobalDeviceManager *dm=&__globalDeviceManage;
|
|
|
+ static time_t sended_id=0;
|
|
|
+
|
|
|
+ if(tm->tm_hour==0) {
|
|
|
+ time_t from,to;
|
|
|
+ get_range(tm, &from, &to, 1);
|
|
|
+
|
|
|
+ if(sended_id != from) {
|
|
|
+ get_time_str2(tmp1,sizeof(tmp1),from);
|
|
|
+ get_time_str2(tmp2,sizeof(tmp2),to);
|
|
|
+ //sprintf(path, "/tmp/power_%s_%s.csv", tmp1, tmp2);
|
|
|
+ if(!file_exist(path)) {
|
|
|
+ dev_log_xport(type, from, to, path);
|
|
|
+ }
|
|
|
|
|
|
- if(file_exist(path)) {
|
|
|
- sprintf(sub, "%s %d power data", dm->_globalDevInfo.product.name, dm->_globalDevInfo.product.id);
|
|
|
- r = mail_send(sub, NULL, path);
|
|
|
- if(r==0) {
|
|
|
- file_remove(path);
|
|
|
- sended_id = from;
|
|
|
- }
|
|
|
+ if(file_exist(path)) {
|
|
|
+ //sprintf(sub, "%s %d power data", dm->_globalDevInfo.product.name, dm->_globalDevInfo.product.id);
|
|
|
+ r = mail_send(sub, NULL, path);
|
|
|
+ if(r==0) {
|
|
|
+ file_remove(path);
|
|
|
+ sended_id = from;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1207,6 +1246,19 @@ static void send_check(void)
|
|
|
}
|
|
|
|
|
|
|
|
|
+static void send_check(void)
|
|
|
+{
|
|
|
+ static uint32_t send_cnt=0;
|
|
|
+
|
|
|
+ send_cnt++;
|
|
|
+ if(send_cnt%SEND_PERIOD==0) {
|
|
|
+ struct tm *tm=get_curtime();
|
|
|
+
|
|
|
+ send_power_data(tm);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
static void* polling_thread(void *arg)
|
|
|
{
|
|
|
thread_handle_t *h=(thread_handle_t*)arg;
|