This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Issue in wlan_ioctl_get_scan_results / Not getting RSSI Value

Hello,

I am using APIs wlan_ioctl_set_scan_params and wlan_ioctl_get_scan_results, basic intention is to get the RSSI/Signal Strength of the network. In current scenario I am not connected to any of the network but just want to see the signal strength of the available networks.

Below is the code flow:

wlan_init( CC3000_UsynchCallback,NULL, NULL, NULL, ReadWlanInterruptPin, WlanInterruptEnable, WlanInterruptDisable, WriteWlanPin);

wlan_start(0);
  
wlan_set_event_mask(HCI_EVNT_WLAN_KEEPALIVE|HCI_EVNT_WLAN_UNSOL_INIT|HCI_EVNT_WLAN_ASYNC_PING_REPORT);
 
wlan_ioctl_set_connection_policy(DISABLE, DISABLE, DISABLE);

for(ucstatus = 0; ucstatus < 16 ; ucstatus++)
{
 interval[ucstatus] = 2000;   
}

wlan_ioctl_set_scan_params(1000,20,30,2,0x7FF,-100,0,205,interval);
 
wlan_reset(0); //because I read some where that after changing the scan param, need to restart wlan
 
wlan_ioctl_set_scan_params(1000,20,30,2,0x7FF,-100,0,205,interval); //setting same values again, I Think // should not harm
 
tx_thread_sleep(10000);// wait for 10 Sec, just to give enough time.
  
wlan_ioctl_get_scan_results(10000,ScanRes);

numberofnw =  ScanRes[3];
 
offset = 64;

for(count = 0 ; count < (numberofnw-1) ; count++)
{
 tx_thread_sleep(1000);
 wlan_ioctl_get_scan_results(10000,&ScanRes[offset]);     
 tx_thread_sleep(1000);      
 offset += 64;
}

I get multiple network details but do not see the RSSI value as per the return value structure. Values in buffer ScanRes after multiple scans are shown in "ScanResult_RSSI_Issue.JPG" starts from 0x00, 0x00, 0x00, 0x05......

Also please find the CC3000 Debug log for the same operation (teraterm_ScanResult_RSSI_Issue_1.log)

4214.teraterm_ScanResult_RSSI_Issue_1.log
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
$


$
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
|�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X��%,!
�
1
2-
	X�
$


$
d
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
$


$
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
|�
C-
	X�-e(-
	X�
$


$
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
|�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
$


$
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
$


$
d
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
|�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
$


$
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
|�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
|�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
d
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
$


$
�
1
2-
	X�
|�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
$


$
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
$


$
�
1
2-
	X�
|�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
$


$
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
d
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
|�	Z
			$VU�!����0z�.
p	�8=���
F/02v	[+","2-"K�2,"� "-"?2,"�-"�2,"��"-"�2," 1�"-"�2,"`1�"-"�2,"��"-"��!+���+���+l�+l�+6n
=
>
?*5(B�0
� 
�
��D��
�(� �\�0���l�|��� Z(
[�{Td�b�r�
	
	
	
	
	
	
	
�
^
]
�
@
	
	
		
�
�
�
l
i	
	

	
	
	

�
�
	
	
	
	
	
	
	
�
�
�
�
�-sP*
t
u
v-w
x%Ё:
�
o!-e�
�
�
� !
�
�
�n!w�-
m!-m!����
m!''''-e@-e�-e�
e-e-e-e-e�-e�-e�-e�-e-e-e-e-e-e-e-e-e-e-e-e#-e-eF
-e9-e4-eE-e-ea-eO-e-e-e8&-e$-eN-e4-e%-e1
e
e-eI-e&-e&-e&-e-eR-eQ-eQ-eQ-eQ-eQ-eQ-eQ-eQ-e/e/P�-eS-e--eP-e>-e?-e\-e]"
]-e`
\
�-
	T�-��]-eK-eD
@
�|@
KX
L
	
	
	^@
$

+,!D�New_FTC
$
,!-2!�DI�DI
�DI�DI
VU�!����0z�.
p	�8=���
F/02v	[+","2-"K�2,"� "-"?2,"�-"�2,"��"-"�2," 1�"-"�2,"`1�"-"�2,"��"-"��!+���+���+l�+l�+6n
=
>
?*5(B�0
� 
�
��D��
�(� �\�0���l�|��� Z(
[�{Td�b�r�
	
	
	
	
	
	
	
�
^
]
�
@
	
	
		
�
�
�
l
i	
	

	
	
	

�
�
	
	
	
	
	
	
	
�
�
�
�
�-sP*
t
u
v-w
x%Ё:
�
o!-e�
�
�
� !
�
�
�n!w�-
m!-m!����
m!''''-e@-e�-e�
e-e-e-e-e�-e�-e�-e�-e-e-e-e-e-e-e-e-e-e-e-e#-e-eF
-e9-e4-eE-e-ea-eO-e-e-e8&-e$-eN-e4-e%-e1
e
e-eI-e&-e&-e&-e-eR-eQ-eQ-eQ-eQ-eQ-eQ-eQ-eQ-e/e/P�-eS-e--eP-e>-e?-e\-e]"
]-e`
\
�-
	T�-��]-eK-eD
@
�|@
KX
L
	
	
	^@
$


$
,!$�
C-
	X�-e(-
	X�
	
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�VU�!����0z�.
p	�8=���
F/02v	[+","2-"K�2,"� "-"?2,"�-"�2,"��"-"�2," 1�"-"�2,"`1�"-"�2,"��"-"��!+���+���+l�+l�+6n
=
>
?*5(B�0
� 
�
��D��
�(� �\�0���l�|��� Z(
[�{Td�b�r�
	
	
	
	
	
	
	
�
^
]
�
@
	
	
		
�
�
�
l
i	
	

	
	
	

�
�
	
	
	
	
	
	
	
�
�
�
�
�-sP*
t
u
v-w
x%Ё:
�
o!-e�
�
�
� !
�
�
�n!w�-
m!-m!����
m!''''-e@-e�-e�
e-e-e-e-e�-e�-e�-e�-e-e-e-e-e-e-e-e-e-e-e-e#-e-eF
-e9-e4-eE-e-ea-eO-e-e-e8&-e$-eN-e4-e%-e1
e
e-eI-e&-e&-e&-e-eR-eQ-eQ-eQ-eQ-eQ-eQ-eQ-eQ-e/e/P�-eS-e--eP-e>-e?-e\-e]"
]-e`
\
�-
	T�-��]-eK-eD
@
�|@
KX
L
	
	
	^@
$

+,!D�New_FTC
$
,!-2!�DI�DI
�DI�DI
VU�!����0z�.
p	�8=���
F/02v	[+","2-"K�2,"� "-"?2,"�-"�2,"��"-"�2," 1�"-"�2,"`1�"-"�2,"��"-"��!+���+���+l�+l�+6n
=
>
?*5(B�0
� 
�
��D��
�(� �\�0���l�|��� Z(
[�{Td�b�r�
	
	
	
	
	
	
	
�
^
]
�
@
	
	
		
�
�
�
l
i	
	

	
	
	

�
�
	
	
	
	
	
	
	
�
�
�
�
�-sP*
t
u
v-w
x%Ё:
�
o!-e�
�
�
� !
�
�
�n!w�-
m!-m!����
m!''''-e@-e�-e�
e-e-e-e-e�-e�-e�-e�-e-e-e-e-e-e-e-e-e-e-e-e#-e-eF
-e9-e4-eE-e-ea-eO-e-e-e8&-e$-eN-e4-e%-e1
e
e-eI-e&-e&-e&-e-eR-eQ-eQ-eQ-eQ-eQ-eQ-eQ-eQ-e/e/P�-eS-e--eP-e>-e?-e\-e]"
]-e`
\
�-
	T�-��]-eK-eD
@
�|@
KX
L
	
	
	^@
$


$
d,!$�
C-
	X�-e(-
	X�
	
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
|�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$+,!'�WJh-2!*�Hc!��&�HW
C-
	X�-e(-
	X�
�
1
2-
	X�+,!'����HF
C-
	X�-e(-
	X�-2!��lhF�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�,!'�-2!�����
�
1
2-
	X�
C-
	X�-e(-
	X�
$


$
�
1
2-
	X�
C-
	X�-e(-
	X�+,!'�U0�<\ -2!t M�-��O
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�+,!'�UI
�DI-2!�DI�DI
�DI�DI
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
|�
$


$
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
$


$
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
d
C-
	X�-e(-
	X�
�
1
2-
	X�
C-
	X�-e(-
	X�
�
1
2-
	X�
$


$
C-
	X�-e(-
	X�

Please let me know, what could have been wrong here. let me know, if you need any more info from me.

Thanks and Regards,

Manish Kakra

 

  • Hello,

    Any update on this??

    Thanks and Regards,

    Manish Kakra

     

  • Hi Manish Kakra,

    I can't seem to get to your logs and read the screen shot very well.  However, I can post a function that does work for me that you may be able to compare to and see if it helps.  Sorry for the crudeness of it but I just threw it together for testing.

    Brent

    //*****************************************************************************
    // scan wireless networks
    //*****************************************************************************
    uint16 scan_networks(uint8 *num_networks, uint8 *ssid_array,
                         uint8 *ssid_length, uint8 *rssi_array)
    {
      uint8 index;
      uint16 sub_index;
      uint32 interval_list[16] = {200, 200, 200, 200, 200, 200, 200, 200,
                                  200, 200, 200, 200, 200, 200, 200, 200};
      uint8 scan_results[128];
      long return_status;

      return_status = wlan_ioctl_set_scan_params(1, 100, 100, 5, 0x7ff, -80, 0,
                                                 205, interval_list);
      if (return_status != 0)
        return ERROR_WL_PARAM;

      return_status = wlan_ioctl_get_scan_results(0, scan_results);
      if (return_status != 0)
        return ERROR_WL_PARAM;
      *num_networks = scan_results[0];
      ssid_length[0] = scan_results[9] >> 2;
      rssi_array[0] = scan_results[8] >> 1;

      for (sub_index = 0; sub_index < ssid_length[0]; sub_index++)
        ssid_array[sub_index] = scan_results[sub_index+12];

      for (index = 1; index < *num_networks; index++)
      {
        return_status = wlan_ioctl_get_scan_results(0, scan_results);
        if (return_status != 0)
          return ERROR_WL_PARAM;
        if (index <= 6)
        {
          ssid_length[index] = scan_results[9] >> 2;
          rssi_array[index] = scan_results[8] >> 1;

          for (sub_index = 0; sub_index < ssid_length[index]; sub_index++)
            ssid_array[index*32 + sub_index] = scan_results[sub_index+12];
        }
      }

      return NO_ERROR;
    }

  • Hello Brent,

    Thanks for giving time to help me out.

    Unfortunately, I am still not getting correct response. the values I get in buffer scan_results are same as the screen-shot I posted. so scan_results have values something like this for first call:

    00000002 00000001 00000000 41535553 00000000 00000000 00000000 00000000

    I have tried patch corresponds to release 1.11 and 1.11.1 but getting same results.

    Also I have below initialization sequence. CC3000 was not connected to any access point before doing this operation.

     //Initialize CC3000
     wlan_init( CC3000_UsynchCallback,NULL, NULL, NULL, ReadWlanInterruptPin, WlanInterruptEnable, WlanInterruptDisable, WriteWlanPin);

     wlan_start(0);  
     wlan_set_event_mask(HCI_EVNT_WLAN_KEEPALIVE|HCI_EVNT_WLAN_UNSOL_INIT|HCI_EVNT_WLAN_ASYNC_PING_REPORT);

     
     wlan_ioctl_set_connection_policy(DISABLE, DISABLE, DISABLE);

     scan_networks(num_networks, ssid_array, ssid_length, rssi_array);  \\ your code here for getting RSSI

    Please let me know, if you find anything wrong with this. ?

    Once again thanks.

    Regards,

    Manish K

     

  • Hi Manish K,

    I can't see any differences in your code sequence.  I think that it should work.  For reference, here is the raw data returned from my wlan_ioctl_set_scan_params routine:

    00000003    00000001    00F7336D    63656C45    4E6F7274    6B6E6F4D    00000000    00000000    00000000    00000000    00000000    1EC0C1C0    6365931F

    I have put it in the same 32bit word format that you have.  As you can see, mine finds 3 networks, the 1 indicates the scan results are valid, 0x6D indicates the AP is valid and the RSSI is ox3C, the 0x33 indicates the security mode is 3 - WPA2 - and the SSID length is 0xC.  0x00F7 is the time stamp and the next 32 bytes are the SSID name.

    Somehow, yours has the third word that contains most of the valid information zeroed out (and I believe this is what you are asking).  It looks like your SSID name is "SUSA".  Is that correct?  If so, there should be at least an indication of a length of 4 in the ssid length.  That would be an inconsistency in the return message.  I can't see it getting everything else correct and not that one word.

    A couple suggestions to try:

    1.  Have you run the wlan_ioctl_get_scan_results again to see if is picks up the second network and if it has the same problems as the first?

    2.  Look at the data as early as you can coming back from SPI to see if there might be some data corruption going on.

    I can't think of anything else to try at this time.  Let me know those results and we will go from there.

    Brent

  • Hi Brent,

    Thanks again.

    SSID name is ASUS (41535553), does this value comes in different order for you ? If so, this might be a clue for the issue.

    with respect to your suggestions, I tried calling other networks but same issue.

    Seems like data corruption is the issue for me. I suspect some issue, while packaging the data in event handher in case: HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS: but still trying to confirm. I have same code that TI has provided, not sure why it would behave different for me and you. Could be something related to endianness.., trying to figure out. Thanks for pointing this out.

    Update you once I dig more into it.

    Once again thanks for you help.

    Regards,

    Manish K

     

  • Hi Manish K,

    My SSID was in the same order as yours (that is how I came up with your network name).

    I agree that since all the code came from TI that there shouldn't be data corruption (unless it happens in both cases).  It is still suspicious that only that one word seems to be cleared.  I would still pursue that vector.  Is there some way you can see the data from SPI?  Put a break point in?  That would show if the data was correct at some point in time.

    Brent

  • Hi,

    I've tried reproducing the problem you report unsuccessfully. 

    Can you please try the following?

    1. Capture SPI data of the get scan results transaction

    2. Capture received buffer before streaming conversion in hci_event_handler (pucReceivedData)

    3. Capture again CC3000 internal network stack logs, but this time with additional information. To do this, please run the following command after driver initalization: netapp_set_debug_level(0x1FF);


    btw, which platform are you using? is it 16bit, 32bit?

    Regards,

    Tomer

  • Thanks Tomer and Brent.

    Finally, this is what is happening in my case:

    I have 32-bit non-TI host micro. To get correct values I have to make below changes in evnt_handler.c for it to work. Somehow, issue is in "STREAM_TO_UINT16". Rest of the things works fine.

          case HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS:

           STREAM_TO_UINT32((char *)pucReceivedParams,GET_SCAN_RESULTS_TABlE_COUNT_OFFSET,*(unsigned long *)pRetParams);
           pRetParams = ((char *)pRetParams) + 4;                                                       
           STREAM_TO_UINT32((char *)pucReceivedParams,GET_SCAN_RESULTS_SCANRESULT_STATUS_OFFSET,*(unsigned long *)pRetParams);
           pRetParams = ((char *)pRetParams) + 4;                                                       
    //STREAM_TO_UINT16((char *)pucReceivedParams,GET_SCAN_RESULTS_ISVALID_TO_SSIDLEN_OFFSET,*(unsigned long *)pRetParams);

    //pRetParams = ((char *)pRetParams) + 2;  
    //STREAM_TO_UINT16((char *)pucReceivedParams,GET_SCAN_RESULTS_FRAME_TIME_OFFSET,*(unsigned long *)pRetParams);

       //pRetParams = ((char *)pRetParams) + 2; 
           //With above code, actual received values were getting corrupted.
           //Below code is for getting values for next four bytes that has SSID Len, Security Type, RSSI Value, IS_RSSI_Valid Flag
           STREAM_TO_UINT32((char *)pucReceivedParams,GET_SCAN_RESULTS_ISVALID_TO_SSIDLEN_OFFSET,*(unsigned long *)pRetParams);
           pRetParams = ((char *)pRetParams) + 4;                           
           
           memcpy((unsigned char *)pRetParams, (char *)(pucReceivedParams + GET_SCAN_RESULTS_FRAME_TIME_OFFSET + 2), GET_SCAN_RESULTS_SSID_MAC_LENGTH);
           break;

    Please let me know, what could be issue in using original code.

    Thanks and Regards,

    Manish Kakra

     

  • Hi Manish,

    can you tell which 32 bit non-TI host micro you are using? Can you also tell which compiler you are using? Could it have to do something with alignment?

    Best regards,

    Martin

  • Hello Martin,

    Thanks.

    Using MCF5253 and Wind River Diab compiler. Not sure if it is something to do with allignment, but have not experienced this issue anywhere else yet.

    Will try to look more into this.

    Regards,

    Manish K

  • Hi Manish,

    Did you have any progress?

    What are the sizes in your processor of char? short? long? is it 8 bits, 16 bits, 32 bits accordingly?

    Please look at the memory section of the received buffer and see what happens due to calling the STREAM macro.

    I know for example, that for some processors, char is defined as 2 bytes and not as 1 byte.

    Regards,

    Tomer