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 ------------------------------------
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:
------------------------------- 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
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.---------------------------------------------------------------------------------------------------------
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
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
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
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?
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?
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?
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.
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?
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 )
2) The structure definition in wlan.c is (56 bytes)
// // 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):
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;
We will update the documentation and the code itself.
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).
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?
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;}
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