|
@@ -60,9 +60,9 @@ static QueueHandle_t TcpRecvHandle = NULL;
|
|
static void TcpWorkStatus(void *arg);
|
|
static void TcpWorkStatus(void *arg);
|
|
static void sendQueueMsg(UINT32 msgId, UINT32 xTickstoWait);
|
|
static void sendQueueMsg(UINT32 msgId, UINT32 xTickstoWait);
|
|
static INT32 socketRegisterPSUrcCallback(urcID_t eventID, void *param, UINT32 paramLen);
|
|
static INT32 socketRegisterPSUrcCallback(urcID_t eventID, void *param, UINT32 paramLen);
|
|
-void socketAppConnectionCallBack(UINT8 connectionEventType, void *bodyEvent);
|
|
|
|
-void TcpDataInfoAssembleSend();
|
|
|
|
-void TcpDataInfoRecvHandle();
|
|
|
|
|
|
+static void socketAppConnectionCallBack(UINT8 connectionEventType, void *bodyEvent);
|
|
|
|
+static void TcpDataInfoAssembleSend();
|
|
|
|
+static void TcpDataInfoRecvHandle();
|
|
UINT8 bcc_chk(UINT8* data, UINT8 length);
|
|
UINT8 bcc_chk(UINT8* data, UINT8 length);
|
|
//线程任务区
|
|
//线程任务区
|
|
static void TcpTask(void* arg)
|
|
static void TcpTask(void* arg)
|
|
@@ -79,7 +79,7 @@ static void TcpTask(void* arg)
|
|
}
|
|
}
|
|
if(TcpRecvHandle == NULL)
|
|
if(TcpRecvHandle == NULL)
|
|
{
|
|
{
|
|
- TcpRecvHandle = osMessageQueueNew(2,sizeof(TcpipConnectionRecvDataInd), NULL);
|
|
|
|
|
|
+ TcpRecvHandle = osMessageQueueNew(1,sizeof(TcpipConnectionRecvDataInd*), NULL);
|
|
}
|
|
}
|
|
while (true)
|
|
while (true)
|
|
{
|
|
{
|
|
@@ -137,10 +137,8 @@ static void TcpTask(void* arg)
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case QMSG_ID_SOCK_RECVPKG:
|
|
case QMSG_ID_SOCK_RECVPKG:
|
|
- #ifdef USING_PRINTF
|
|
|
|
- printf("QMSG_ID_SOCK_RECVPKG\n");
|
|
|
|
- #endif
|
|
|
|
TcpDataInfoRecvHandle();
|
|
TcpDataInfoRecvHandle();
|
|
|
|
+ TcpService=0x00;
|
|
break;
|
|
break;
|
|
case QMSG_ID_NW_IP_SUSPEND:
|
|
case QMSG_ID_NW_IP_SUSPEND:
|
|
if (socContext.id >= 0 && socContext.status != APP_SOCKET_CONNECTION_CLOSED)
|
|
if (socContext.id >= 0 && socContext.status != APP_SOCKET_CONNECTION_CLOSED)
|
|
@@ -183,7 +181,7 @@ static void TcpTask(void* arg)
|
|
TcpTaskDeInit(arg);
|
|
TcpTaskDeInit(arg);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- free(queueItem);
|
|
|
|
|
|
+ free(queueItem);
|
|
}
|
|
}
|
|
}//while 循环
|
|
}//while 循环
|
|
}
|
|
}
|
|
@@ -226,8 +224,8 @@ static void TcpDataInfoAssembleSend()
|
|
UINT8 TEMP_NUM=0;
|
|
UINT8 TEMP_NUM=0;
|
|
TEMP_NUM = BATT_TEMP_NUM+2;//TEMP_NUM为温度总检测数量
|
|
TEMP_NUM = BATT_TEMP_NUM+2;//TEMP_NUM为温度总检测数量
|
|
UINT16 DataLen;
|
|
UINT16 DataLen;
|
|
- if(send_counter%1==0)
|
|
|
|
- //if(0)
|
|
|
|
|
|
+ //if(send_counter%1==0)
|
|
|
|
+ if(0)
|
|
{
|
|
{
|
|
osStatus_t result = osMutexAcquire(UartMutex, osWaitForever);
|
|
osStatus_t result = osMutexAcquire(UartMutex, osWaitForever);
|
|
appGetSystemTimeUtcSync(&TimeStracture);
|
|
appGetSystemTimeUtcSync(&TimeStracture);
|
|
@@ -302,8 +300,8 @@ static void TcpDataInfoAssembleSend()
|
|
tcpipConnectionSend(socContext.id, (UINT8 *)&BattToTcpInfo, sizeof(BattToTcpInfo), 0, 0, 0);
|
|
tcpipConnectionSend(socContext.id, (UINT8 *)&BattToTcpInfo, sizeof(BattToTcpInfo), 0, 0, 0);
|
|
|
|
|
|
}
|
|
}
|
|
- if(send_counter%6==0)
|
|
|
|
- //if(0)
|
|
|
|
|
|
+ //if(send_counter%6==0)
|
|
|
|
+ if(0)
|
|
{
|
|
{
|
|
osStatus_t result = osMutexAcquire(GpsMutex, osWaitForever);
|
|
osStatus_t result = osMutexAcquire(GpsMutex, osWaitForever);
|
|
appGetSystemTimeUtcSync(&TimeStracture);
|
|
appGetSystemTimeUtcSync(&TimeStracture);
|
|
@@ -337,8 +335,8 @@ static void TcpDataInfoAssembleSend()
|
|
tcpipConnectionSend(socContext.id, (UINT8 *)&GpsToTcpInfo, sizeof(GpsToTcpInfo), 0, 0, 0);
|
|
tcpipConnectionSend(socContext.id, (UINT8 *)&GpsToTcpInfo, sizeof(GpsToTcpInfo), 0, 0, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //if(send_counter==0)
|
|
|
|
- if(0)
|
|
|
|
|
|
+ if(send_counter==0)
|
|
|
|
+ //if(0)
|
|
{
|
|
{
|
|
CHAR iccid[20];
|
|
CHAR iccid[20];
|
|
CHAR imei[15];
|
|
CHAR imei[15];
|
|
@@ -404,27 +402,23 @@ static void TcpDataInfoAssembleSend()
|
|
//Tcp数据接收处理函数
|
|
//Tcp数据接收处理函数
|
|
static void TcpDataInfoRecvHandle()
|
|
static void TcpDataInfoRecvHandle()
|
|
{
|
|
{
|
|
- UINT8* Ptr;
|
|
|
|
- TcpipConnectionRecvDataInd* TcpRecvData;
|
|
|
|
|
|
+ TcpipConnectionRecvDataInd *TcpRecvData;
|
|
TcpService = 0x01;//应答标志
|
|
TcpService = 0x01;//应答标志
|
|
- osMessageQueueGet(TcpRecvHandle,TcpRecvData,0,2000);
|
|
|
|
|
|
+ osMessageQueueGet(TcpRecvHandle,&TcpRecvData,0,0);
|
|
osDelay(100);
|
|
osDelay(100);
|
|
- if(TcpRecvData == NULL)
|
|
|
|
- {
|
|
|
|
- // #ifdef USING_PRINTF
|
|
|
|
- // printf("TcpRecvData is vacant\n");
|
|
|
|
- // #endif
|
|
|
|
- TcpService = 0x02;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
|
|
+ UINT8 *Ptr;
|
|
|
|
+ if(TcpRecvData != PNULL)
|
|
{
|
|
{
|
|
-
|
|
|
|
#ifdef USING_PRINTF
|
|
#ifdef USING_PRINTF
|
|
- Ptr=TcpRecvData->data;
|
|
|
|
|
|
+ printf("TcpRecvData is vacant\n");
|
|
|
|
+ #endif
|
|
|
|
+ #ifdef USING_PRINTF
|
|
|
|
+ Ptr = TcpRecvData->data;
|
|
printf("TcpDataInfoRecvHandle socket connection %u receive length %u data:", TcpRecvData->connectionId, TcpRecvData->length);
|
|
printf("TcpDataInfoRecvHandle socket connection %u receive length %u data:", TcpRecvData->connectionId, TcpRecvData->length);
|
|
for(int i = 0;i<TcpRecvData->length;i++)
|
|
for(int i = 0;i<TcpRecvData->length;i++)
|
|
printf("%x ",*(Ptr+i));
|
|
printf("%x ",*(Ptr+i));
|
|
- #endif
|
|
|
|
|
|
+ #endif
|
|
|
|
+ free(TcpRecvData);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -517,7 +511,7 @@ static INT32 socketRegisterPSUrcCallback(urcID_t eventID, void *param, UINT32 pa
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
//Tcpz连接状态回调函数
|
|
//Tcpz连接状态回调函数
|
|
-void socketAppConnectionCallBack(UINT8 connectionEventType, void *bodyEvent)
|
|
|
|
|
|
+static void socketAppConnectionCallBack(UINT8 connectionEventType, void *bodyEvent)
|
|
{
|
|
{
|
|
switch(connectionEventType)
|
|
switch(connectionEventType)
|
|
{
|
|
{
|
|
@@ -575,12 +569,15 @@ void socketAppConnectionCallBack(UINT8 connectionEventType, void *bodyEvent)
|
|
case TCPIP_CONNECTION_RECEIVE_EVENT:
|
|
case TCPIP_CONNECTION_RECEIVE_EVENT:
|
|
{
|
|
{
|
|
TcpipConnectionRecvDataInd *rcvInd;
|
|
TcpipConnectionRecvDataInd *rcvInd;
|
|
|
|
+ TcpipConnectionRecvDataInd *rcvbuffer = NULL;
|
|
rcvInd = (TcpipConnectionRecvDataInd *)bodyEvent;
|
|
rcvInd = (TcpipConnectionRecvDataInd *)bodyEvent;
|
|
if(rcvInd != PNULL)
|
|
if(rcvInd != PNULL)
|
|
{
|
|
{
|
|
uint8_t* Ptr;
|
|
uint8_t* Ptr;
|
|
- //osMessageQueuePut(TcpRecvHandle,rcvInd,0,2000);
|
|
|
|
- //sendQueueMsg(QMSG_ID_SOCK_RECVPKG, 0);
|
|
|
|
|
|
+ rcvbuffer = malloc(sizeof(TcpipConnectionRecvDataInd));
|
|
|
|
+ memcpy(rcvbuffer,rcvInd,sizeof(TcpipConnectionRecvDataInd));
|
|
|
|
+ osMessageQueuePut(TcpRecvHandle,&rcvbuffer,0,1000);
|
|
|
|
+ sendQueueMsg(QMSG_ID_SOCK_RECVPKG, 0);
|
|
#ifdef USING_PRINTF
|
|
#ifdef USING_PRINTF
|
|
Ptr=rcvInd->data;
|
|
Ptr=rcvInd->data;
|
|
printf("socketAppConnectionCallBack socket connection %u receive length %u data:", rcvInd->connectionId, rcvInd->length);
|
|
printf("socketAppConnectionCallBack socket connection %u receive length %u data:", rcvInd->connectionId, rcvInd->length);
|