|
@@ -650,10 +650,24 @@ void getTargetWeight(void)
|
|
|
*/
|
|
|
}
|
|
|
|
|
|
+void sendWifi_buf(uint8_t *buf){
|
|
|
+ if (XbeeConst_UseAPI==0 && isnewLora==1) {
|
|
|
+ rt_sem_take(sendLora_lock, RT_WAITING_FOREVER);
|
|
|
+ rt_thread_mdelay((XbeeConst_DeviceAddress-1)*50);
|
|
|
+ }
|
|
|
+ rt_sem_take(uart2_lock, RT_WAITING_FOREVER);
|
|
|
+
|
|
|
+ for (int SendWifi_i = 1; SendWifi_i <= buf[0]; SendWifi_i++) //将缓冲区发出
|
|
|
+ usart2_send_data[SendWifi_i-1] = buf[SendWifi_i];
|
|
|
+
|
|
|
+ HAL_UART_Transmit_DMA(&huart2, usart2_send_data, buf[0]);
|
|
|
+ rt_thread_mdelay(50);
|
|
|
+ rt_sem_release(uart2_lock);
|
|
|
+}
|
|
|
|
|
|
void SendWifi_entry(void *parameter) {
|
|
|
while (1)
|
|
|
- {
|
|
|
+ {
|
|
|
if ((XbeeConst_needRetry>(40+XbeeConst_DeviceAddress)) && XbeeConst_CanSend==0) { //需要2秒后重发
|
|
|
if ((XbeeConst_FTxBuf0[4]&0xF0) == 0xF0) {
|
|
|
XbeeConst_FTxBuf0[4]=XbeeConst_FTxBuf0[4]-16;
|
|
@@ -669,26 +683,10 @@ void SendWifi_entry(void *parameter) {
|
|
|
setSendFrame_t(XbeeConst_FTxBuf0[4]==0xF8 || XbeeConst_FTxBuf0[4]==0xE8,0x00,0xC0);
|
|
|
// setSendFrame_t(1,0x00,0xC0);
|
|
|
XbeeConst_PTxBuf0 = xBeeApp2MakeFrame(&userSendFrame_t, XbeeConst_FTxBuf0);
|
|
|
- for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_PTxBuf0[0]; SendWifi_i++) //将缓冲区发出
|
|
|
- usart2_send_data[SendWifi_i-1] = XbeeConst_PTxBuf0[SendWifi_i];
|
|
|
-
|
|
|
-// {
|
|
|
-// usart2_send_data[SendWifi_i-1] = XbeeConst_PTxBuf0[SendWifi_i];
|
|
|
-// rt_kprintf(" %02X",usart2_send_data[SendWifi_i-1]);
|
|
|
-//}
|
|
|
-// rt_kprintf("\n");
|
|
|
- HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_PTxBuf0[0]);
|
|
|
- rt_thread_mdelay(50);
|
|
|
- rt_sem_release(uart2_lock);
|
|
|
+ sendWifi_buf(XbeeConst_PTxBuf0);
|
|
|
}
|
|
|
else{
|
|
|
- rt_sem_take(uart2_lock, RT_WAITING_FOREVER);
|
|
|
- for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_FTxBuf0[0]; SendWifi_i++) //将缓冲区发出
|
|
|
- usart2_send_data[SendWifi_i-1] = XbeeConst_FTxBuf0[SendWifi_i];
|
|
|
-
|
|
|
- HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_FTxBuf0[0]);
|
|
|
- rt_thread_mdelay(50);
|
|
|
- rt_sem_release(uart2_lock);
|
|
|
+ sendWifi_buf(XbeeConst_FTxBuf0);
|
|
|
}
|
|
|
|
|
|
XbeeConst_needRetry = 0; //重置重发定时计数
|
|
@@ -701,30 +699,14 @@ void SendWifi_entry(void *parameter) {
|
|
|
XbeeConst_CanSend = 0; //锁定无线不可发送直至解锁
|
|
|
XbeeConst_needRetry = 0; //重置重发定时计数
|
|
|
XbeeConst_FrameNumLast = XbeeConst_FTxBuf0[XbeeConst_FTxBuf0[0]-1];
|
|
|
- if (XbeeConst_UseAPI>0) {
|
|
|
- rt_sem_take(uart2_lock, RT_WAITING_FOREVER);
|
|
|
+ if (XbeeConst_UseAPI>0) {
|
|
|
setSendFrame_t(XbeeConst_FTxBuf0[4]==0xF8,0x00,0xC0);
|
|
|
XbeeConst_PTxBuf0 = xBeeApp2MakeFrame(&userSendFrame_t, XbeeConst_FTxBuf0);
|
|
|
-
|
|
|
- for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_PTxBuf0[0]; SendWifi_i++) //将缓冲区发出
|
|
|
- usart2_send_data[SendWifi_i-1] = XbeeConst_PTxBuf0[SendWifi_i];
|
|
|
-// {
|
|
|
-// usart2_send_data[SendWifi_i-1] = XbeeConst_PTxBuf0[SendWifi_i];
|
|
|
-// rt_kprintf(" %02X",usart2_send_data[SendWifi_i-1]);
|
|
|
-//}
|
|
|
-// rt_kprintf("\n");
|
|
|
- HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_PTxBuf0[0]);
|
|
|
- rt_thread_mdelay(50);
|
|
|
- rt_sem_release(uart2_lock);
|
|
|
+ sendWifi_buf(XbeeConst_PTxBuf0);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- rt_sem_take(uart2_lock, RT_WAITING_FOREVER);
|
|
|
- for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_FTxBuf0[0]; SendWifi_i++) //将缓冲区发出
|
|
|
- usart2_send_data[SendWifi_i-1] = XbeeConst_FTxBuf0[SendWifi_i];
|
|
|
- HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_FTxBuf0[0]);
|
|
|
- rt_thread_mdelay(50);
|
|
|
- rt_sem_release(uart2_lock);
|
|
|
+ sendWifi_buf(XbeeConst_FTxBuf0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -733,24 +715,13 @@ void SendWifi_entry(void *parameter) {
|
|
|
XbeeConst_CanSend = 0; //锁定无线不可发送直至解锁
|
|
|
XbeeConst_needRetry = 0; //重置重发定时计数
|
|
|
XbeeConst_FrameNumLast = XbeeConst_FTxBuf0[XbeeConst_FTxBuf0[0]-1];
|
|
|
- if (XbeeConst_UseAPI>0) {
|
|
|
- rt_sem_take(uart2_lock, RT_WAITING_FOREVER);
|
|
|
+ if (XbeeConst_UseAPI>0) {
|
|
|
setSendFrame_t(XbeeConst_FTxBuf0[4]==0xF8,0x00,0xC0);
|
|
|
- XbeeConst_PTxBuf0 = xBeeApp2MakeFrame(&userSendFrame_t, XbeeConst_FTxBuf0);
|
|
|
- for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_PTxBuf0[0]; SendWifi_i++) //将缓冲区发出
|
|
|
- usart2_send_data[SendWifi_i-1] = XbeeConst_PTxBuf0[SendWifi_i];
|
|
|
-
|
|
|
- HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_PTxBuf0[0]);
|
|
|
- rt_thread_mdelay(50);
|
|
|
- rt_sem_release(uart2_lock);
|
|
|
+ XbeeConst_PTxBuf0 = xBeeApp2MakeFrame(&userSendFrame_t, XbeeConst_FTxBuf0);
|
|
|
+ sendWifi_buf(XbeeConst_PTxBuf0);
|
|
|
}
|
|
|
- else{
|
|
|
- rt_sem_take(uart2_lock, RT_WAITING_FOREVER);
|
|
|
- for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_FTxBuf0[0]; SendWifi_i++) //将缓冲区发出
|
|
|
- usart2_send_data[SendWifi_i-1] = XbeeConst_FTxBuf0[SendWifi_i];
|
|
|
- HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_FTxBuf0[0]);
|
|
|
- rt_thread_mdelay(50);
|
|
|
- rt_sem_release(uart2_lock);
|
|
|
+ else{
|
|
|
+ sendWifi_buf(XbeeConst_FTxBuf0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -765,25 +736,17 @@ void SendWifi_entry(void *parameter) {
|
|
|
XbeeConst_CanSend = 0; //锁定无线不可发送直至解锁
|
|
|
XbeeConst_needRetry = 0; //重置重发定时计数
|
|
|
XbeeConst_FrameNumLast = XbeeConst_FTxBuf0[XbeeConst_FTxBuf0[0]-1];
|
|
|
- rt_sem_take(uart2_lock, RT_WAITING_FOREVER);
|
|
|
if (XbeeConst_UseAPI>0) {
|
|
|
setSendFrame_t(XbeeConst_FTxBuf0[4]==0xF8,0x00,0xC0);
|
|
|
- XbeeConst_PTxBuf0 = xBeeApp2MakeFrame(&userSendFrame_t, XbeeConst_FTxBuf0);
|
|
|
- for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_PTxBuf0[0]; SendWifi_i++) //将缓冲区发出
|
|
|
- usart2_send_data[SendWifi_i-1] = XbeeConst_PTxBuf0[SendWifi_i];
|
|
|
- HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_PTxBuf0[0]);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- for (int SendWifi_i = 1; SendWifi_i <= XbeeConst_FTxBuf0[0]; SendWifi_i++) //将缓冲区发出
|
|
|
- usart2_send_data[SendWifi_i-1] = XbeeConst_FTxBuf0[SendWifi_i];
|
|
|
- HAL_UART_Transmit_DMA(&huart2, usart2_send_data, XbeeConst_FTxBuf0[0]);
|
|
|
- }
|
|
|
- rt_thread_mdelay(50);
|
|
|
- rt_sem_release(uart2_lock);
|
|
|
+ XbeeConst_PTxBuf0 = xBeeApp2MakeFrame(&userSendFrame_t, XbeeConst_FTxBuf0);
|
|
|
+ sendWifi_buf(XbeeConst_PTxBuf0);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ sendWifi_buf(XbeeConst_FTxBuf0);
|
|
|
+ }
|
|
|
}
|
|
|
XbeeConst_needRetry++;
|
|
|
- rt_thread_mdelay(100);
|
|
|
+ rt_thread_mdelay(100);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -792,7 +755,7 @@ static rt_thread_t SendWifiid = RT_NULL;
|
|
|
|
|
|
void SendWifi_thread(void)
|
|
|
{
|
|
|
- SendWifiid = rt_thread_create("SendWifi", SendWifi_entry, RT_NULL, 0x300,5, 5);
|
|
|
+ SendWifiid = rt_thread_create("SendWifi", SendWifi_entry, RT_NULL, 0x300,4, 5);
|
|
|
|
|
|
/* 如果获得线程控制块,启动这个线程 */
|
|
|
if (SendWifiid != RT_NULL) rt_thread_startup(SendWifiid);
|
|
@@ -805,7 +768,6 @@ static void pop_product_thread_cleanup(struct rt_thread *tid)
|
|
|
{
|
|
|
return ;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
void pop_product_thread(void)
|