• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Low Power RF & Wireless Connectivity » SimpleLink™ Wi-Fi® » Trouble using wlan_ioctl_get_scan_results
Share
Low Power RF & Wireless Connectivity
  • Forums
  • Announcements
  • Files
  • E2E Wiki
Options
  • Subscribe via RSS

Trouble using wlan_ioctl_get_scan_results

Trouble using wlan_ioctl_get_scan_results

This question is answered
Jeffrey Holt
Posted by Jeffrey Holt
on Feb 21 2012 14:02 PM
Prodigy100 points

I am having trouble using the wlan_ioctl_get_scan_results function.  I think there might be a problem with the structure type (WLAN_San_Result_t) that is passed into the function not matching what is actually returned byt the cc3000.

The defintition of the function in the Simplelink API reference manual does not match up with the actual definition in wlan.c

 

-------------------------------- Here is the documentaion for the function call ------------------------------------

 

long wlan_ioctl_get_scan_results ( unsigned long  ulScanTimeout,
unsigned char *  ucResults 
)

Gets the WLAN scan operation results.

Gets entry from scan result table. The scan results are returned one by one, and each entry represents a single AP found in the area. The following is a format of hte scan result:

  • 4 Bytes: number of networks found
  • 4 Bytes: The status of the scan: 0 - agged results, 1 - results valid, 2 - no results
  • 44 bytes: Result entry, where the bytes are arranged as follows:
    • 4 bytes isValid - is result valid or not
    • 4 bytes rssi - RSSI value;
    • 4 bytes: securityMode - security mode of the AP: 0 - Open, 1 - WEP, 2 WPA, 3 WPA2
    • 4 bytes: SSID name length
    • 2 bytes: the time at which the entry has entered into scans result table
    • 32 bytes: SSID name
    • 6 bytes: BSSID

------------------------------- Here is the structure defined in wlan.c -------------------------------------------

 

#ifdef __CCS__
typedef struct __attribute__ ((__packed__)) _WLAN_San_Result_t
#elif __IAR_SYSTEMS_ICC__
#pragma pack(1)
typedef struct _WLAN_San_Result_t
#endif
{
    //
    // Set to 1 if this entry is occuiped
    //
    unsigned long isValid    : 1;
    long rssi       : 7; 

    //
    // Holds one of the parsed security-modes
    // SECURITY_OPEN, SECURITY_WEP, SECURITY_WPA, SECURITY_WPA2,
    //
    unsigned long securityMode : 2;
    long ulSsidLen     : 6;

    //
    // The time of which the frame has enterd (in seconds)
    //
    short         frameTime;

    //
    // AP name and MAC address
    //
    char          ssid[MAXIMAL_SSID_LENGTH];
    unsigned char ucBssid[ETH_ALEN]; 

}WLAN_San_Result_t;

 

Problems

1) It says 44 bytes follow but the bytes listed add up to 56

2) The structure does not match documentation.

 

I found that if this is called multiple times, the driver evenually crashes.  I was able to change the structure and get it to work using this as my structure:

typedef struct wlan_test_get_scan
{
    unsigned long num_networks;
    unsigned long scan_status;
    unsigned char byte1;
    unsigned char byte2;
    unsigned short time;
    unsigned char ssid_name[32];
    unsigned char bssid[6];
}wlan_test_get_scan;

As you can see this also does not match the documentation.  I came up with this after tracking the problem to where the data is copied in the hci_event_handler.

 

So, can you please confirm the data format for the wlan_ioctl_get_scan_results and the bit packing for the results?

 

Finally, is there additional documentation that gives the api for the cc3000 part (not the driver, but the chip itself)?

 

Thanks

 

 

 

 

cc3000 simplelink wi-fi scanning
Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Gustavo L
    Posted by Gustavo L
    on Feb 21 2012 14:04 PM
    Genius9990 points

    Jeffrey,

    We'll look at this and come back to you.

    Regards,
    Gustavo

    ---------------------------------------------------------------------------------------------------------
    Please click the Verify Answer button on this post if it answers your question.
    ---------------------------------------------------------------------------------------------------------

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Martin Honig
    Posted by Martin Honig
    on Feb 27 2012 06:57 AM
    Prodigy190 points

    Hello Jeffrey,


    I am facing the same problem right now. My colleague, who evaluated CC3000, told me, that the function documentation from the header is invalid. He partially decrypted the format but unfortunately he can provide it to me tomorrow at the earliest. He also told me, that struct from wlan.c is also incorrect. I assume that you are almost there, but I will appreciate if Gustavo provide us proper documentation.

    Martin

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Igor56492
    Posted by Igor56492
    on Feb 27 2012 09:05 AM
    Intellectual1735 points

    Hello 

    Can you please let us know based on which CC3000 Host Driver source code you are working?

    Which application you are based on?

    Regards,

    Igor

    cc3000 simplelink wi-fi Simple WiFi application
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jeffrey Holt
    Posted by Jeffrey Holt
    on Feb 27 2012 09:43 AM
    Prodigy100 points

    The version that prints out the serial port is 1.6.2.2.  I have ported the Basic Wifi Application to a non-DMA Stellaris micro (LM3S300).  I have downloaded every demo version available on the wiki and they all use the same driver code (as far as I can tell).

    I do want to ask again if there is a API document available for  the CC3000 hardware part (not the driver code API)?

    Jeff

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Igor56492
    Posted by Igor56492
    on Feb 27 2012 10:08 AM
    Intellectual1735 points

    Hello Jeffrey

    We are currently using host version 1.7.2.2 so I would suggest using it.

    More than that what are I would suggest you to check is that the CC3000 Host SPI buffer is at least of size 150 bytes for RX and150 for TX.

    On top of that what type of HW documentation you are looking for? We have a modules DS, from LSR and from Murata.

    Is that what you are looking for?

    Regards,

    Igor

    cc3000
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jeffrey Holt
    Posted by Jeffrey Holt
    on Feb 27 2012 10:40 AM
    Prodigy100 points

    I don't think the host version or the spi buffers is at the core of the problem.  Have you had a chance to look into the structure definition that I noted in the original post?

    The type of documentation I am looking for is the type that would be needed if I was writing the CC3000 Host Driver.  If I had a document that gave the API for the CC3000, I could have checked what data was coming out of the module when I issued the get scan results command and checked it against the structure definition.  Does that make sense?

    Jeff

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Igor56492
    Posted by Igor56492
    on Feb 27 2012 10:55 AM
    Intellectual1735 points

    Hey Jeff,

    There is no proper documentation that allows user to re-write the host driver, sorry about that.

    So my suggestion is to use the latest CC3000 Host Driver available on the WiKi together with the latest documentation (Doxygen 1.7.2.2)

    More than that from looking into code the wlan results are returned in the format of:

    {
    //
    // Set to 1 if this entry is occuiped
    //
    unsigned long isValid : 1;
    long rssi : 7;

    //
    // Holds one of the parsed security-modes
    // SECURITY_OPEN, SECURITY_WEP, SECURITY_WPA, SECURITY_WPA2,
    //
    unsigned long securityMode : 2;
    long ulSsidLen : 6;

    //
    // The time of which the frame has enterd (in seconds)
    //
    short frameTime;

    //
    // AP name and MAC address
    //
    char ssid[MAXIMAL_SSID_LENGTH];
    unsigned char ucBssid[ETH_ALEN];
    }WLAN_San_Result_t;

    Is this what you are observing?

    Regards,

    Igor

    cc3000
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jeffrey Holt
    Posted by Jeffrey Holt
    on Feb 27 2012 11:00 AM
    Prodigy100 points

    Igor,

    This is not what I am observing.  Can you please look at my original post again, it explains what the documentation states, how the driver code is currently implemented, and what I needed to do to get this to work.

    Jeff

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Igor56492
    Posted by Igor56492
    on Feb 28 2012 10:41 AM
    Intellectual1735 points

    Hello Jeffrey,

    Please align your code (and documentation) of theBasic WiFi Application to the latest one.

    There definitely is a correct description of the strucuture.

    The link to updated Doxygen is:

    http://processors.wiki.ti.com/index.php/CC3000_Wi-Fi_for_MCU#CC3000_Doxygen_APIs

    More than that can you please share with me a code sample that causes a crash on CC3000 Host Driver?

    Regards,

    Igor

    cc3000
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jeffrey Holt
    Posted by Jeffrey Holt
    on Feb 28 2012 12:21 PM
    Prodigy100 points

    When you say there is a correct description of the structure, can you list here what it is?  My confusion is this:

     

    1) The Doxygen documents states (52 bytes I think, the breakdown of the 44 bytes does not add up to 44)

    long wlan_ioctl_get_scan_results   (unsigned long ulScanTimeout,  unsigned char * ucResults )
            

    Gets the WLAN scan operation results.

    Gets entry from scan result table. The scan results are returned one
    by one, and each entry represents a single AP found in the area. The
    following is a format of hte scan result:

    • 4 Bytes: number of networks found
    • 4 Bytes: The status of the scan: 0 - agged results, 1 - results valid, 2 - no results
    • 44 bytes: Result entry, where the bytes are arranged as follows:
      • 4 bytes isValid - is result valid or not
      • 4 bytes rssi - RSSI value;
      • 4 bytes: securityMode - security mode of the AP: 0 - Open, 1 - WEP, 2 WPA, 3 WPA2
      • 4 bytes: SSID name length
      • 2 bytes: the time at which the entry has entered into scans result table
      • 32 bytes: SSID name
      • 6 bytes: BSSID
    Parameters:
           
    [in] scan_timeout
    [out] ucResults scan resault (WLAN_San_Result_t)
    Returns:
    On success, zero is returned. On error, -1 is returned
    See also:
    wlan_ioctl_set_scan_params
    Note:
    scan_timeout, is not supported on this version.

    2) The structure definition in wlan.c is (56 bytes)

    #ifdef __CCS__
    typedef struct __attribute__ ((__packed__)) _WLAN_San_Result_t
    #elif __IAR_SYSTEMS_ICC__
    #pragma pack(1)
    typedef struct _WLAN_San_Result_t
    #endif
    {
     //
     // Set to 1 if this entry is occuiped
     //
     unsigned long isValid    : 1;
     long rssi       : 7; 

     //
     // Holds one of the parsed security-modes
     // SECURITY_OPEN, SECURITY_WEP, SECURITY_WPA, SECURITY_WPA2,
     //
     unsigned long securityMode : 2;
     long ulSsidLen     : 6;

     //
     // The time of which the frame has enterd (in seconds)
     //
     short         frameTime;

     //
     // AP name and MAC address
     //
     char          ssid[MAXIMAL_SSID_LENGTH];
     unsigned char ucBssid[ETH_ALEN]; 
    }WLAN_San_Result_t;

     

    3) I found that when debugging the code that the structure definition needed to be this (50 bytes):


    typedef struct wlan_test_get_scan
    {
        unsigned long num_networks;
        unsigned long scan_status;
        unsigned char byte1;
        unsigned char byte2;
        unsigned short time;
        unsigned char ssid_name[32];
        unsigned char bssid[6];
    }wlan_test_get_scan;

     

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Igor56492
    Posted by Igor56492
    on Feb 29 2012 09:18 AM
    Intellectual1735 points

    Hello Jeffrey ,

    I finally understand your issue and I am sorry very much for such a long responce time.

    You observation is correct and requires a fix of documentation in the upcomoming version.

    The structure of the scan result is as follows:

    long Count 

    long ScanResultState

    //
     // Set to 1 if this entry is occuiped
     //
     unsigned long isValid    : 1;
     long rssi       : 7; 

     //
     // Holds one of the parsed security-modes
     // SECURITY_OPEN, SECURITY_WEP, SECURITY_WPA, SECURITY_WPA2,
     //
     unsigned long securityMode : 2;
     long ulSsidLen     : 6;

     //
     // The time of which the frame has enterd (in seconds)
     //
     short         frameTime;

     //
     // AP name and MAC address
     //
     char          ssid[MAXIMAL_SSID_LENGTH];
     unsigned char ucBssid[ETH_ALEN]; 

    We will update the documentation and the code itself.

    Regards,

    Igor

    cc3000
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Martin Honig
    Posted by Martin Honig
    on Mar 06 2012 02:26 AM
    Prodigy190 points

    Hello,

    this definition seems to fit the data I observe and the structure my colleague assembled. It is probably not completely right, because RSSI is acting a little bit weird (one network -45(dBm?), second 60), but rest of it looks fine.

    {
    unsigned long networksFound;
    unsigned long scanStatus;
    unsigned long isValid : 1;
    signed long rssi : 7;
    unsigned long securityMode : 2;
    unsigned long ulSsidLen : 6;
    unsigned long frameTime : 16;
    char ssid[32];
    unsigned char ucBssid[6];

    } wifi_scan_result_t;

    Basically scanning seems to depends on other conditions. I am unable to scan (start scan by setting scan parameters and calling get scan result) any network until I try to associate CC3000 to any network (no matter if it is in the area/if I'm successful with association or not).

    If I try to associate I can get data from get scan result function even when I haven't enabled scanning by set scan parameters command, but basically I can get only two networks from get scan result although there are something like 6 networks in the area (powerful enough that It should be scanable).

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Igor56492
    Posted by Igor56492
    on Mar 06 2012 20:47 PM
    Intellectual1735 points

    Hello Martin.

    Please note that in general scanning is enabled in CC3000 by default, so you do not have to enable it. You may disable it though.

    Can you please share the code sample performing a get scan results task?

    Regards,

    Igor

    cc3000
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Martin Honig
    Posted by Martin Honig
    on Mar 07 2012 02:18 AM
    Prodigy190 points

    Hello Igor,

    I am using modified SensorApplication demo, but I got rid of server and waiting for association from state machine in the main(). I enhanced command line to be able to control CC3000, so I implemented several more commands to be able to connect to secure network, set IP address manually/by DHCP, disconnect, scan, etc. I followed programmers guide on your Wiki so my scan command is implemented by following code (added to terminal.c in SensorApp demo runUARTterminal() ).

    When I run "scan" command after reset, I get nothing. When I start scan by "scan start" (wlan_ioctl_set_scan_params(1,....)) and than use "scan" (wlan_ioctl_get_scan_results()) I get nothing again. Only way how to gather data from wlan_ioctl_get_scan_results() is by typing "assoc xxx" (wlan_connect() no matter what ssid, only attempt is enough), then I get some results, no matter if I type "scan star/stop". Second strange thing is, that I am unable to get more than two results from get scan results command and my colleague has the same experience (in both cases there has been more than just two strong networks in area).

    runUARTterminal()
    {
    ............
         else if(checkCommand(uartRXBytePointer(validPos),"scan") == 1)
    {
    if(argn == 2)
    {
    validPos += strlen("scan");
    while(uartRXByte(validPos) < '.' && validPos <= bytesInUart() )
    validPos++;
    if(checkCommand(uartRXBytePointer(validPos),"stop") == 1)
    {
    wifi_scan_mode(0);
    sendString("Scan disabled");
    }
    else if(checkCommand(uartRXBytePointer(validPos),"start") == 1)
    {
    wifi_scan_mode(1);
    sendString("Scan enabled");
    }
    else
    {
    sendString("Invalid argument - use start/stop");
    }
    }
    else if(argn == 1)
    {
    char ssid[64];
    int ssidLen;
    int sec;
    int rssi;

    int attempt = 0;
    int upperLimit = wifi_scan_result(&ssid[0], &ssidLen, &sec, &rssi);
    if(upperLimit == -1)
    {
    sendString("No network in the arrea");
    }
    else
    {
    while(attempt < upperLimit)
    {
    printScanResult(&ssid[0], &ssidLen, &sec, &rssi);
    wifi_scan_result(&ssid[0], &ssidLen, &sec, &rssi);
    attempt++;
    }
    }
    }
    .............
    }
    
    
    int wifi_scan_mode(int enable)
    {
    static unsigned long channel_interval_list[16] =
    {
    WIFI_SCAN_CHANNEL_INTERVAL_LIST,
    WIFI_SCAN_CHANNEL_INTERVAL_LIST,
    WIFI_SCAN_CHANNEL_INTERVAL_LIST,
    WIFI_SCAN_CHANNEL_INTERVAL_LIST,
    WIFI_SCAN_CHANNEL_INTERVAL_LIST,
    WIFI_SCAN_CHANNEL_INTERVAL_LIST,
    WIFI_SCAN_CHANNEL_INTERVAL_LIST,
    WIFI_SCAN_CHANNEL_INTERVAL_LIST,
    WIFI_SCAN_CHANNEL_INTERVAL_LIST,
    WIFI_SCAN_CHANNEL_INTERVAL_LIST,
    WIFI_SCAN_CHANNEL_INTERVAL_LIST,
    WIFI_SCAN_CHANNEL_INTERVAL_LIST,
    WIFI_SCAN_CHANNEL_INTERVAL_LIST,
    WIFI_SCAN_CHANNEL_INTERVAL_LIST,
    WIFI_SCAN_CHANNEL_INTERVAL_LIST,
    WIFI_SCAN_CHANNEL_INTERVAL_LIST
    };

    return wlan_ioctl_set_scan_params(
    enable, 20, 30, 2, 0x1FFF, -80, 0, 205, channel_interval_list
    );
    }

    int wifi_scan_result(char *ssid, int *ssidLen, int *security, int *rssi)
    {
    static unsigned char buffer[50];

    wifi_scan_result_t *result = (wifi_scan_result_t *) buffer;

    memset(buffer, 0, sizeof(buffer));

    if (wlan_ioctl_get_scan_results(WIFI_SCAN_CHANNEL_INTERVAL_LIST+10000, buffer) != 0)
    {
    return -1;
    }

    if (result->isValid != 1)
    {
    return -1;
    }

    memcpy(ssid, result->ssid, result->ulSsidLen);
    ssid[result->ulSsidLen] = '\0';
    *ssidLen = result->ulSsidLen;
    *security = result->securityMode;
    *rssi = result->rssi;

    return result->networks_found;
    }
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jason Powers
    Posted by Jason Powers
    on Mar 18 2012 20:47 PM
    Prodigy10 points

    Martin-

    I am having a similar problem as you and your colleague are having. I am not able to "scan" all the available APs in the area. Initially I wasn't able to scan any APs then I did a "first time configuration" and noticed after that I was able to scan/detect that AP when  issuing a wlan_ioctl_get_scan_results. I then added a second/different AP using the "first time configuration" and low-and-behold after issuing a wlan_ioctl_get_scan_results after that the original as well as the second AP showed up in my results. It appears as tho the only AP the wlan_ioctl_get_scan_results returns are the available APs that are stored in the CC3000s.

    FYI- I did turn off one of the APs and reran the scan and it didn't return that AP in the result. I was just making sure the wlan_ioctl_get_scan_results function wasn't returning the stored values.

    I hope this get fixed soon as it would be nice to be able to scan and choose what AP to connect to depending on where you are.

    Jason

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
12345
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use