ZHCU938C May 2018 – January 2021 CC3100 , CC3100MOD , CC3200 , CC3200MOD
Rx 统计信息功能检查介质的拥塞情况和距离,验证射频硬件,并使用 RSSI 信息将 SimpleLink WiFi 器件定位在理想位置。
示例:
将 SimpleLink 器件连接到 AP,运行从 AP 到器件的 UDP 数据包流,然后在 SimpleLink Studio 中使用以下代码获取 Rx 统计信息。
static _i32 RxStatisticsCollect(_i16 channel)
{
SlGetRxStatResponse_t rxStatResp;
_u8 buffer[MAX_BUF_RX_STAT] = {'\0'};
_u8 var[MAX_BUF_SIZE] = {'\0'};
_i32 idx = -1;
_i16 sd = -1;
_i32 retVal = -1;
memset(&rxStatResp, 0, sizeof(rxStatResp));
sd = sl_Socket(SL_AF_RF,SL_SOCK_RAW,channel);
if(sd < 0)
{
printf("Error In Creating the Socket\n");
ASSERT_ON_ERROR(sd);
}
retVal = sl_Recv(sd, buffer, BYTES_TO_RECV, 0);
ASSERT_ON_ERROR(retVal);
printf("Press \"Enter\" to start collecting statistics.\n");
fgets((char *)var, sizeof(var), stdin);
retVal = sl_WlanRxStatStart();
ASSERT_ON_ERROR(retVal);
printf("Press \"Enter\" to get the statistics.\n");
fgets((char *)var, sizeof(var), stdin);
retVal = sl_WlanRxStatGet(&rxStatResp, 0);
ASSERT_ON_ERROR(retVal);
printf("\n\n*********************Rx Statistics**********************\n\n");
printf("Received Packets - %d\n",rxStatResp.ReceivedValidPacketsNumber);
printf("Received FCS - %d\n",rxStatResp.ReceivedFcsErrorPacketsNumber);
printf("Received Address Mismatch - %d\n",rxStatResp.ReceivedAddressMismatchPacketsNumber);
printf("Average Rssi for management: %d Average Rssi for other packets: %d\n",
rxStatResp.AvarageMgMntRssi,rxStatResp.AvarageDataCtrlRssi);
for(idx = 0 ; idx < SIZE_OF_RSSI_HISTOGRAM ; idx++)
{
printf("Rssi Histogram cell %d is %d\n", idx, rxStatResp.RssiHistogram[idx]);
}
printf("\n");
for(idx = 0 ; idx < NUM_OF_RATE_INDEXES; idx++)
{
printf("Rate Histogram cell %d is %d\n", idx, rxStatResp.RateHistogram[idx]);
}
printf("The data was sampled in %u microseconds.\n",
((_i16)rxStatResp.GetTimeStamp - rxStatResp.StartTimeStamp));
printf("\n\n*******************End Rx Statistics********************\n");
retVal = sl_WlanRxStatStop();
ASSERT_ON_ERROR(retVal);
retVal = sl_Close(sd);
ASSERT_ON_ERROR(retVal);
return SUCCESS;
}