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