CH32V/F208 BLE转ETH的测试以及速度优化说明
CH32V208/208系列具有强大的低功耗蓝牙与以太网控制器,对于想要用BLE无线转网络进而控制多个设备提供了支持。
对于BLE全速测试数据上下行大概8Mbps,208内置的以太网控制器为10Mbps速度,加上协议栈的缘故,跑TCP发的话
大概还有8Mbps左右,二者合并后,大概只有400Kbps的速度了。
1. 现在原始的demo上测试。手机上先下载一个BLE调试助手的app,便于主机操控透传,打开208的(以V208)Peripheral_ETH例程,下载进入开发板,现在需要将以太网发送给服务器的

同样将BLE从机发给主机的eripheralChar4Notify(notiData, SIMPLEPROFILE_CHAR4_LEN);注释掉

3.更改BLE发送间隔等参数


打开ble调试助手app,设置MTU为512与上面保持一致,开启notify,接收数据。


测试所得,大概60K多大B。也就是4800Kbps。
以太网处理接收代码
volatile u16 blelen=0;
u8 BLEBuf[490];
extern peripheralConnItem_t peripheralConnList;
/*********************************************************************
* @fn WCHNET_DataLoopback
*
* @brief Data loopback function.
*
* @param id - socket id.
*
* @return none
*/
void WCHNET_DataLoopback(u8 id)
{
#if 0
u8 i;
u32 len;
u32 endAddr = SocketInf[id].RecvStartPoint + SocketInf[id].RecvBufLen; //Receive buffer end address
if ((SocketInf[id].RecvReadPoint + SocketInf[id].RecvRemLen) > endAddr) { //Calculate the length of the received data
len = endAddr - SocketInf[id].RecvReadPoint;
}
else {
len = SocketInf[id].RecvRemLen;
}
i = WCHNET_SocketSend(id, (u8 *) SocketInf[id].RecvReadPoint, &len); //send data
if (i == WCHNET_ERR_SUCCESS) {
WCHNET_SocketRecv(id, NULL, &len); //Clear sent data
}
#else
u32 len, totallen;
u8 *p = BLEBuf;
if(BLE_SFlag==0)
{
if(LL_GetNumberOfUnAckPacket(peripheralConnList.connHandle)>19)
return;
len = WCHNET_SocketRecvLen(id, NULL); //query length
if(len<=490)
WCHNET_SocketRecv(id, BLEBuf, &len); //Read the data of the receive buffer into MyBuf
else {
len=490;
WCHNET_SocketRecv(id, BLEBuf, &len);
}
blelen=len;
// totallen = len;
peripheralChar4Notify(p,blelen) ;
// else{
// BLE_SFlag=1;
// printf("*****\r\n");
// }
}
else if(BLE_SFlag==1)
{
if(LL_GetNumberOfUnAckPacket(peripheralConnList.connHandle)>19)
return;
peripheralChar4Notify(p,blelen) ;
}
// while(1){
// len = totallen;
// WCHNET_SocketSend(id, p, &len); //Send the data
// totallen -= len; //Subtract the sent length from the total length
// p += len; //offset buffer pointer
// if(totallen) continue; //If the data is not sent, continue to send
// break; //After sending, exit
// }
#endif
}
浙公网安备 33010602011771号