auto search and light on
This commit is contained in:
parent
985922dd22
commit
561f2e923f
@ -92,8 +92,8 @@ SET(SRC_TX_SERVER
|
||||
${CMAKE_CURRENT_LIST_DIR}/main.c
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(tx_server ${SRC_TX_SERVER})
|
||||
ADD_EXECUTABLE(tx_test ${SRC_TX_SERVER})
|
||||
|
||||
TARGET_LINK_LIBRARIES(tx_server pthread dl)
|
||||
TARGET_LINK_LIBRARIES(tx_test pthread dl)
|
||||
|
||||
|
||||
|
||||
2
cp.sh
2
cp.sh
@ -1,5 +1,5 @@
|
||||
#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.12.235:/root/
|
||||
sshpass -p "&Over#B0Ost!" scp ./output/bin/tx_test root@10.10.12.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/
|
||||
|
||||
87
main.c
87
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.10";
|
||||
char softwareVersion[16]="1.1.0";
|
||||
char stationsn[16]="TJ251372224247";//TJ250995217957
|
||||
char productid[8]="10045";
|
||||
char appKey[32]="fdhQmhqhvbL1cf1K9mUqt";
|
||||
@ -53,6 +53,11 @@ char lightsn2[9]={0};
|
||||
char lightsn3[9]={0};
|
||||
char lightsn4[9]={0};
|
||||
char lightsn5[9]={0};
|
||||
uint32_t Tag1=0;
|
||||
uint32_t Tag2=0;
|
||||
uint32_t Tag3=0;
|
||||
uint32_t Tag4=0;
|
||||
uint32_t Tag5=0;
|
||||
int searchTimeOut=0;
|
||||
int searchTimeOld=0;
|
||||
int searchTimeNew=0;
|
||||
@ -127,7 +132,6 @@ void removeLog(){
|
||||
void enableWatchDog(){
|
||||
system("echo 1 > /sys/class/gpio/export");//watchdog enable pin SGM820
|
||||
system("echo 112 > /sys/class/gpio/export");//feed watchdog pin 113 yellow
|
||||
system("echo 113 > /sys/class/gpio/export");//feed watchdog pin 113 yellow
|
||||
system("echo out > /sys/class/gpio/gpio1/direction");
|
||||
system("echo out > /sys/class/gpio/gpio112/direction");
|
||||
system("echo out > /sys/class/gpio/gpio113/direction");
|
||||
@ -781,6 +785,7 @@ void *actHandleQrcode(void *parm){
|
||||
}
|
||||
#endif
|
||||
}else{
|
||||
#if 0
|
||||
if(strstr(str,"TJ")!=NULL && strlen(str)==27){
|
||||
LOG_I("ok\n");
|
||||
char *result=NULL;
|
||||
@ -800,6 +805,11 @@ void *actHandleQrcode(void *parm){
|
||||
result=strtok_r(NULL,",",&p);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if(strstr(str,"TJ")!=NULL){
|
||||
buffer_to_file("savedDevSn",str,strlen(str),"wb");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
@ -1016,7 +1026,8 @@ void *thread_tag_search_send(void *arg){
|
||||
LOG_I("searchTimeNew:%d\n",searchTimeNew);
|
||||
if((searchTimeNew-searchTimeOld)>=searchTimeOut){
|
||||
isSearchLabelOn=false;
|
||||
search_tag_report();
|
||||
//search_tag_report();
|
||||
test_lighton_search();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1036,8 +1047,9 @@ void *thread_uart_recv_ack(void *arg){
|
||||
LOG_I("ack:%x\n",parm_ack);
|
||||
if(parm_ack==0x2323){
|
||||
if(isLightOn){
|
||||
char *flash=mqtt_parm.msg_flash;
|
||||
char *light=mqtt_parm.msg_lightDuration;
|
||||
char *flash="1";
|
||||
char *light="10";
|
||||
#if 0
|
||||
uint32_t tag1=strtol(lightsn1,NULL,16);
|
||||
uint32_t tag2=strtol(lightsn2,NULL,16);
|
||||
uint32_t tag3=strtol(lightsn3,NULL,16);
|
||||
@ -1063,13 +1075,18 @@ void *thread_uart_recv_ack(void *arg){
|
||||
}else if(strcmp(mqtt_parm.msg_color,"8")==0){
|
||||
changecolor=0;
|
||||
}
|
||||
|
||||
jt_ledctrl_package_t led_ctrl={
|
||||
.s.color=changecolor,
|
||||
.s.sound=atoi(mqtt_parm.msg_sound),
|
||||
.s.flash=atoi(mqtt_parm.msg_flash),
|
||||
};
|
||||
uart_data_send_lighton(&uartSend,led_ctrl.ch,atoi(flash),atoi(light),tag1,tag2,tag3,tag4,tag5,lightsnNum);
|
||||
#endif
|
||||
jt_ledctrl_package_t led_ctrl={
|
||||
.s.color=4,
|
||||
.s.sound=1,
|
||||
.s.flash=1,
|
||||
};
|
||||
uart_data_send_lighton(&uartSend,led_ctrl.ch,atoi(flash),atoi(light),Tag1,Tag2,Tag3,Tag4,Tag5,lightsnNum);
|
||||
isLightOn=false;
|
||||
}
|
||||
|
||||
@ -1575,6 +1592,58 @@ bool timeNew(){
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void test_search(void){
|
||||
LOG_I("%s\n",__func__);
|
||||
isSendComEnd=false;
|
||||
isLightOn=false;
|
||||
isLightOnByRule=false;
|
||||
isLabelUp=false;
|
||||
isSearchLabel=true;
|
||||
searchTimeOut=10;
|
||||
LOG_I("searchTimeOut:%d\n",searchTimeOut);
|
||||
searchTimeOld=getCurrentTime();
|
||||
LOG_I("searchTimeOld:%d\n",searchTimeOld);
|
||||
isSearchLabelOn=true;
|
||||
}
|
||||
|
||||
void test_lighton_search(void){
|
||||
LOG_I("%s\n",__func__);
|
||||
isSendComEnd=false;
|
||||
isLightOn=true;
|
||||
isLightOnByRule=false;
|
||||
isLabelUp=false;
|
||||
isSearchLabel=false;
|
||||
if(tagCount<=5){
|
||||
lightsnNum=tagCount;
|
||||
}else{
|
||||
lightsnNum=5;
|
||||
}
|
||||
LOG_I("tagCount:%d\n",tagCount);
|
||||
LOG_I("lightsnNum:%d\n",lightsnNum);
|
||||
for(int i=0;i<lightsnNum;i++){
|
||||
LOG_I("onlyTags:%08X,%04x\n",onlyTags[i].name,onlyTags[i].battery);
|
||||
if(i==0){
|
||||
Tag1=onlyTags[i].name;
|
||||
}
|
||||
if(i==1){
|
||||
Tag2=onlyTags[i].name;
|
||||
}
|
||||
if(i==2){
|
||||
Tag3=onlyTags[i].name;
|
||||
}
|
||||
if(i==3){
|
||||
Tag4=onlyTags[i].name;
|
||||
}
|
||||
if(i==4){
|
||||
Tag5=onlyTags[i].name;
|
||||
}
|
||||
}
|
||||
tagCount=0;
|
||||
memset(onlyTags,0,sizeof(onlyTags));
|
||||
|
||||
uart_data_send_head_lighton(&uartSend,5,lightsnNum);
|
||||
}
|
||||
//==========================================================================================
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@ -1600,6 +1669,7 @@ int main(int argc, char *argv[])
|
||||
uart_init(&uartRecvBack,115200,8,1,'N',0);
|
||||
//doCommand_help(0, NULL);
|
||||
//sleep(5);
|
||||
system("echo 113 > /sys/class/gpio/export");//113 yellow
|
||||
#if 1
|
||||
enableWatchDog();
|
||||
ret = pthread_create(&pt_watchdog,NULL,thread_feed_watchdog,NULL);
|
||||
@ -1714,10 +1784,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
readresult=NULL;
|
||||
}
|
||||
test_search();
|
||||
|
||||
while(1){
|
||||
if((ping("8.8.8.8") == 0)||(ping("8.8.4.4") == 0)){
|
||||
LOG_I("net ok\n");
|
||||
#if 0
|
||||
while(!timeNew()){
|
||||
//LOG_I("sleep\n");
|
||||
getTimeCount++;
|
||||
@ -1726,6 +1798,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
#endif
|
||||
saveStartUpTime();
|
||||
ret = pthread_create(&pt_mqtt,NULL,thread_mqtt,NULL);
|
||||
if(ret!=0){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user