123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- #include "includes.h"
- #include "lsapi_sys.h"
- APP_DEF app;
- /*
- app_init
- 初始化应用层数据
- */
- void app_init(void){
- ticketReset();
- memset((T_UINT8 *)&app, 0, sizeof(APP_DEF));
- app.media=MEDIA_IDLE;
- app.paraFileReady=TRUE;
- app.psnFileReady=TRUE;
- app.loadVoicePlayAlready=TRUE;
- #ifdef FORCE_ONWORK_STATUS
- app.onWorkZone=1;
- #endif
- }
- /*
- ptQueueComReadTask
- 通用队列读取任务
- 主要负责读取通用队列数据,分析处理
- 包括负责转发需要发送到外部(串口外设)的消息
- 负责转发需要发送到内部(module)的消息
- 负责处理从外部(串口外设)输入的消息
- 负责处理从内部(module)返回的消息
- */
- PT_THREAD (ptQueueComReadTask(pt_timer_t *ptPool, struct pt *pt)){
- static pt_timer_t ptTimer;
- T_UINT8 buffer[TUP_DATA_MAX+EXT_DATA],type;
- T_INT16 len;
- PT_BEGIN(pt);
- while(1){
- ticketDeVote(TICKET_PT_QUECOM);//其实这个没用,因为没消息时肯定就投票了
- while(1){
- len=msgQueueAccept(buffer,sizeof(buffer)-1, Q_OUTER, &type);
- if(len>0){
- buffer[len]=0;
- if(QSUB_COM_TO_OUTTER==type){//msg that need to send to outter(usart)
- outterInfo(buffer, len);
- }else if(QSUB_COM_FROM_OUTTER==type){//process commands from user(usart)
- OutterCmdHandle(buffer, len);
- }
- continue;
- }else break;
- }
- while(1){
- len=msgQueueAccept(buffer,sizeof(buffer)-1, Q_INNER, &type);
- if(len>0){
- buffer[len]=0;
- if(QSUB_COM_TO_INNER==type){//msg that need to send to inner(modem)
- innerInfo(buffer, len);
- }else if(QSUB_COM_FROM_INNER==type){//process commands from inner(modem)
- InnerCmdHandler(buffer, len);
- }
- continue;
- }else break;
- }
- while(1){
- len=msgQueueAccept(buffer,sizeof(buffer)-1, Q_LOG, &type);
- if(len>0){
- buffer[len]=0;
- outterInfo(buffer, len);
- continue;
- }else break;
- }
- ticketVote(TICKET_PT_QUECOM);
- PTTimerStart(ptPool, &ptTimer,1);//should be fast
- PT_WAIT_UNTIL(pt, PTTimerIsExpired(&ptTimer));
- }
- PT_END(pt);
- }
- /*
- MCU升级模式开始,关闭网络及相关业务
- MCU升级模式退出,打开网络及相关业务
- */
- void normalTaskStatus(T_BOOL status){
- //netWorkCtl(status);
- authWorkCtl(status);
- locationWorkCtl(status);
- }
- void sysInfoShow(void){
- static unsigned char cnt=0;
- if(++cnt>=10){
- cnt=0;
- //打印注册,pdp,netif
- wlog_info("[sys]reg:%d,pdp:%d,netif:%d",app.netWork.reg,app.netWork.pdp,app.netWork.netReayd);
- //打印iot验证、业务登录和等待计数
- wlog_info("[sys]iot:%d,login:%d,nextCnt:%d",getIotStatus(),getLoginStatus(),getNextCnt());
- //打印作业状态及上传使用能情况
- wlog_info("[sys]onWork:%d,voice:%d,sos:%d",app.onWorkZone,sut_para.voiceUploadEnable_N,sut_para.sosUpoadEnable_N);
- //打印作业状态和采样实际使用值
- wlog_info("[sys]devT:%d,gnssT:%d,nearT:%d,dataT:%d",app.devSampleTime,app.gnssSampleTime,app.nearSampleTime,app.dataUploadTime);
- //打印参数文件和PSN文件状态
- wlog_info("[sys]fpara:%d,fpsn:%d", app.paraFileReady, app.psnFileReady);
- }
- }
- #include "nmea.h"
- typedef struct{
- unsigned char reg:1;
- unsigned char ppp:1;
- unsigned char iot:1;
- unsigned char auth:1;
- unsigned char ksos:1;
- unsigned char krec:1;
- unsigned char locate:1;
- unsigned int psn;
- unsigned char sdata[4];
- int csq;
- unsigned int lat;
- unsigned int lon;
- int bat;
- short ax;
- short ay;
- short az;
- int step;
- unsigned short mcc;
- unsigned char mnc;
- unsigned short lac;
- unsigned int cellid;
- NEAR_DEF near;
- }TINFO_DEF;
- TINFO_DEF tinfo={
- .reg=0,
- .ppp=0,
- .iot=0,
- .auth=0,
- .ksos=0,
- .krec=0,
- .locate=0,
- .psn=999,
- .sdata[0]=0,
- .sdata[1]=0,
- .sdata[2]=0,
- .sdata[3]=0,
- .csq=-99,
- .lat=999,
- .lon=999,
- .bat=-99,
- .ax=999,
- .ay=999,
- .az=999,
- .step=0,
- .mcc=999,
- .mnc=99,
- .lac=999,
- .cellid=999,
- };
- void getTinfo(void){
- char info[30];
- static T_BOOL nearFlag=FALSE;
- tinfo.psn=sut_psn.psn;
- memcpy(tinfo.sdata,app.bubiaoSerVer,4);
- tinfo.reg=app.netWork.reg;
- tinfo.ppp=app.netWork.netReayd;
- LSAPI_NET_GetCsq(&tinfo.csq);
- tinfo.iot=getIotStatus();
- tinfo.auth=getLoginStatus();
- tinfo.ksos=app.ksos;
- tinfo.krec=app.krec;
- tinfo.locate=nmeaInfo.isGpsValid;
- tinfo.lat=nmeaInfo.Latitude;
- tinfo.lon=nmeaInfo.Longitude;
- tinfo.bat=app.bat;
- tinfo.ax=sut_saveRecDev.record.aspeed_x;
- tinfo.ay=sut_saveRecDev.record.aspeed_y;
- tinfo.az=sut_saveRecDev.record.aspeed_z;
- tinfo.step=sut_saveRecDev.record.steps;
- tinfo.mcc=sut_saveRecDev.record.mcc;
- tinfo.mnc=sut_saveRecDev.record.mnc;
- tinfo.lac=sut_saveRecDev.record.lac;
- tinfo.cellid=sut_saveRecDev.record.cellid;
- if(nearFlag==FALSE){
- if(sut_saveRecNear.record.num==0) memset((unsigned char *)&tinfo.near,0,sizeof(NEAR_DEF));
- else{
- memcpy((unsigned char *)&tinfo.near, &sut_saveRecNear.record.info[0],sizeof(NEAR_DEF));
- nearFlag=TRUE;
- }
- }
- }
- /*用于获取测试数据*/
- void getTestInfo(void){
- char info[100];
- getTinfo();
- snprintf(info, sizeof(info), "<PARA>psn=%d,sdata=%d.%d.%d.%d\r\n",tinfo.psn,tinfo.sdata[0],tinfo.sdata[1],tinfo.sdata[2],tinfo.sdata[3]);
- outterInfo(info, strlen(info));
- snprintf(info, sizeof(info), "<NET>iccid=%s,reg=%d,ppp=%d,csq=%d\r\n",app.CCID,tinfo.reg,tinfo.ppp,tinfo.csq);
- outterInfo(info, strlen(info));
- snprintf(info, sizeof(info), "<SERVER>iot=%d,data=%d\r\n",tinfo.iot,tinfo.auth);
- outterInfo(info, strlen(info));
- snprintf(info, sizeof(info), "<KEY>sos=%d,rec=%d,charge=%d\r\n",tinfo.ksos,tinfo.krec,app.vcharge);
- outterInfo(info, strlen(info));
- snprintf(info, sizeof(info), "<GPS>locate=%d,lat=%d,long=%d\r\n",tinfo.locate,tinfo.lat,tinfo.lon);
- outterInfo(info, strlen(info));
- snprintf(info, sizeof(info), "<DEV>bat=%d,ax=%d,ay=%d,az=%d,step=%d\r\n",tinfo.bat,tinfo.ax,tinfo.ay,tinfo.az,tinfo.step);
- outterInfo(info, strlen(info));
- snprintf(info, sizeof(info), "<LBS>mcc=%d,mnc=%d,lac=%d,cellid=%d\r\n",tinfo.mcc,tinfo.mnc,tinfo.lac,tinfo.cellid);
- outterInfo(info, strlen(info));
- snprintf(info, sizeof(info), "<NEAR>acc=%02x%02x%02x%02x%02x%02x,rssi=%d\r\n",tinfo.near.mac[0],tinfo.near.mac[1],tinfo.near.mac[2],tinfo.near.mac[3],tinfo.near.mac[4],tinfo.near.mac[5],tinfo.near.rssi);
- outterInfo(info, strlen(info));
- snprintf(info, sizeof(info), "<LTE>name=%s,lte=%s\r\n",APP_NAME,APP_VERSION);
- outterInfo(info, strlen(info));
- snprintf(info, sizeof(info), "<MODEM>ati=%s\r\n",app.fmVersion);
- outterInfo(info, strlen(info));
- }
|