mirror of
http://180.163.74.83:13000/zhangzhenghao/AP05.git
synced 2025-12-12 15:04:29 +00:00
add sync time judge upto v1.1.9
This commit is contained in:
parent
b2805dfefe
commit
ae491ab832
5
cp.sh
5
cp.sh
@ -1,4 +1,7 @@
|
||||
sshpass -p "PddloTSecPwdOnly!" scp ./output/bin/tx_server root@192.168.0.148:/home/linaro/
|
||||
#sshpass -p "&Over#B0Ost!" scp ./start.sh root@10.10.10.101:/root/
|
||||
#sshpass -p "&Over#B0Ost!" scp ./output/bin/tx_server root@10.10.10.101:/root/
|
||||
sshpass -p "&Over#B0Ost!" scp ./output/bin/tx_server root@10.10.10.101:/home/linaro/
|
||||
#sshpass -p "PddloTSecPwdOnly!" scp ./output/bin/tx_server root@192.168.0.148:/home/linaro/
|
||||
#sshpass -p "PddloTSecPwdOnly!" scp ./output/bin/tx_server root@10.10.10.132:/root/
|
||||
#sshpass -p "PddloTSecPwdOnly!" scp ./start.sh root@10.10.10.225:/root/
|
||||
#sshpass -p "PddloTSecPwdOnly!" scp ./start.sh root@10.10.10.132:/root/
|
||||
|
||||
32
main.c
32
main.c
@ -36,7 +36,7 @@ int fd;
|
||||
int UPCASE=0;
|
||||
int count_value=0;
|
||||
int getPayloadTime=120*1000;//usecond
|
||||
char softwareVersion[16]="1.1.8";
|
||||
char softwareVersion[16]="1.1.9";
|
||||
char stationsn[16]="TJ251372224247";//TJ250995217957
|
||||
char productid[8]="10045";
|
||||
char appKey[32]="fdhQmhqhvbL1cf1K9mUqt";
|
||||
@ -1487,6 +1487,18 @@ void updateStationInfo(char *msg_id){
|
||||
LOG_I("Time:%s\n",startTime);
|
||||
mqtt_server_station_status_report(msg_id,productid,stationsn,local_ip,softwareVersion,"1",startTime);
|
||||
}
|
||||
|
||||
bool timeNew(){
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
long gettime=tv.tv_sec*1000+tv.tv_usec;
|
||||
LOG_I("gettime:%ld\n",gettime);
|
||||
if(gettime<1744000000000){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//==========================================================================================
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@ -1495,11 +1507,13 @@ int main(int argc, char *argv[])
|
||||
char recv_data[8]={0};
|
||||
char command_buffer[256] = "";
|
||||
int len=0;
|
||||
int getTimeCount=0;
|
||||
char *readresult=NULL;
|
||||
char networktype[32]={0};
|
||||
|
||||
LOG_I("version:%s\n",softwareVersion);
|
||||
system("insmod /system/lib/modules/wk2xxx_spi.ko");
|
||||
//system("busybox udhcpc -i eth0");
|
||||
system("timedatectl set-timezone Asia/Shanghai");
|
||||
uart_open(&uartSend,"/dev/ttyS0");//U12 ttyS0,U14 ttyS4,U21 ttysWK0 U13 ttysWK1 U15 ttysWK2 U22 ttysWK3 U20 ttyS1
|
||||
uart_init(&uartSend,115200,8,1,'N',0);
|
||||
@ -1510,6 +1524,7 @@ int main(int argc, char *argv[])
|
||||
uart_init(&uartRecvBack,115200,8,1,'N',0);
|
||||
//doCommand_help(0, NULL);
|
||||
//sleep(5);
|
||||
#if 1
|
||||
enableWatchDog();
|
||||
ret = pthread_create(&pt_watchdog,NULL,thread_feed_watchdog,NULL);
|
||||
if(ret!=0){
|
||||
@ -1519,7 +1534,7 @@ int main(int argc, char *argv[])
|
||||
LOG_I("pthread_create watchdog success\n");
|
||||
pthread_detach(pt_watchdog);
|
||||
}
|
||||
|
||||
#endif
|
||||
ret = pthread_create(&pt_uart_recv_ack,NULL,thread_uart_recv_ack,NULL);
|
||||
if(ret!=0){
|
||||
LOG_I("pthread_create uart_recv_ack fail\n");
|
||||
@ -1624,11 +1639,18 @@ int main(int argc, char *argv[])
|
||||
readresult=NULL;
|
||||
}
|
||||
|
||||
saveStartUpTime();
|
||||
|
||||
while(1){
|
||||
if((ping("8.8.8.8") == 0)||(ping("8.8.4.4") == 0)){
|
||||
sleep(1);
|
||||
LOG_I("net ok\n");
|
||||
while(!timeNew()){
|
||||
//LOG_I("sleep\n");
|
||||
getTimeCount++;
|
||||
if(getTimeCount==100){
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
saveStartUpTime();
|
||||
ret = pthread_create(&pt_mqtt,NULL,thread_mqtt,NULL);
|
||||
if(ret!=0){
|
||||
LOG_I("pthread_create mqtt fail\n");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user