SWRU368C May 2018 – January 2021 CC3100 , CC3100MOD , CC3200 , CC3200MOD
The Rx Statistics feature inspects the medium in terms of congestion and distance, validates the RF hardware, and uses the RSSI information to position the SimpleLink WiFi device in an ideal location.
Example:
Connect the SimpleLink device to an AP, run a UDP flow of packets to the device from the AP, and use the following code with the SimpleLink Studio to get Rx statistics.
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;
}