Driver for CC3000 Wi-Fi module

Dependencies:   NVIC_set_all_priorities

Dependents:   CC3000_Simple_Socket Wi-Go_IOT_Demo

Information

The current code has been reworked to a full object oriented application and contains an mbed socket compatible API.

CC3000 Wi-Fi module library

Info

This is the low level driver for TI's SimpleLink CC3000 device.
Port from Avnet's Wi-Go KEIL code (based on TI's CC3000 code).
Special thanks to Jim Carver from Avnet for providing the Wi-Go board and for his assistance.

Differences with TI's original code

The code functionality stays exactly the same.
In order to make it easier to use the code, following changes were made :

  • Addition of a tool to shift all IRQ priorities to a lower level since it is very important to keep the SPI handler at the highest system priority, the WLAN interrupt the second highest and all other system interrupts at a lower priority, so their handlers can be preempted by the CC3000 interrupts.
  • Addition of low level I/O controls and conditional compiler controls in cc3000_common.h.
  • CC3000 initialisation, pin declarations, SPI and WLAN irq priorities are set in Init_HostDriver , we need to call this function at the start of the main function.
  • The SPI and HCI code are joined into one file.
  • The include list has been rearranged - Only #include "wlan.h" is needed in the user API.
  • Part of the CC3000's user eeprom memory is used to store additional info (52 bytes in NVMEM_USER_FILE_1):
# bytesDescriptionInfo
1First time config parameterUseful when connecting
2Firmware updater versionused with the Firmware update tool
2Service Pack versionused with the Firmware update tool
3Driver Versionused with the Firmware update tool
3Firmware Versionused with the Firmware update tool
1CIK validation (Client Interface Key)
40CIK data (Client Interface Key)used with the exosite

Using the Library

A user API is needed to access the CC3000 functions.
Examples:

Using the library with other processors

cc3000_common.cpp loads the irq tool for all targets:
All current mbed targets are supported by this library.

#include "NVIC_set_all_priorities.h"


All low level settings that need to change are available in cc3000_common.h

//*****************************************************************************
//              PIN CONTROLS & COMPILE CONTROLS
//*****************************************************************************
// Compiler control
#define CC3000_UNENCRYPTED_SMART_CONFIG   // No encryption
//#define CC3000_TINY_DRIVER                // Driver for small memory model CPUs

//Interrupt controls
#define NVIC_ALL_IRQ        NVIC_set_all_irq_priorities(3);         // Set ALL interrupt priorities to level 3
#define NVIC_SPI_IRQ        NVIC_SetPriority(SPI0_IRQn, 0x0);       // Wi-Fi SPI interrupt must be higher priority than SysTick
#define NVIC_PORT_IRQ       NVIC_SetPriority(PORTA_IRQn, 0x1);
#define NVIC_SYSTICK_IRQ    NVIC_SetPriority(SysTick_IRQn, 0x2);    // SysTick set to lower priority than Wi-Fi SPI bus interrupt
//#define NVIC_ADC_IRQ        NVIC_SetPriority(ADC0_IRQn, 0x3);       // ADC is the lowest of all

// Wlan controls
#define WLAN_ISF_PCR        PORTA->PCR[16]
#define WLAN_ISF_ISFR       PORTA->ISFR
#define WLAN_ISF_MASK       (1<<16)

#define WLAN_ASSERT_CS      wlan_cs = 0;   //CS : active low
#define WLAN_DEASSERT_CS    wlan_cs = 1;

#define WLAN_ASSERT_EN      wlan_en = 1;   //EN : active high
#define WLAN_DEASSERT_EN    wlan_en = 0;

#define WLAN_READ_IRQ       wlan_int

#define WLAN_ENABLE_IRQ     wlan_int.fall(&WLAN_IRQHandler);
#define WLAN_DISABLE_IRQ    wlan_int.fall(NULL);

#define WLAN_IRQ_PIN_CREATE         InterruptIn wlan_int (PTA16);
#define WLAN_EN_PIN_CREATE          DigitalOut  wlan_en  (PTA13);
#define WLAN_CS_PIN_CREATE          DigitalOut  wlan_cs  (PTD0);
#define WLAN_SPI_PORT_CREATE        SPI wlan(PTD2, PTD3, PTC5); // mosi, miso, sclk

#define WLAN_SPI_PORT_INIT          wlan.format(8,1);
#define WLAN_SPI_SET_FREQ           wlan.frequency(12000000);
#define WLAN_SPI_SET_IRQ_HANDLER    wlan_int.fall(&WLAN_IRQHandler);

#define WLAN_SPI_WRITE              wlan.write(*data++);
#define WLAN_SPI_READ               wlan.write(0x03);          // !! DO NOT MODIFY the 0x03 parameter (CC3000 will not respond).

API documentation

Due to a little problem with the links on the mbed site, the API documentation is not directly accessible (will be solved in a next release).
Currently, it is only accessible by adding modules.html to the API doc link: http://mbed.org/users/frankvnk/code/CC3000_Hostdriver/docs/tip/modules.html

Committer:
frankvnk
Date:
Mon Jul 15 14:19:46 2013 +0000
Revision:
4:d8255a5aad46
Parent:
0:c44f0314d6ec
Child:
5:854f9b13a0f9
Full clean up (comments, Doxygen, code)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
frankvnk 0:c44f0314d6ec 1 /*****************************************************************************
frankvnk 0:c44f0314d6ec 2 *
frankvnk 0:c44f0314d6ec 3 * wlan.h - CC3000 Host Driver Implementation.
frankvnk 0:c44f0314d6ec 4 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
frankvnk 0:c44f0314d6ec 5 *
frankvnk 0:c44f0314d6ec 6 * Redistribution and use in source and binary forms, with or without
frankvnk 0:c44f0314d6ec 7 * modification, are permitted provided that the following conditions
frankvnk 0:c44f0314d6ec 8 * are met:
frankvnk 0:c44f0314d6ec 9 *
frankvnk 0:c44f0314d6ec 10 * Redistributions of source code must retain the above copyright
frankvnk 0:c44f0314d6ec 11 * notice, this list of conditions and the following disclaimer.
frankvnk 0:c44f0314d6ec 12 *
frankvnk 0:c44f0314d6ec 13 * Redistributions in binary form must reproduce the above copyright
frankvnk 0:c44f0314d6ec 14 * notice, this list of conditions and the following disclaimer in the
frankvnk 0:c44f0314d6ec 15 * documentation and/or other materials provided with the
frankvnk 0:c44f0314d6ec 16 * distribution.
frankvnk 0:c44f0314d6ec 17 *
frankvnk 0:c44f0314d6ec 18 * Neither the name of Texas Instruments Incorporated nor the names of
frankvnk 0:c44f0314d6ec 19 * its contributors may be used to endorse or promote products derived
frankvnk 0:c44f0314d6ec 20 * from this software without specific prior written permission.
frankvnk 0:c44f0314d6ec 21 *
frankvnk 0:c44f0314d6ec 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
frankvnk 0:c44f0314d6ec 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
frankvnk 0:c44f0314d6ec 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
frankvnk 0:c44f0314d6ec 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
frankvnk 0:c44f0314d6ec 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
frankvnk 0:c44f0314d6ec 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
frankvnk 0:c44f0314d6ec 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
frankvnk 0:c44f0314d6ec 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
frankvnk 0:c44f0314d6ec 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
frankvnk 0:c44f0314d6ec 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
frankvnk 0:c44f0314d6ec 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
frankvnk 0:c44f0314d6ec 33 *
frankvnk 0:c44f0314d6ec 34 *****************************************************************************/
frankvnk 0:c44f0314d6ec 35 #ifndef __WLAN_H__
frankvnk 0:c44f0314d6ec 36 #define __WLAN_H__
frankvnk 0:c44f0314d6ec 37
frankvnk 0:c44f0314d6ec 38 #include "GlobalAssigns.h"
frankvnk 0:c44f0314d6ec 39 #include "cc3000_common.h"
frankvnk 0:c44f0314d6ec 40 #include "hci.h"
frankvnk 0:c44f0314d6ec 41 #include "CC3000_spi.h"
frankvnk 0:c44f0314d6ec 42 #include "socket.h"
frankvnk 0:c44f0314d6ec 43 #include "nvmem.h"
frankvnk 0:c44f0314d6ec 44 #include "security.h"
frankvnk 0:c44f0314d6ec 45 #include "evnt_handler.h"
frankvnk 0:c44f0314d6ec 46
frankvnk 0:c44f0314d6ec 47 /** CC3000 Host driver - WLAN
frankvnk 0:c44f0314d6ec 48 *
frankvnk 0:c44f0314d6ec 49 */
frankvnk 4:d8255a5aad46 50
frankvnk 0:c44f0314d6ec 51 #ifdef __cplusplus
frankvnk 0:c44f0314d6ec 52 extern "C" {
frankvnk 0:c44f0314d6ec 53 #endif
frankvnk 0:c44f0314d6ec 54
frankvnk 4:d8255a5aad46 55 #define SMART_CONFIG_PROFILE_SIZE 67 // 67 = 32 (max ssid) + 32 (max key) + 1 (SSID length) + 1 (security type) + 1 (key length)
frankvnk 4:d8255a5aad46 56
frankvnk 4:d8255a5aad46 57 /* patches type */
frankvnk 4:d8255a5aad46 58 #define PATCHES_HOST_TYPE_WLAN_DRIVER 0x01
frankvnk 4:d8255a5aad46 59 #define PATCHES_HOST_TYPE_WLAN_FW 0x02
frankvnk 4:d8255a5aad46 60 #define PATCHES_HOST_TYPE_BOOTLOADER 0x03
frankvnk 4:d8255a5aad46 61
frankvnk 4:d8255a5aad46 62 #define SL_SET_SCAN_PARAMS_INTERVAL_LIST_SIZE (16)
frankvnk 4:d8255a5aad46 63 #define SL_SIMPLE_CONFIG_PREFIX_LENGTH (3)
frankvnk 4:d8255a5aad46 64 #define ETH_ALEN (6)
frankvnk 4:d8255a5aad46 65 #define MAXIMAL_SSID_LENGTH (32)
frankvnk 4:d8255a5aad46 66
frankvnk 4:d8255a5aad46 67 #define SL_PATCHES_REQUEST_DEFAULT (0)
frankvnk 4:d8255a5aad46 68 #define SL_PATCHES_REQUEST_FORCE_HOST (1)
frankvnk 4:d8255a5aad46 69 #define SL_PATCHES_REQUEST_FORCE_NONE (2)
frankvnk 4:d8255a5aad46 70
frankvnk 4:d8255a5aad46 71
frankvnk 4:d8255a5aad46 72 #define WLAN_SEC_UNSEC (0)
frankvnk 4:d8255a5aad46 73 #define WLAN_SEC_WEP (1)
frankvnk 4:d8255a5aad46 74 #define WLAN_SEC_WPA (2)
frankvnk 4:d8255a5aad46 75 #define WLAN_SEC_WPA2 (3)
frankvnk 4:d8255a5aad46 76
frankvnk 4:d8255a5aad46 77
frankvnk 4:d8255a5aad46 78 #define WLAN_SL_INIT_START_PARAMS_LEN (1)
frankvnk 4:d8255a5aad46 79 #define WLAN_PATCH_PARAMS_LENGTH (8)
frankvnk 4:d8255a5aad46 80 #define WLAN_SET_CONNECTION_POLICY_PARAMS_LEN (12)
frankvnk 4:d8255a5aad46 81 #define WLAN_DEL_PROFILE_PARAMS_LEN (4)
frankvnk 4:d8255a5aad46 82 #define WLAN_SET_MASK_PARAMS_LEN (4)
frankvnk 4:d8255a5aad46 83 #define WLAN_SET_SCAN_PARAMS_LEN (100)
frankvnk 4:d8255a5aad46 84 #define WLAN_GET_SCAN_RESULTS_PARAMS_LEN (4)
frankvnk 4:d8255a5aad46 85 #define WLAN_ADD_PROFILE_NOSEC_PARAM_LEN (24)
frankvnk 4:d8255a5aad46 86 #define WLAN_ADD_PROFILE_WEP_PARAM_LEN (36)
frankvnk 4:d8255a5aad46 87 #define WLAN_ADD_PROFILE_WPA_PARAM_LEN (44)
frankvnk 4:d8255a5aad46 88 #define WLAN_CONNECT_PARAM_LEN (29)
frankvnk 4:d8255a5aad46 89 #define WLAN_SMART_CONFIG_START_PARAMS_LEN (4)
frankvnk 4:d8255a5aad46 90
frankvnk 4:d8255a5aad46 91
frankvnk 0:c44f0314d6ec 92 #define WLAN_SEC_UNSEC (0)
frankvnk 0:c44f0314d6ec 93 #define WLAN_SEC_WEP (1)
frankvnk 0:c44f0314d6ec 94 #define WLAN_SEC_WPA (2)
frankvnk 0:c44f0314d6ec 95 #define WLAN_SEC_WPA2 (3)
frankvnk 0:c44f0314d6ec 96
frankvnk 4:d8255a5aad46 97 /**
frankvnk 4:d8255a5aad46 98 * Send HCI_CMND_SIMPLE_LINK_START to CC3000
frankvnk 4:d8255a5aad46 99 * @param usPatchesAvailableAtHost flag to indicate if patches available
frankvnk 4:d8255a5aad46 100 * from host or from EEPROM. Due to the
frankvnk 4:d8255a5aad46 101 * fact the patches are burn to the EEPROM
frankvnk 4:d8255a5aad46 102 * using the patch programmer utility, the
frankvnk 4:d8255a5aad46 103 * patches will be available from the EEPROM
frankvnk 4:d8255a5aad46 104 * and not from the host.
frankvnk 4:d8255a5aad46 105 * @return none
frankvnk 4:d8255a5aad46 106 */
frankvnk 4:d8255a5aad46 107 static void SimpleLink_Init_Start(unsigned short usPatchesAvailableAtHost);
frankvnk 0:c44f0314d6ec 108
frankvnk 4:d8255a5aad46 109 /**
frankvnk 4:d8255a5aad46 110 * Initialize wlan driver
frankvnk 4:d8255a5aad46 111 * @param sWlanCB Asynchronous events callback.
frankvnk 4:d8255a5aad46 112 * 0 no event call back.
frankvnk 4:d8255a5aad46 113 * -call back parameters:
frankvnk 4:d8255a5aad46 114 * 1) event_type: HCI_EVNT_WLAN_UNSOL_CONNECT connect event,
frankvnk 4:d8255a5aad46 115 * HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event,
frankvnk 4:d8255a5aad46 116 * HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE config done,
frankvnk 4:d8255a5aad46 117 * HCI_EVNT_WLAN_UNSOL_DHCP dhcp report,
frankvnk 4:d8255a5aad46 118 * HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report OR
frankvnk 4:d8255a5aad46 119 * HCI_EVNT_WLAN_KEEPALIVE keepalive.
frankvnk 4:d8255a5aad46 120 * 2) data: pointer to extra data that received by the event
frankvnk 4:d8255a5aad46 121 * (NULL no data).
frankvnk 4:d8255a5aad46 122 * 3) length: data length.
frankvnk 4:d8255a5aad46 123 * -Events with extra data:
frankvnk 4:d8255a5aad46 124 * HCI_EVNT_WLAN_UNSOL_DHCP: 4 bytes IP, 4 bytes Mask,
frankvnk 4:d8255a5aad46 125 * 4 bytes default gateway, 4 bytes DHCP server and 4 bytes
frankvnk 4:d8255a5aad46 126 * for DNS server.
frankvnk 4:d8255a5aad46 127 * HCI_EVNT_WLAN_ASYNC_PING_REPORT: 4 bytes Packets sent,
frankvnk 4:d8255a5aad46 128 * 4 bytes Packets received, 4 bytes Min round time,
frankvnk 4:d8255a5aad46 129 * 4 bytes Max round time and 4 bytes for Avg round time.
frankvnk 4:d8255a5aad46 130 * @param sFWPatches 0 no patch or pointer to FW patches
frankvnk 4:d8255a5aad46 131 * @param sDriverPatches 0 no patch or pointer to driver patches
frankvnk 4:d8255a5aad46 132 * @param sBootLoaderPatches 0 no patch or pointer to bootloader patches
frankvnk 4:d8255a5aad46 133 * @param sReadWlanInterruptPin init callback. the callback read wlan interrupt status.
frankvnk 4:d8255a5aad46 134 * @param sWlanInterruptEnable init callback. the callback enable wlan interrupt.
frankvnk 4:d8255a5aad46 135 * @param sWlanInterruptDisable init callback. the callback disable wlan interrupt.
frankvnk 4:d8255a5aad46 136 * @param sWriteWlanPin init callback. the callback write value to device pin.
frankvnk 4:d8255a5aad46 137 * @return none
frankvnk 4:d8255a5aad46 138 * @sa wlan_set_event_mask , wlan_start , wlan_stop
frankvnk 4:d8255a5aad46 139 * @warning This function must be called before ANY other wlan driver function
frankvnk 4:d8255a5aad46 140 */
frankvnk 0:c44f0314d6ec 141 extern void wlan_init(tWlanCB sWlanCB,
frankvnk 0:c44f0314d6ec 142 tFWPatches sFWPatches,
frankvnk 0:c44f0314d6ec 143 tDriverPatches sDriverPatches,
frankvnk 0:c44f0314d6ec 144 tBootLoaderPatches sBootLoaderPatches,
frankvnk 0:c44f0314d6ec 145 tWlanReadInteruptPin sReadWlanInterruptPin,
frankvnk 0:c44f0314d6ec 146 tWlanInterruptEnable sWlanInterruptEnable,
frankvnk 0:c44f0314d6ec 147 tWlanInterruptDisable sWlanInterruptDisable,
frankvnk 0:c44f0314d6ec 148 tWriteWlanPin sWriteWlanPin);
frankvnk 0:c44f0314d6ec 149
frankvnk 4:d8255a5aad46 150 /**
frankvnk 4:d8255a5aad46 151 * Trigger Received event/data processing - called from the SPI library to receive the data
frankvnk 4:d8255a5aad46 152 * @param pvBuffer - pointer to the received data buffer
frankvnk 4:d8255a5aad46 153 * The function triggers Received event/data processing
frankvnk 4:d8255a5aad46 154 * @param Pointer to the received data
frankvnk 4:d8255a5aad46 155 * @return none
frankvnk 4:d8255a5aad46 156 */
frankvnk 4:d8255a5aad46 157 void SpiReceiveHandler(void *pvBuffer);
frankvnk 0:c44f0314d6ec 158
frankvnk 0:c44f0314d6ec 159
frankvnk 4:d8255a5aad46 160 /**
frankvnk 4:d8255a5aad46 161 * Start WLAN device. This function asserts the enable pin of
frankvnk 4:d8255a5aad46 162 * the device (WLAN_EN), starting the HW initialization process.
frankvnk 4:d8255a5aad46 163 * The function blocked until device Initialization is completed.
frankvnk 4:d8255a5aad46 164 * Function also configure patches (FW, driver or bootloader)
frankvnk 4:d8255a5aad46 165 * and calls appropriate device callbacks.
frankvnk 4:d8255a5aad46 166 * @param usPatchesAvailableAtHost - flag to indicate if patches available
frankvnk 4:d8255a5aad46 167 * from host or from EEPROM. Due to the
frankvnk 4:d8255a5aad46 168 * fact the patches are burn to the EEPROM
frankvnk 4:d8255a5aad46 169 * using the patch programmer utility, the
frankvnk 4:d8255a5aad46 170 * patches will be available from the EEPROM
frankvnk 4:d8255a5aad46 171 * and not from the host.
frankvnk 4:d8255a5aad46 172 * @return none
frankvnk 4:d8255a5aad46 173 * @Note Prior calling the function wlan_init shall be called.
frankvnk 4:d8255a5aad46 174 * @Warning This function must be called after wlan_init and before any
frankvnk 4:d8255a5aad46 175 * other wlan API
frankvnk 4:d8255a5aad46 176 * @sa wlan_init , wlan_stop
frankvnk 4:d8255a5aad46 177 */
frankvnk 0:c44f0314d6ec 178 extern void wlan_start(unsigned short usPatchesAvailableAtHost);
frankvnk 0:c44f0314d6ec 179
frankvnk 4:d8255a5aad46 180 /**
frankvnk 4:d8255a5aad46 181 * Stop WLAN device by putting it into reset state.
frankvnk 4:d8255a5aad46 182 * @param none
frankvnk 4:d8255a5aad46 183 * @return none
frankvnk 4:d8255a5aad46 184 * @sa wlan_start
frankvnk 4:d8255a5aad46 185 */
frankvnk 0:c44f0314d6ec 186 extern void wlan_stop(void);
frankvnk 0:c44f0314d6ec 187
frankvnk 4:d8255a5aad46 188 /**
frankvnk 4:d8255a5aad46 189 * Connect to AP
frankvnk 4:d8255a5aad46 190 * @param sec_type security options:
frankvnk 4:d8255a5aad46 191 * WLAN_SEC_UNSEC,
frankvnk 4:d8255a5aad46 192 * WLAN_SEC_WEP (ASCII support only),
frankvnk 4:d8255a5aad46 193 * WLAN_SEC_WPA or WLAN_SEC_WPA2
frankvnk 4:d8255a5aad46 194 * @param ssid up to 32 bytes and is ASCII SSID of the AP
frankvnk 4:d8255a5aad46 195 * @param ssid_len length of the SSID
frankvnk 4:d8255a5aad46 196 * @param bssid 6 bytes specified the AP bssid
frankvnk 4:d8255a5aad46 197 * @param key up to 16 bytes specified the AP security key
frankvnk 4:d8255a5aad46 198 * @param key_len key length
frankvnk 4:d8255a5aad46 199 * @return On success, zero is returned. On error, negative is returned.
frankvnk 4:d8255a5aad46 200 * Note that even though a zero is returned on success to trigger
frankvnk 4:d8255a5aad46 201 * connection operation, it does not mean that CCC3000 is already
frankvnk 4:d8255a5aad46 202 * connected. An asynchronous "Connected" event is generated when
frankvnk 4:d8255a5aad46 203 * actual association process finishes and CC3000 is connected to
frankvnk 4:d8255a5aad46 204 * the AP. If DHCP is set, An asynchronous "DHCP" event is
frankvnk 4:d8255a5aad46 205 * generated when DHCP process is finish.
frankvnk 4:d8255a5aad46 206 * @warning Please Note that when connection to AP configured with security
frankvnk 4:d8255a5aad46 207 * type WEP, please confirm that the key is set as ASCII and not as HEX.
frankvnk 4:d8255a5aad46 208 * @sa wlan_disconnect
frankvnk 4:d8255a5aad46 209 */
frankvnk 0:c44f0314d6ec 210 #ifndef CC3000_TINY_DRIVER
frankvnk 0:c44f0314d6ec 211 extern long wlan_connect(unsigned long ulSecType,
frankvnk 0:c44f0314d6ec 212 char *ssid,
frankvnk 0:c44f0314d6ec 213 long ssid_len,
frankvnk 0:c44f0314d6ec 214 unsigned char *bssid,
frankvnk 0:c44f0314d6ec 215 unsigned char *key,
frankvnk 0:c44f0314d6ec 216 long key_len);
frankvnk 0:c44f0314d6ec 217 #else
frankvnk 0:c44f0314d6ec 218 extern long wlan_connect(char *ssid, long ssid_len);
frankvnk 0:c44f0314d6ec 219
frankvnk 0:c44f0314d6ec 220 #endif
frankvnk 0:c44f0314d6ec 221
frankvnk 4:d8255a5aad46 222 /**
frankvnk 4:d8255a5aad46 223 * Disconnect connection from AP.
frankvnk 4:d8255a5aad46 224 * @return 0 disconnected done, other CC3000 already disconnected
frankvnk 4:d8255a5aad46 225 * @sa wlan_connect
frankvnk 4:d8255a5aad46 226 */
frankvnk 0:c44f0314d6ec 227 extern long wlan_disconnect(void);
frankvnk 0:c44f0314d6ec 228
frankvnk 4:d8255a5aad46 229 /**
frankvnk 4:d8255a5aad46 230 * Add profile
frankvnk 4:d8255a5aad46 231 * When auto start is enabled, the device connects to
frankvnk 4:d8255a5aad46 232 * station from the profiles table. Up to 7 profiles are supported.
frankvnk 4:d8255a5aad46 233 * If several profiles configured the device choose the highest
frankvnk 4:d8255a5aad46 234 * priority profile, within each priority group, device will choose
frankvnk 4:d8255a5aad46 235 * profile based on security policy, signal strength, etc
frankvnk 4:d8255a5aad46 236 * parameters. All the profiles are stored in CC3000 NVMEM.
frankvnk 4:d8255a5aad46 237 *
frankvnk 4:d8255a5aad46 238 * @param ulSecType WLAN_SEC_UNSEC,WLAN_SEC_WEP,WLAN_SEC_WPA,WLAN_SEC_WPA2
frankvnk 4:d8255a5aad46 239 * @param ucSsid ssid SSID up to 32 bytes
frankvnk 4:d8255a5aad46 240 * @param ulSsidLen ssid length
frankvnk 4:d8255a5aad46 241 * @param ucBssid bssid 6 bytes
frankvnk 4:d8255a5aad46 242 * @param ulPriority ulPriority profile priority. Lowest priority:0.
frankvnk 4:d8255a5aad46 243 * @param ulPairwiseCipher_Or_TxKeyLen key length for WEP security
frankvnk 4:d8255a5aad46 244 * @param ulGroupCipher_TxKeyIndex key index
frankvnk 4:d8255a5aad46 245 * @param ulKeyMgmt KEY management
frankvnk 4:d8255a5aad46 246 * @param ucPf_OrKey security key
frankvnk 4:d8255a5aad46 247 * @param ulPassPhraseLen security key length for WPA\WPA2
frankvnk 4:d8255a5aad46 248 * @return On success, zero is returned. On error, -1 is returned
frankvnk 4:d8255a5aad46 249 * @sa wlan_ioctl_del_profile
frankvnk 4:d8255a5aad46 250 */
frankvnk 0:c44f0314d6ec 251 extern long wlan_add_profile(unsigned long ulSecType,
frankvnk 0:c44f0314d6ec 252 unsigned char* ucSsid,
frankvnk 0:c44f0314d6ec 253 unsigned long ulSsidLen,
frankvnk 0:c44f0314d6ec 254 unsigned char *ucBssid,
frankvnk 0:c44f0314d6ec 255 unsigned long ulPriority,
frankvnk 0:c44f0314d6ec 256 unsigned long ulPairwiseCipher_Or_Key,
frankvnk 0:c44f0314d6ec 257 unsigned long ulGroupCipher_TxKeyLen,
frankvnk 0:c44f0314d6ec 258 unsigned long ulKeyMgmt,
frankvnk 0:c44f0314d6ec 259 unsigned char* ucPf_OrKey,
frankvnk 0:c44f0314d6ec 260 unsigned long ulPassPhraseLen);
frankvnk 0:c44f0314d6ec 261
frankvnk 4:d8255a5aad46 262 /**
frankvnk 4:d8255a5aad46 263 * Delete WLAN profile
frankvnk 4:d8255a5aad46 264 * @param index number of profile to delete
frankvnk 4:d8255a5aad46 265 * @return On success, zero is returned. On error, -1 is returned
frankvnk 4:d8255a5aad46 266 * @Note In order to delete all stored profile, set index to 255.
frankvnk 4:d8255a5aad46 267 * @sa wlan_add_profile
frankvnk 4:d8255a5aad46 268 */
frankvnk 0:c44f0314d6ec 269 extern long wlan_ioctl_del_profile(unsigned long ulIndex);
frankvnk 0:c44f0314d6ec 270
frankvnk 4:d8255a5aad46 271 /**
frankvnk 4:d8255a5aad46 272 * Mask event according to bit mask. In case that event is
frankvnk 4:d8255a5aad46 273 * masked (1), the device will not send the masked event to host.
frankvnk 4:d8255a5aad46 274 * @param mask mask option:
frankvnk 4:d8255a5aad46 275 * HCI_EVNT_WLAN_UNSOL_CONNECT connect event
frankvnk 4:d8255a5aad46 276 * HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event
frankvnk 4:d8255a5aad46 277 * HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE smart config done
frankvnk 4:d8255a5aad46 278 * HCI_EVNT_WLAN_UNSOL_INIT init done
frankvnk 4:d8255a5aad46 279 * HCI_EVNT_WLAN_UNSOL_DHCP dhcp event report
frankvnk 4:d8255a5aad46 280 * HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report
frankvnk 4:d8255a5aad46 281 * HCI_EVNT_WLAN_KEEPALIVE keepalive
frankvnk 4:d8255a5aad46 282 * HCI_EVNT_WLAN_TX_COMPLETE - disable information on end of transmission
frankvnk 4:d8255a5aad46 283 * Saved: no.
frankvnk 4:d8255a5aad46 284 * @return On success, zero is returned. On error, -1 is returned
frankvnk 4:d8255a5aad46 285 */
frankvnk 0:c44f0314d6ec 286 extern long wlan_set_event_mask(unsigned long ulMask);
frankvnk 0:c44f0314d6ec 287
frankvnk 4:d8255a5aad46 288 /**
frankvnk 4:d8255a5aad46 289 * Get wlan status: disconnected, scanning, connecting or connected
frankvnk 4:d8255a5aad46 290 * @param none
frankvnk 4:d8255a5aad46 291 * @return WLAN_STATUS_DISCONNECTED, WLAN_STATUS_SCANING,
frankvnk 4:d8255a5aad46 292 * STATUS_CONNECTING or WLAN_STATUS_CONNECTED
frankvnk 4:d8255a5aad46 293 */
frankvnk 0:c44f0314d6ec 294 extern long wlan_ioctl_statusget(void);
frankvnk 0:c44f0314d6ec 295
frankvnk 0:c44f0314d6ec 296
frankvnk 4:d8255a5aad46 297 /**
frankvnk 4:d8255a5aad46 298 * Set connection policy
frankvnk 4:d8255a5aad46 299 * When auto is enabled, the device tries to connect according the following policy:
frankvnk 4:d8255a5aad46 300 * 1) If fast connect is enabled and last connection is valid,
frankvnk 4:d8255a5aad46 301 * the device will try to connect to it without the scanning
frankvnk 4:d8255a5aad46 302 * procedure (fast). The last connection will be marked as
frankvnk 4:d8255a5aad46 303 * invalid, due to adding/removing profile.
frankvnk 4:d8255a5aad46 304 * 2) If profile exists, the device will try to connect it
frankvnk 4:d8255a5aad46 305 * (Up to seven profiles).
frankvnk 4:d8255a5aad46 306 * 3) If fast and profiles are not found, and open mode is
frankvnk 4:d8255a5aad46 307 * enabled, the device will try to connect to any AP.
frankvnk 4:d8255a5aad46 308 * Note that the policy settings are stored in the CC3000 NVMEM.
frankvnk 4:d8255a5aad46 309 * @param should_connect_to_open_ap enable(1), disable(0) connect to any
frankvnk 4:d8255a5aad46 310 * available AP. This parameter corresponds to the configuration of
frankvnk 4:d8255a5aad46 311 * item # 3 in the brief description.
frankvnk 4:d8255a5aad46 312 * @param should_use_fast_connect enable(1), disable(0). if enabled, tries
frankvnk 4:d8255a5aad46 313 * to connect to the last connected AP. This parameter corresponds
frankvnk 4:d8255a5aad46 314 * to the configuration of item # 1 in the brief description.
frankvnk 4:d8255a5aad46 315 * @param auto_start enable(1), disable(0) auto connect
frankvnk 4:d8255a5aad46 316 * after reset and periodically reconnect if needed. This
frankvnk 4:d8255a5aad46 317 * configuration configures option 2 in the above description.
frankvnk 4:d8255a5aad46 318 * @return On success, zero is returned. On error, -1 is returned
frankvnk 4:d8255a5aad46 319 * @sa wlan_add_profile , wlan_ioctl_del_profile
frankvnk 4:d8255a5aad46 320 */
frankvnk 0:c44f0314d6ec 321 extern long wlan_ioctl_set_connection_policy(unsigned long should_connect_to_open_ap,
frankvnk 0:c44f0314d6ec 322 unsigned long should_use_fast_connect,
frankvnk 0:c44f0314d6ec 323 unsigned long ulUseProfiles);
frankvnk 0:c44f0314d6ec 324
frankvnk 4:d8255a5aad46 325 /**
frankvnk 4:d8255a5aad46 326 * Gets entry from scan result table.
frankvnk 4:d8255a5aad46 327 * The scan results are returned one by one, and each entry represents a single AP found in the area.
frankvnk 4:d8255a5aad46 328 * The following is a format of the scan result:
frankvnk 4:d8255a5aad46 329 * - 4 Bytes: number of networks found
frankvnk 4:d8255a5aad46 330 * - 4 Bytes: The status of the scan: 0 - aged results, 1 - results valid, 2 - no results
frankvnk 4:d8255a5aad46 331 * - 42 bytes: Result entry, where the bytes are arranged as follows:
frankvnk 4:d8255a5aad46 332 * - 1 bit isValid - is result valid or not
frankvnk 4:d8255a5aad46 333 * - 7 bits rssi - RSSI value
frankvnk 4:d8255a5aad46 334 * - 2 bits securityMode - security mode of the AP: 0 - Open, 1 - WEP, 2 WPA, 3 WPA2
frankvnk 4:d8255a5aad46 335 * - 6 bits SSID name length
frankvnk 4:d8255a5aad46 336 * - 2 bytes the time at which the entry has entered into scans result table
frankvnk 4:d8255a5aad46 337 * - 32 bytes SSID name
frankvnk 4:d8255a5aad46 338 * - 6 bytes BSSID
frankvnk 4:d8255a5aad46 339 * @param[in] scan_timeout parameter not supported
frankvnk 4:d8255a5aad46 340 * @param[out] ucResults scan result (_wlan_full_scan_results_args_t)
frankvnk 4:d8255a5aad46 341 * @return On success, zero is returned. On error, -1 is returned
frankvnk 4:d8255a5aad46 342 * @Note scan_timeout, is not supported on this version.
frankvnk 4:d8255a5aad46 343 * @sa wlan_ioctl_set_scan_params
frankvnk 4:d8255a5aad46 344 */
frankvnk 0:c44f0314d6ec 345 extern long wlan_ioctl_get_scan_results(unsigned long ulScanTimeout,
frankvnk 0:c44f0314d6ec 346 unsigned char *ucResults);
frankvnk 0:c44f0314d6ec 347
frankvnk 4:d8255a5aad46 348 /**
frankvnk 4:d8255a5aad46 349 * start and stop scan procedure. Set scan parameters.
frankvnk 4:d8255a5aad46 350 * @param uiEnable start/stop application scan:
frankvnk 4:d8255a5aad46 351 * 1 = start scan with default interval value of 10 min.
frankvnk 4:d8255a5aad46 352 * To set a different scan interval value, apply the value in milliseconds.
frankvnk 4:d8255a5aad46 353 * minimum = 1 second. 0=stop.
frankvnk 4:d8255a5aad46 354 * Wlan reset (wlan_stop() wlan_start()) is needed when changing scan interval value.
frankvnk 4:d8255a5aad46 355 * Saved: No
frankvnk 4:d8255a5aad46 356 * @param uiMinDwellTime minimum dwell time value to be used for each channel, in milliseconds.
frankvnk 4:d8255a5aad46 357 * Saved: yes
frankvnk 4:d8255a5aad46 358 * Recommended Value: 100
frankvnk 4:d8255a5aad46 359 * Default: 20
frankvnk 4:d8255a5aad46 360 * @param uiMaxDwellTime maximum dwell time value to be used for each channel, in milliseconds.
frankvnk 4:d8255a5aad46 361 * Saved: yes
frankvnk 4:d8255a5aad46 362 * Recommended Value: 100
frankvnk 4:d8255a5aad46 363 * Default: 30
frankvnk 4:d8255a5aad46 364 * @param uiNumOfProbeRequests max probe request between dwell time.
frankvnk 4:d8255a5aad46 365 * Saved: yes.
frankvnk 4:d8255a5aad46 366 * Recommended Value: 5
frankvnk 4:d8255a5aad46 367 * Default:2
frankvnk 4:d8255a5aad46 368 * @param uiChannelMask bitwise, up to 13 channels (0x1fff).
frankvnk 4:d8255a5aad46 369 * Saved: yes.
frankvnk 4:d8255a5aad46 370 * Default: 0x7ff
frankvnk 4:d8255a5aad46 371 * @param uiRSSIThreshold RSSI threshold.
frankvnk 4:d8255a5aad46 372 * Saved: yes
frankvnk 4:d8255a5aad46 373 * Default: -80
frankvnk 4:d8255a5aad46 374 * @param uiSNRThreshold NSR threshold.
frankvnk 4:d8255a5aad46 375 * Saved: yes
frankvnk 4:d8255a5aad46 376 * Default: 0
frankvnk 4:d8255a5aad46 377 * @param uiDefaultTxPower probe Tx power.
frankvnk 4:d8255a5aad46 378 * Saved: yes
frankvnk 4:d8255a5aad46 379 * Default: 205
frankvnk 4:d8255a5aad46 380 * @param aiIntervalList pointer to array with 16 entries (16 channels)
frankvnk 4:d8255a5aad46 381 * Each entry (unsigned long) holds timeout between periodic scan
frankvnk 4:d8255a5aad46 382 * and connection scan - in milliseconds.
frankvnk 4:d8255a5aad46 383 * Saved: yes.
frankvnk 4:d8255a5aad46 384 * Default 2000ms.
frankvnk 4:d8255a5aad46 385 * @return On success, zero is returned. On error, -1 is returned
frankvnk 4:d8255a5aad46 386 * @Note uiDefaultTxPower, is not supported on this version.
frankvnk 4:d8255a5aad46 387 * @sa wlan_ioctl_get_scan_results
frankvnk 4:d8255a5aad46 388 */
frankvnk 0:c44f0314d6ec 389 extern long wlan_ioctl_set_scan_params(unsigned long uiEnable,
frankvnk 0:c44f0314d6ec 390 unsigned long uiMinDwellTime,
frankvnk 0:c44f0314d6ec 391 unsigned long uiMaxDwellTime,
frankvnk 0:c44f0314d6ec 392 unsigned long uiNumOfProbeRequests,
frankvnk 0:c44f0314d6ec 393 unsigned long uiChannelMask,
frankvnk 0:c44f0314d6ec 394 long iRSSIThreshold,
frankvnk 0:c44f0314d6ec 395 unsigned long uiSNRThreshold,
frankvnk 0:c44f0314d6ec 396 unsigned long uiDefaultTxPower,
frankvnk 0:c44f0314d6ec 397 unsigned long *aiIntervalList);
frankvnk 0:c44f0314d6ec 398
frankvnk 0:c44f0314d6ec 399
frankvnk 4:d8255a5aad46 400 /**
frankvnk 4:d8255a5aad46 401 * Start to acquire device profile. The device acquire its own profile, if profile message is found.
frankvnk 4:d8255a5aad46 402 * The acquired AP information is stored in CC3000 EEPROM only when AES128 encryption is used.
frankvnk 4:d8255a5aad46 403 * When AES128 encryption is not used, a profile is internally created by the device.
frankvnk 4:d8255a5aad46 404 * @param algoEncryptedFlag indicates whether the information is encrypted
frankvnk 4:d8255a5aad46 405 * @return On success, zero is returned. On error, -1 is returned
frankvnk 4:d8255a5aad46 406 * @Note An asynchronous event - Smart Config Done will be generated as soon
frankvnk 4:d8255a5aad46 407 * as the process finishes successfully.
frankvnk 4:d8255a5aad46 408 * @sa wlan_smart_config_set_prefix , wlan_smart_config_stop
frankvnk 4:d8255a5aad46 409 */
frankvnk 0:c44f0314d6ec 410 extern long wlan_smart_config_start(unsigned long algoEncryptedFlag);
frankvnk 0:c44f0314d6ec 411
frankvnk 4:d8255a5aad46 412 /**
frankvnk 4:d8255a5aad46 413 * Stop the acquire profile procedure
frankvnk 4:d8255a5aad46 414 * @param algoEncryptedFlag indicates whether the information is encrypted
frankvnk 4:d8255a5aad46 415 * @return On success, zero is returned. On error, -1 is returned
frankvnk 4:d8255a5aad46 416 * @sa wlan_smart_config_start , wlan_smart_config_set_prefix
frankvnk 4:d8255a5aad46 417 */
frankvnk 0:c44f0314d6ec 418 extern long wlan_smart_config_stop(void);
frankvnk 0:c44f0314d6ec 419
frankvnk 4:d8255a5aad46 420 /**
frankvnk 4:d8255a5aad46 421 * Configure station ssid prefix. The prefix is used internally in CC3000. It should always be TTT.
frankvnk 4:d8255a5aad46 422 * @param newPrefix 3 bytes identify the SSID prefix for the Smart Config.
frankvnk 4:d8255a5aad46 423 * @return On success, zero is returned. On error, -1 is returned
frankvnk 4:d8255a5aad46 424 * @Note The prefix is stored in CC3000 NVMEM
frankvnk 4:d8255a5aad46 425 * @sa wlan_smart_config_start , wlan_smart_config_stop
frankvnk 4:d8255a5aad46 426 */
frankvnk 0:c44f0314d6ec 427 extern long wlan_smart_config_set_prefix(char* cNewPrefix);
frankvnk 0:c44f0314d6ec 428
frankvnk 4:d8255a5aad46 429 /**
frankvnk 4:d8255a5aad46 430 * Process the acquired data and store it as a profile.
frankvnk 4:d8255a5aad46 431 * The acquired AP information is stored in CC3000 EEPROM encrypted.
frankvnk 4:d8255a5aad46 432 * The encrypted data is decrypted and stored as a profile.
frankvnk 4:d8255a5aad46 433 * behavior is as defined by connection policy.
frankvnk 4:d8255a5aad46 434 * @param none
frankvnk 4:d8255a5aad46 435 * @return On success, zero is returned. On error, -1 is returned
frankvnk 4:d8255a5aad46 436 */
frankvnk 0:c44f0314d6ec 437 extern long wlan_smart_config_process(void);
frankvnk 0:c44f0314d6ec 438
frankvnk 0:c44f0314d6ec 439
frankvnk 0:c44f0314d6ec 440 #ifdef __cplusplus
frankvnk 0:c44f0314d6ec 441 }
frankvnk 0:c44f0314d6ec 442 #endif // __cplusplus
frankvnk 0:c44f0314d6ec 443
frankvnk 0:c44f0314d6ec 444 #endif // __WLAN_H__