|
@@ -33,6 +33,9 @@ void BleTask(void *pvParameters)
|
|
|
sint8 ret = -1;
|
|
|
QueueDataTrans_Type BleAnsData={0,NULL};
|
|
|
QueueDataTrans_Type BleAskData={0,NULL};
|
|
|
+ uint16 ReadLen = 0;
|
|
|
+ uint8 *retptr = NULL;
|
|
|
+ uint8 *pSend = NULL;
|
|
|
for (;;)
|
|
|
{
|
|
|
switch (bleWorkState)
|
|
@@ -53,11 +56,8 @@ void BleTask(void *pvParameters)
|
|
|
AtcmdTransmit(AT_Conn, BleTargetMacAddr, sizeof(BleTargetMacAddr), AtCmdRead, &ret);
|
|
|
if (ret == 0) //连接成功
|
|
|
{
|
|
|
- BleConnectFlg = 1;
|
|
|
- bleWorkState = 1;
|
|
|
BleConnectEnable = 0;
|
|
|
BleDisconnectFlg = 0;
|
|
|
- xSemaphoreGive(ConnSemaphore);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -65,9 +65,6 @@ void BleTask(void *pvParameters)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- uint8 *retptr = NULL;
|
|
|
- uint8 *pSend = NULL;
|
|
|
- uint16 ReadLen = 0;
|
|
|
memset(RX_Buffer[UART_LPUART2], 0x00, sizeof(RX_Buffer[UART_LPUART2]));
|
|
|
UART_Receive_Data(UART_LPUART2, RX_Buffer[UART_LPUART2],&ReadLen, 100);
|
|
|
memcpy(AtCmdRead, RX_Buffer[UART_LPUART2], sizeof(AtCmdRead));
|
|
@@ -79,6 +76,7 @@ void BleTask(void *pvParameters)
|
|
|
bleWorkState = 1;
|
|
|
BleConnectFlg = 1;
|
|
|
BleDisconnectFlg = 0;
|
|
|
+ xSemaphoreGive(ConnSemaphore);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -115,8 +113,6 @@ void BleTask(void *pvParameters)
|
|
|
/*已连接状态下的数据交换在此进行
|
|
|
UartTramsit;
|
|
|
*/
|
|
|
- uint8 *pSend = NULL;
|
|
|
- uint16 ReadLen = 0;
|
|
|
/*S32K144*/
|
|
|
if (BleCurrentRole == 1)//主机蓝牙在连接状态下的蓝牙串口发送功能,从MCU串口0队列得到,发给串口2
|
|
|
{
|
|
@@ -139,7 +135,7 @@ void BleTask(void *pvParameters)
|
|
|
BleAnsData.DataPtr = NULL;
|
|
|
}
|
|
|
}
|
|
|
- UART_Receive_Data(UART_LPUART2, RX_Buffer[UART_LPUART2],&ReadLen, 100);
|
|
|
+ UART_Receive_Data(UART_LPUART2, RX_Buffer[UART_LPUART2],&ReadLen, 1000);
|
|
|
memcpy(AtCmdRead, RX_Buffer[UART_LPUART2], sizeof(AtCmdRead));
|
|
|
memset(RX_Buffer[UART_LPUART2], 0x00, sizeof(RX_Buffer[UART_LPUART2]));
|
|
|
if (ReadLen>0)//连接的状态下,蓝牙串口会发送断开状态以及发送的内容
|
|
@@ -162,7 +158,7 @@ void BleTask(void *pvParameters)
|
|
|
memset(DataSend.DataPtr,0x00,ReadLen+1);
|
|
|
memcpy(DataSend.DataPtr,AtCmdRead,DataSend.RealLen);
|
|
|
sint8 McuDataRet = -1;
|
|
|
- McuDataRet= xQueueSend(McuDataRecvHandle,&DataSend,1000*5);//增加数据的有效性判定,主机蓝牙从Uart2->Uart0数据的有效性,len>7?
|
|
|
+ McuDataRet= xQueueSend(McuDataRecvHandle,&DataSend,1000*2);//增加数据的有效性判定,主机蓝牙从Uart2->Uart0数据的有效性,len>7?
|
|
|
if(McuDataRet!=pdPASS)
|
|
|
{
|
|
|
if(DataSend.DataPtr != NULL)
|