Part Number:CC3100
Customer has issues with scanning SSIDs on CC3100. The system isn’t responding as expected to sl_SetSockOpt command.
Basically, when passively scanning for SSIDs on one or more channels, we’ve utilized the SL_SO_RCVTIMEO to specify a maximum amount of time an input function waits until it completes; implementing a 200ms timeout. However, it looks like in the event there is no AP on a given scan channel, it appears to ignore this 200ms timeout and will wait for a much longer time period (on the order of seconds).
Have you ever seen this before? Any suggestions? I’ve attached a snippet of code for reference…
/*!
\brief This function opens a raw socket, receives the frames and display them.
\param[in] channel : channel for the raw socket
\param[in] timeout : timeout interval
\return 0 for success, -ve otherwise
\note
\warning
*/
int32_t Sniffer(uint8_t *ptr2buffer, uint16_t *buff_index, uint8_t max_buffer_size, uint32_t channel, uint32_t timeout)
{
TransceiverRxOverHead_t *frameRadioHeader = 0;
uint8_t MAC[MAX_RECV_BUF_SIZE] = {'\0'};
// uint8_t filterData[MAC_ADDR_LENGTH] = {'\0'};
int32_t retVal = -1;
int16_t sd = -1;
int16_t indx, nMsgs;
SlSockNonblocking_t enableOption;
SlTimeval_t timeVal;
uint32_t time_delay_msec;
bool test_bit;
uint16_t memIndx, prntIndex;
g_Exit = 1;
/********************* Open Socket for transceiver *********************/
sd = sl_Socket(SL_AF_RF,SL_SOCK_RAW,(int16_t)channel);
if(sd > 0)
{
enableOption.NonblockingEnabled = 1;
indx = sl_SetSockOpt(sd, SL_SOL_SOCKET, SL_SO_NONBLOCKING, (void*)&enableOption, sizeof(enableOption));
if(indx != 0) {
if(sl_Close(sd) != 0)
{
return -3;
}
else
{
return -1;
}
}
timeVal.tv_sec = 0; // Seconds
timeVal.tv_usec = 200000; // Microseconds. 10000 microseconds resolution => 200ms
indx = sl_SetSockOpt(sd,SL_SOL_SOCKET,SL_SO_RCVTIMEO, (_u8 *)&timeVal, sizeof(timeVal)); // Enable receive timeout
if(indx != 0) {
if(sl_Close(sd) != 0)
{
return -3;
}
else
{
return -1;
}
}
g_Exit = 0;
}
else
{
return -2;
}
/************ Receiving frames from the CC3100 and printing to screen*****/
memIndx = 0;
nMsgs = 0;
if (!g_Exit)
{
time_delay_msec = start_time_ticks(time_in_ticks(timeout));
test_bit = check_time_ticks(time_delay_msec);
while(test_bit && (max_buffer_size >= memIndx))
{
memset(wifi_rxbuffer, 0, sizeof(wifi_rxbuffer));
retVal = sl_Recv(sd,wifi_rxbuffer,MAX_RECV_BUF_SIZE,0); // returns after each message received
if(retVal > 0)
{
memcpy(MAC, wifi_rxbuffer, sizeof(wifi_rxbuffer));
memset(&MAC[retVal], 0, (sizeof(MAC) - retVal));
if(MAC[8] == 0x80)
{
frameRadioHeader = (TransceiverRxOverHead_t *)wifi_rxbuffer;
if((memIndx + (uint16_t)MAC[45] + 2) <= max_buffer_size)
{
if((frameRadioHeader != NULL) && (frameRadioHeader->rssi >= MIN_RSSI))
{
nMsgs++;
ptr2buffer[memIndx++] = (uint8_t)MAC[45] + 2;
ptr2buffer[memIndx++] = (uint8_t)frameRadioHeader->rssi;
prntIndex = memIndx;
for(indx = 0; indx < (int16_t)MAC[45]; indx++)
{
ptr2buffer[memIndx++] = MAC[46+indx];
ptr2buffer[memIndx] = 0;
}
if(CurrentPort == UART_INTF)
{
printf("%s\r\n", (char*)&ptr2buffer[prntIndex]);
}
}
test_bit = check_time_ticks(time_delay_msec);
}
else
{
test_bit = false;
}
}
else
{
test_bit = check_time_ticks(time_delay_msec);
}
}
}
}
*buff_index = memIndx;
if(sl_Close(sd) != 0)
{
return -3;
}
return (int32_t)nMsgs;
}
Regards,
Mark