Staging:CC3220 Scan Policy (Texas Instruments NDA restrictions applicable)

Overview
This is a sample application demonstrating how to define the device's scan time interval in case there is no connection.

Application Details
Scanning is the process of acknowledging all Wi-Fi networks within the vicinity. There are two types of scanning:
 * Passive scan - The device recognizes all APs by listening to beacon signal only.
 * Actvie scan - The device actively sends PROBE REQUEST packets as broadcast packets, and APs receiving these packets will respond with PROBE RESPONSES.

Simplelink Wi-Fi devices uses active scan. Default interval is 10 minutes. On setting the scan policy, an immediate scan is activated. The next scan will be based on the set interval.

Prerequisite

 * 1x CC3220LP
 * 1x Micro-USB cable

Source Files Details

 * main.c - Initializes the device in default configuration and creates CmdTask'
 * pinmux.c - Pinmux configurations as required by the application.
 * cc_launchpad.c - Initializes peripherals.
 * cmd_scan_policy.c - Implementation to handle all user inputs from the console window
 * scan_policy.c - Implementation to exercise all Scan Policy commands
 * str.c - Defines all command option and message strings
 * timer_if.c - Functions to control timer.
 * uart_if.c - Functions to display information on UART.
 * startup_*.c - IDE specific startup functions (not required when working with TI-RTOS).

Key Simplink API used

 * sl_WlanSet - Setting the scan channel mask and RSSI threshold
 * sl_WlanGet - Retrieving the scan channel mask and RSSI threshold
 * sl_WlanPolicySet - Setting the scan policy, interval, and hiding mask, or disabling scan.
 * sl_WlanPolicyGet - Retrieving the scan policy, interval, and hiding mask
 * sl_WlanGetNetworkList - Retrieving scanned SSID list
 * sl_WlanSetMode - Setting the device mode - STA or AP

General Guidelines

 * 1) Build and run the project.
 * 2) A prompt will appear on the terminal where commands can be entered as described in the following section.

Commands
Usage: help [command name]
 * help

Description: To know more about the command name.

Available commands: help               setpolicy           getpolicy           disablepolicy listssid

Usage: setpolicy [-help] -m -i -c
 * setpolicy

Description: Enables and sets scan policy parameter -m     Device mode for scanning. 0=STA & 2=AP. Default: 0 -i     Scanning interval in seconds. [1, 60]. Default: 10 -v     Showing visible/hidden SSID. 3=ALL, 1=Visible Only (case 2 and 0 not supported). Default: 3 -c     Scanning channel mask in hexadecimal. [0000, 1FFF]. There are 13 bits, and each bit represents a channel. If a bit is set to 1, the channel will be scanned. Default: 0x1FFF -r     Scanning RSSI threshold, in dBm. [-95, 0]. Default: -95 -help  Display this help.

Usage: getpolicy [-help]
 * getpolicy

Description: Gets the current scan policy setting. -help  Display this help.

Usage: disablepolicy [-help]
 * disablepolicy

Description: Disables scan policy. -help  Display this help.

Usage: listssid [-help]
 * listssid

Description: List scan result. Execute repeatedly to see the latest scan result. -help  Display this help.

Example use cases and outputs
command>>:setpolicy Scan Policy configured successfully.
 * Use default settings and list all discovered SSIDs

command>>:getpolicy Device Mode:        Station Scan RSSI Threshold: -95 dBm Scan Channels Mask: 0x1FFF Scan Interval:      10 seconds Scan type:          Visible + Hidden

command>>:listssid Found 17 entries ST=Security Type, GC=Group Cipher, UCB=Unicast Cipher Bitmap KMSB=Key Mgmt Suites Bitmap, H=Hidden SSID                | BSSID             | CH | RSSI | ST | GC | UCB | KMSB | H

=
===================================================================

| **:**:**:3c:0c:ab | 1 | -41  | 4  | 8  | 8   | 2    | 0 | **:**:**:26:e2:02 | 1 | -88  | 4  | 8  | 8   | 2    | 0 | **:**:**:26:ec:a0 | 1 | -75  | 4  | 8  | 8   | 1    | 0 | **:**:**:26:ec:a1 | 1 | -74  | 4  | 8  | 8   | 1    | 0 | **:**:**:26:ec:a2 | 1 | -74  | 4  | 8  | 8   | 2    | 0 | **:**:**:26:e2:00 | 1 | -88  | 4  | 8  | 8   | 1    | 0 | **:**:**:09:64:62 | 2 | -84  | 6  | 4  | 12  | 2    | 0  | **:**:**:0a:1b:48 | 2  | -84  | 6  | 4  | 12  | 2    | 0 | **:**:**:26:e1:61 | 11 | -60 | 4  | 8  | 8   | 1    | 0 | **:**:**:27:3e:02 | 11 | -63 | 4  | 8  | 8   | 2    | 0 | **:**:**:26:e1:62 | 11 | -59 | 4  | 8  | 8   | 2    | 0 | **:**:**:26:e1:60 | 11 | -61 | 4  | 8  | 8   | 1    | 0 | **:**:**:26:e2:c2 | 11 | -80 | 4  | 8  | 8   | 2    | 0 | **:**:**:26:e4:62 | 11 | -81 | 4  | 8  | 8   | 2    | 0 | **:**:**:dc:78:8e | 6 | -53  | 4  | 8  | 8   | 2    | 0 | **:**:**:44:f9:34 | 6 | -47  | 0  | 0  | 0   | 0    | 1 | **:**:**:a6:be:8b | 6 | -72  | 0  | 0  | 0   | 0    | 0

command>>:setpolicy -m 2 -i 5 -v 1 -c 0020 -r -70 Scan Policy configured successfully.
 * Use settings of:
 * Scanning in AP mode
 * Scanning interval of 5 seconds
 * Only visible SSIDs
 * Only channel 6
 * With RSSI threshold of minimum of -70dBm

command>>:getpolicy Device Mode:        Access Point Scan RSSI Threshold: -70 dBm Scan Channels Mask: 0x0020 Scan Interval:      5 seconds Scan type:          Visible Only

command>>:listssid Found 2 entries ST=Security Type, GC=Group Cipher, UCB=Unicast Cipher Bitmap KMSB=Key Mgmt Suites Bitmap, H=Hidden SSID                | BSSID             | CH | RSSI | ST | GC | UCB | KMSB | H

=
===================================================================

| **:**:**:dc:78:8e | 6 | -54  | 4  | 8  | 8   | 2    | 0 | **:**:**:a6:be:8b | 6 | -69  | 0  | 0  | 0   | 0    | 0

Any time after setting the policy, you can retrieve the SSID list as many time as you want, but the list may remain unchanged because the network process has not issued a new scan due to the scanning interval setting.

Limitations/Known Issues
None