Simple LED control project using CC3100 as Access Point and socket

Dependencies:   mbed

Fork of cc3100_Test_Demo by David Fletcher

Committer:
ArcN00b
Date:
Wed May 31 17:03:57 2017 +0000
Revision:
13:0b58d32f9290
Parent:
10:d24deb1afd1b
Pulizia codice

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 6:778b081f6a13 1 /*
dflet 6:778b081f6a13 2 * wlan.h - CC31xx/CC32xx Host Driver Implementation
dflet 6:778b081f6a13 3 *
dflet 6:778b081f6a13 4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 6:778b081f6a13 5 *
dflet 6:778b081f6a13 6 *
dflet 6:778b081f6a13 7 * Redistribution and use in source and binary forms, with or without
dflet 6:778b081f6a13 8 * modification, are permitted provided that the following conditions
dflet 6:778b081f6a13 9 * are met:
dflet 6:778b081f6a13 10 *
dflet 6:778b081f6a13 11 * Redistributions of source code must retain the above copyright
dflet 6:778b081f6a13 12 * notice, this list of conditions and the following disclaimer.
dflet 6:778b081f6a13 13 *
dflet 6:778b081f6a13 14 * Redistributions in binary form must reproduce the above copyright
dflet 6:778b081f6a13 15 * notice, this list of conditions and the following disclaimer in the
dflet 6:778b081f6a13 16 * documentation and/or other materials provided with the
dflet 6:778b081f6a13 17 * distribution.
dflet 6:778b081f6a13 18 *
dflet 6:778b081f6a13 19 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 6:778b081f6a13 20 * its contributors may be used to endorse or promote products derived
dflet 6:778b081f6a13 21 * from this software without specific prior written permission.
dflet 6:778b081f6a13 22 *
dflet 6:778b081f6a13 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 6:778b081f6a13 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 6:778b081f6a13 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 6:778b081f6a13 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 6:778b081f6a13 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 6:778b081f6a13 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 6:778b081f6a13 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 6:778b081f6a13 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 6:778b081f6a13 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 6:778b081f6a13 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 6:778b081f6a13 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 6:778b081f6a13 34 *
dflet 6:778b081f6a13 35 */
dflet 6:778b081f6a13 36
dflet 6:778b081f6a13 37 /*****************************************************************************/
dflet 6:778b081f6a13 38 /* Include files */
dflet 6:778b081f6a13 39 /*****************************************************************************/
dflet 6:778b081f6a13 40 #include "cc3100_simplelink.h"
dflet 6:778b081f6a13 41
dflet 6:778b081f6a13 42 #ifndef WLAN_H_
dflet 6:778b081f6a13 43 #define WLAN_H_
dflet 6:778b081f6a13 44
dflet 6:778b081f6a13 45 namespace mbed_cc3100 {
dflet 6:778b081f6a13 46
dflet 6:778b081f6a13 47 /*****************************************************************************/
dflet 6:778b081f6a13 48 /* Macro declarations */
dflet 6:778b081f6a13 49 /*****************************************************************************/
dflet 6:778b081f6a13 50
dflet 6:778b081f6a13 51 /*!
dflet 6:778b081f6a13 52
dflet 6:778b081f6a13 53 \addtogroup wlan
dflet 6:778b081f6a13 54 @{
dflet 6:778b081f6a13 55
dflet 6:778b081f6a13 56 */
dflet 6:778b081f6a13 57
dflet 6:778b081f6a13 58 const uint8_t SL_BSSID_LENGTH = (6);
dflet 6:778b081f6a13 59 const uint8_t MAXIMAL_SSID_LENGTH = (32);
dflet 6:778b081f6a13 60
dflet 6:778b081f6a13 61 const uint8_t NUM_OF_RATE_INDEXES = (20);
dflet 6:778b081f6a13 62 const uint8_t SIZE_OF_RSSI_HISTOGRAM = (6);
dflet 6:778b081f6a13 63
dflet 6:778b081f6a13 64 /* WLAN Disconnect Reason Codes */
dflet 6:778b081f6a13 65 const uint8_t SL_DISCONNECT_RESERVED_0 = (0);
dflet 6:778b081f6a13 66 const uint8_t SL_DISCONNECT_UNSPECIFIED_REASON = (1);
dflet 6:778b081f6a13 67 const uint8_t SL_PREVIOUS_AUTHENTICATION_NO_LONGER_VALID = (2);
dflet 6:778b081f6a13 68 const uint8_t SL_DEAUTHENTICATED_BECAUSE_SENDING_STATION_IS_LEAVING = (3);
dflet 6:778b081f6a13 69 const uint8_t SL_DISASSOCIATED_DUE_TO_INACTIVITY = (4);
dflet 6:778b081f6a13 70 const uint8_t SL_DISASSOCIATED_BECAUSE_AP_IS_UNABLE_TO_HANDLE_ALL_CURRENTLY_ASSOCIATED_STATIONS = (5);
dflet 6:778b081f6a13 71 const uint8_t SL_CLASS_2_FRAME_RECEIVED_FROM_NONAUTHENTICATED_STATION = (6);
dflet 6:778b081f6a13 72 const uint8_t SL_CLASS_3_FRAME_RECEIVED_FROM_NONASSOCIATED_STATION = (7);
dflet 6:778b081f6a13 73 const uint8_t SL_DISASSOCIATED_BECAUSE_SENDING_STATION_IS_LEAVING_BSS = (8);
dflet 6:778b081f6a13 74 const uint8_t SL_STATION_REQUESTING_ASSOCIATION_IS_NOT_AUTHENTICATED_WITH_RESPONDING_STATION = (9);
dflet 6:778b081f6a13 75 const uint8_t SL_DISASSOCIATED_BECAUSE_THE_INFORMATION_IN_THE_POWER_CAPABILITY_ELEMENT_IS_UNACCEPTABLE = (10);
dflet 6:778b081f6a13 76 const uint8_t SL_DISASSOCIATED_BECAUSE_THE_INFORMATION_IN_THE_SUPPORTED_CHANNELS_ELEMENT_IS_UNACCEPTABLE = (11);
dflet 6:778b081f6a13 77 const uint8_t SL_DISCONNECT_RESERVED_1 = (12);
dflet 6:778b081f6a13 78 const uint8_t SL_INVALID_INFORMATION_ELEMENT = (13);
dflet 6:778b081f6a13 79 const uint8_t SL_MESSAGE_INTEGRITY_CODE_MIC_FAILURE = (14);
dflet 6:778b081f6a13 80 const uint8_t SL_FOUR_WAY_HANDSHAKE_TIMEOUT = (15);
dflet 6:778b081f6a13 81 const uint8_t SL_GROUP_KEY_HANDSHAKE_TIMEOUT = (16);
dflet 6:778b081f6a13 82 const uint8_t SL_RE_ASSOCIATION_REQUEST_PROBE_RESPONSE_BEACON_FRAME = (17);
dflet 6:778b081f6a13 83 const uint8_t SL_INVALID_GROUP_CIPHER = (18);
dflet 6:778b081f6a13 84 const uint8_t SL_INVALID_PAIRWISE_CIPHER = (19);
dflet 6:778b081f6a13 85 const uint8_t SL_INVALID_AKMP = (20);
dflet 6:778b081f6a13 86 const uint8_t SL_UNSUPPORTED_RSN_INFORMATION_ELEMENT_VERSION = (21);
dflet 6:778b081f6a13 87 const uint8_t SL_INVALID_RSN_INFORMATION_ELEMENT_CAPABILITIES = (22);
dflet 6:778b081f6a13 88 const uint8_t SL_IEEE_802_1X_AUTHENTICATION_FAILED = (23);
dflet 6:778b081f6a13 89 const uint8_t SL_CIPHER_SUITE_REJECTED_BECAUSE_OF_THE_SECURITY_POLICY = (24);
dflet 6:778b081f6a13 90 const uint8_t SL_DISCONNECT_RESERVED_2 = (25);
dflet 6:778b081f6a13 91 const uint8_t SL_DISCONNECT_RESERVED_3 = (26);
dflet 6:778b081f6a13 92 const uint8_t SL_DISCONNECT_RESERVED_4 = (27);
dflet 6:778b081f6a13 93 const uint8_t SL_DISCONNECT_RESERVED_5 = (28);
dflet 6:778b081f6a13 94 const uint8_t SL_DISCONNECT_RESERVED_6 = (29);
dflet 6:778b081f6a13 95 const uint8_t SL_DISCONNECT_RESERVED_7 = (30);
dflet 6:778b081f6a13 96 const uint8_t SL_DISCONNECT_RESERVED_8 = (31);
dflet 6:778b081f6a13 97 const uint8_t SL_USER_INITIATED_DISCONNECTION = (200);
dflet 6:778b081f6a13 98
dflet 6:778b081f6a13 99 /* Wlan error codes */
dflet 6:778b081f6a13 100 const int8_t SL_ERROR_KEY_ERROR = (-3);
dflet 6:778b081f6a13 101 const int8_t SL_ERROR_INVALID_ROLE = (-71);
dflet 6:778b081f6a13 102 const int8_t SL_ERROR_INVALID_SECURITY_TYPE = (-84);
dflet 6:778b081f6a13 103 const int8_t SL_ERROR_PASSPHRASE_TOO_LONG = (-85);
dflet 6:778b081f6a13 104 const int8_t SL_ERROR_WPS_NO_PIN_OR_WRONG_PIN_LEN = (-87);
dflet 6:778b081f6a13 105 const int8_t SL_ERROR_EAP_WRONG_METHOD = (-88);
dflet 6:778b081f6a13 106 const int8_t SL_ERROR_PASSWORD_ERROR = (-89);
dflet 6:778b081f6a13 107 const int8_t SL_ERROR_EAP_ANONYMOUS_LEN_ERROR = (-90);
dflet 6:778b081f6a13 108 const int8_t SL_ERROR_SSID_LEN_ERROR = (-91);
dflet 6:778b081f6a13 109 const int8_t SL_ERROR_USER_ID_LEN_ERROR = (-92);
dflet 6:778b081f6a13 110 const int8_t SL_ERROR_ILLEGAL_WEP_KEY_INDEX = (-95);
dflet 6:778b081f6a13 111 const int8_t SL_ERROR_INVALID_DWELL_TIME_VALUES = (-96);
dflet 6:778b081f6a13 112 const int8_t SL_ERROR_INVALID_POLICY_TYPE = (-97);
dflet 6:778b081f6a13 113 const int8_t SL_ERROR_PM_POLICY_INVALID_OPTION = (-98);
dflet 6:778b081f6a13 114 const int8_t SL_ERROR_PM_POLICY_INVALID_PARAMS = (-99);
dflet 6:778b081f6a13 115 const int16_t SL_ERROR_WIFI_ALREADY_DISCONNECTED = (-129);
dflet 6:778b081f6a13 116 const int8_t SL_ERROR_WIFI_NOT_CONNECTED = (-59);
dflet 6:778b081f6a13 117
dflet 6:778b081f6a13 118
dflet 6:778b081f6a13 119
dflet 6:778b081f6a13 120 const uint8_t SL_SEC_TYPE_OPEN = (0);
dflet 6:778b081f6a13 121 const uint8_t SL_SEC_TYPE_WEP = (1);
dflet 6:778b081f6a13 122 const uint8_t SL_SEC_TYPE_WPA = (2); /* deprecated */
dflet 6:778b081f6a13 123 const uint8_t SL_SEC_TYPE_WPA_WPA2 = (2);
dflet 6:778b081f6a13 124 const uint8_t SL_SEC_TYPE_WPS_PBC = (3);
dflet 6:778b081f6a13 125 const uint8_t SL_SEC_TYPE_WPS_PIN = (4);
dflet 6:778b081f6a13 126 const uint8_t SL_SEC_TYPE_WPA_ENT = (5);
dflet 6:778b081f6a13 127 const uint8_t SL_SEC_TYPE_P2P_PBC = (6);
dflet 6:778b081f6a13 128 const uint8_t SL_SEC_TYPE_P2P_PIN_KEYPAD = (7);
dflet 6:778b081f6a13 129 const uint8_t SL_SEC_TYPE_P2P_PIN_DISPLAY = (8);
dflet 6:778b081f6a13 130 const uint8_t SL_SEC_TYPE_P2P_PIN_AUTO = (9); /* NOT Supported yet */
dflet 6:778b081f6a13 131
dflet 6:778b081f6a13 132
dflet 6:778b081f6a13 133
dflet 6:778b081f6a13 134 const uint8_t SL_SCAN_SEC_TYPE_OPEN = (0);
dflet 6:778b081f6a13 135 const uint8_t SL_SCAN_SEC_TYPE_WEP = (1);
dflet 6:778b081f6a13 136 const uint8_t SL_SCAN_SEC_TYPE_WPA = (2);
dflet 6:778b081f6a13 137 const uint8_t SL_SCAN_SEC_TYPE_WPA2 = (3);
dflet 6:778b081f6a13 138
dflet 6:778b081f6a13 139
dflet 6:778b081f6a13 140
dflet 6:778b081f6a13 141 const uint8_t TLS = (0x1);
dflet 6:778b081f6a13 142 const uint8_t MSCHAP = (0x0);
dflet 6:778b081f6a13 143 const uint8_t PSK = (0x2);
dflet 6:778b081f6a13 144 const uint8_t TTLS = (0x10);
dflet 6:778b081f6a13 145 const uint8_t PEAP0 = (0x20);
dflet 6:778b081f6a13 146 const uint8_t PEAP1 = (0x40);
dflet 6:778b081f6a13 147 const uint8_t FAST = (0x80);
dflet 6:778b081f6a13 148
dflet 6:778b081f6a13 149 const uint8_t FAST_AUTH_PROVISIONING = (0x02);
dflet 6:778b081f6a13 150 const uint8_t FAST_UNAUTH_PROVISIONING = (0x01);
dflet 6:778b081f6a13 151 const uint8_t FAST_NO_PROVISIONING = (0x00);
dflet 6:778b081f6a13 152
dflet 6:778b081f6a13 153 const uint8_t EAPMETHOD_PHASE2_SHIFT = (8);
dflet 6:778b081f6a13 154 const uint8_t EAPMETHOD_PAIRWISE_CIPHER_SHIFT = (19);
dflet 6:778b081f6a13 155 const uint8_t EAPMETHOD_GROUP_CIPHER_SHIFT = (27);
dflet 6:778b081f6a13 156
dflet 6:778b081f6a13 157 const uint8_t WPA_CIPHER_CCMP = (0x1);
dflet 6:778b081f6a13 158 const uint8_t WPA_CIPHER_TKIP = (0x2);
dflet 6:778b081f6a13 159 const uint8_t CC31XX_DEFAULT_CIPHER = (WPA_CIPHER_CCMP | WPA_CIPHER_TKIP);
dflet 6:778b081f6a13 160
dflet 6:778b081f6a13 161 #define EAPMETHOD(phase1,phase2,pairwise_cipher,group_cipher) \
dflet 6:778b081f6a13 162 ((phase1) | \
dflet 6:778b081f6a13 163 ((phase2) << EAPMETHOD_PHASE2_SHIFT ) |\
dflet 6:778b081f6a13 164 ((uint32_t)(pairwise_cipher) << EAPMETHOD_PAIRWISE_CIPHER_SHIFT ) |\
dflet 6:778b081f6a13 165 ((uint32_t)(group_cipher) << EAPMETHOD_GROUP_CIPHER_SHIFT ))
dflet 6:778b081f6a13 166
dflet 6:778b081f6a13 167 /* phase1 phase2 pairwise_cipher group_cipher */
dflet 6:778b081f6a13 168 #define SL_ENT_EAP_METHOD_TLS EAPMETHOD(TLS , 0 , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
dflet 6:778b081f6a13 169 #define SL_ENT_EAP_METHOD_TTLS_TLS EAPMETHOD(TTLS , TLS , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
dflet 6:778b081f6a13 170 #define SL_ENT_EAP_METHOD_TTLS_MSCHAPv2 EAPMETHOD(TTLS , MSCHAP , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
dflet 6:778b081f6a13 171 #define SL_ENT_EAP_METHOD_TTLS_PSK EAPMETHOD(TTLS , PSK , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
ArcN00b 10:d24deb1afd1b 172 #define SL_ENT_EAP_METHOD_TTLS_PEAP0 EAPMETHOD(TTLS , PEAP0 , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
dflet 6:778b081f6a13 173 #define SL_ENT_EAP_METHOD_PEAP0_TLS EAPMETHOD(PEAP0 , TLS , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
dflet 6:778b081f6a13 174 #define SL_ENT_EAP_METHOD_PEAP0_MSCHAPv2 EAPMETHOD(PEAP0 , MSCHAP , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
dflet 6:778b081f6a13 175 #define SL_ENT_EAP_METHOD_PEAP0_PSK EAPMETHOD(PEAP0 , PSK , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
dflet 6:778b081f6a13 176 #define SL_ENT_EAP_METHOD_PEAP1_TLS EAPMETHOD(PEAP1 , TLS , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
dflet 6:778b081f6a13 177 #define SL_ENT_EAP_METHOD_PEAP1_MSCHAPv2 EAPMETHOD(PEAP1 , MSCHAP , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
dflet 6:778b081f6a13 178 #define SL_ENT_EAP_METHOD_PEAP1_PSK EAPMETHOD(PEAP1 , PSK , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
dflet 6:778b081f6a13 179 #define SL_ENT_EAP_METHOD_FAST_AUTH_PROVISIONING EAPMETHOD(FAST , FAST_AUTH_PROVISIONING , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
dflet 6:778b081f6a13 180 #define SL_ENT_EAP_METHOD_FAST_UNAUTH_PROVISIONING EAPMETHOD(FAST , FAST_UNAUTH_PROVISIONING , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
dflet 6:778b081f6a13 181 #define SL_ENT_EAP_METHOD_FAST_NO_PROVISIONING EAPMETHOD(FAST , FAST_NO_PROVISIONING , CC31XX_DEFAULT_CIPHER , CC31XX_DEFAULT_CIPHER)
dflet 6:778b081f6a13 182
dflet 6:778b081f6a13 183 const uint8_t SL_LONG_PREAMBLE = (0);
dflet 6:778b081f6a13 184 const uint8_t SL_SHORT_PREAMBLE = (1);
dflet 6:778b081f6a13 185
dflet 6:778b081f6a13 186 const uint8_t SL_RAW_RF_TX_PARAMS_CHANNEL_SHIFT = (0);
dflet 6:778b081f6a13 187 const uint8_t SL_RAW_RF_TX_PARAMS_RATE_SHIFT = (6);
dflet 6:778b081f6a13 188 const uint8_t SL_RAW_RF_TX_PARAMS_POWER_SHIFT = (11);
dflet 6:778b081f6a13 189 const uint8_t SL_RAW_RF_TX_PARAMS_PREAMBLE_SHIFT = (15);
dflet 6:778b081f6a13 190
dflet 6:778b081f6a13 191 #define SL_RAW_RF_TX_PARAMS(chan,rate,power,preamble) \
dflet 6:778b081f6a13 192 ((chan << SL_RAW_RF_TX_PARAMS_CHANNEL_SHIFT) | \
dflet 6:778b081f6a13 193 (rate << SL_RAW_RF_TX_PARAMS_RATE_SHIFT) | \
dflet 6:778b081f6a13 194 (power << SL_RAW_RF_TX_PARAMS_POWER_SHIFT) | \
dflet 6:778b081f6a13 195 (preamble << SL_RAW_RF_TX_PARAMS_PREAMBLE_SHIFT))
dflet 6:778b081f6a13 196
dflet 6:778b081f6a13 197
dflet 6:778b081f6a13 198 /* wlan config application IDs */
dflet 6:778b081f6a13 199 const uint8_t SL_WLAN_CFG_AP_ID = (0);
dflet 6:778b081f6a13 200 const uint8_t SL_WLAN_CFG_GENERAL_PARAM_ID = (1);
dflet 6:778b081f6a13 201 const uint8_t SL_WLAN_CFG_P2P_PARAM_ID = (2);
dflet 6:778b081f6a13 202
dflet 6:778b081f6a13 203 /* wlan AP Config set/get options */
dflet 6:778b081f6a13 204 const uint8_t WLAN_AP_OPT_SSID = (0);
dflet 6:778b081f6a13 205 const uint8_t WLAN_AP_OPT_CHANNEL = (3);
dflet 6:778b081f6a13 206 const uint8_t WLAN_AP_OPT_HIDDEN_SSID = (4);
dflet 6:778b081f6a13 207 const uint8_t WLAN_AP_OPT_SECURITY_TYPE = (6);
dflet 6:778b081f6a13 208 const uint8_t WLAN_AP_OPT_PASSWORD = (7);
dflet 6:778b081f6a13 209 const uint8_t WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE = (9);
dflet 6:778b081f6a13 210 const uint8_t WLAN_GENERAL_PARAM_OPT_STA_TX_POWER = (10);
dflet 6:778b081f6a13 211 const uint8_t WLAN_GENERAL_PARAM_OPT_AP_TX_POWER = (11);
dflet 6:778b081f6a13 212
dflet 6:778b081f6a13 213 const uint8_t WLAN_P2P_OPT_DEV_NAME = (12);
dflet 6:778b081f6a13 214 const uint8_t WLAN_P2P_OPT_DEV_TYPE = (13);
dflet 6:778b081f6a13 215 const uint8_t WLAN_P2P_OPT_CHANNEL_N_REGS = (14);
dflet 6:778b081f6a13 216 const uint8_t WLAN_GENERAL_PARAM_OPT_INFO_ELEMENT = (16);
dflet 6:778b081f6a13 217 const uint8_t WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS = (18); /* change the scan channels and RSSI threshold using this configuration option */
dflet 6:778b081f6a13 218
dflet 6:778b081f6a13 219 /* SmartConfig CIPHER options */
dflet 6:778b081f6a13 220 const uint8_t SMART_CONFIG_CIPHER_SFLASH = (0); /* password is not delivered by the application. The Simple Manager should */
dflet 6:778b081f6a13 221 /* check if the keys are stored in the Flash. */
dflet 6:778b081f6a13 222 const uint8_t SMART_CONFIG_CIPHER_AES = (1); /* AES (other types are not supported) */
dflet 6:778b081f6a13 223 const uint8_t SMART_CONFIG_CIPHER_NONE = (0xFF); /* do not check in the flash */
dflet 6:778b081f6a13 224
dflet 6:778b081f6a13 225
dflet 6:778b081f6a13 226 const uint8_t SL_POLICY_CONNECTION = (0x10);
dflet 6:778b081f6a13 227 const uint8_t SL_POLICY_SCAN = (0x20);
dflet 6:778b081f6a13 228 const uint8_t SL_POLICY_PM = (0x30);
dflet 6:778b081f6a13 229 const uint8_t SL_POLICY_P2P = (0x40);
dflet 6:778b081f6a13 230
dflet 6:778b081f6a13 231 #define VAL_2_MASK(position,value) ((1 & (value))<<(position))
dflet 6:778b081f6a13 232 #define MASK_2_VAL(position,mask) (((1 << position) & (mask)) >> (position))
dflet 6:778b081f6a13 233
dflet 6:778b081f6a13 234 #define SL_CONNECTION_POLICY(Auto,Fast,Open,anyP2P,autoSmartConfig) (VAL_2_MASK(0,Auto) | VAL_2_MASK(1,Fast) | VAL_2_MASK(2,Open) | VAL_2_MASK(3,anyP2P) | VAL_2_MASK(4,autoSmartConfig))
dflet 6:778b081f6a13 235 #define SL_SCAN_POLICY_EN(policy) (MASK_2_VAL(0,policy))
dflet 6:778b081f6a13 236 #define SL_SCAN_POLICY(Enable) (VAL_2_MASK(0,Enable))
dflet 6:778b081f6a13 237
dflet 6:778b081f6a13 238
dflet 6:778b081f6a13 239 const uint8_t SL_NORMAL_POLICY = (0);
dflet 6:778b081f6a13 240 const uint8_t SL_LOW_LATENCY_POLICY = (1);
dflet 6:778b081f6a13 241 const uint8_t SL_LOW_POWER_POLICY = (2);
dflet 6:778b081f6a13 242 const uint8_t SL_ALWAYS_ON_POLICY = (3);
dflet 6:778b081f6a13 243 const uint8_t SL_LONG_SLEEP_INTERVAL_POLICY = (4);
dflet 6:778b081f6a13 244
dflet 6:778b081f6a13 245 const uint8_t SL_P2P_ROLE_NEGOTIATE = (3);
dflet 6:778b081f6a13 246 const uint8_t SL_P2P_ROLE_GROUP_OWNER = (15);
dflet 6:778b081f6a13 247 const uint8_t SL_P2P_ROLE_CLIENT = (0);
dflet 6:778b081f6a13 248
dflet 6:778b081f6a13 249 const uint8_t SL_P2P_NEG_INITIATOR_ACTIVE = (0);
dflet 6:778b081f6a13 250 const uint8_t SL_P2P_NEG_INITIATOR_PASSIVE = (1);
dflet 6:778b081f6a13 251 const uint8_t SL_P2P_NEG_INITIATOR_RAND_BACKOFF = (2);
dflet 6:778b081f6a13 252
dflet 6:778b081f6a13 253 #define POLICY_VAL_2_OPTIONS(position,mask,policy) ((mask & policy) << position )
dflet 6:778b081f6a13 254
dflet 6:778b081f6a13 255 #define SL_P2P_POLICY(p2pNegType,p2pNegInitiator) (POLICY_VAL_2_OPTIONS(0,0xF,(p2pNegType > SL_P2P_ROLE_GROUP_OWNER ? SL_P2P_ROLE_GROUP_OWNER : p2pNegType)) | \
dflet 6:778b081f6a13 256 POLICY_VAL_2_OPTIONS(4,0x1,(p2pNegType > SL_P2P_ROLE_GROUP_OWNER ? 1:0)) | \
dflet 6:778b081f6a13 257 POLICY_VAL_2_OPTIONS(5,0x3, p2pNegInitiator))
dflet 6:778b081f6a13 258
dflet 6:778b081f6a13 259
dflet 6:778b081f6a13 260 /* Info elements */
dflet 6:778b081f6a13 261
dflet 6:778b081f6a13 262 const uint8_t INFO_ELEMENT_DEFAULT_ID = (0); /* 221 will be used */
dflet 6:778b081f6a13 263
dflet 6:778b081f6a13 264 /* info element size is up to 252 bytes (+ 3 bytes of OUI). */
dflet 6:778b081f6a13 265 const uint8_t INFO_ELEMENT_MAX_SIZE = (252);
dflet 6:778b081f6a13 266
dflet 6:778b081f6a13 267 /* For AP - the total length of all info elements is 300 bytes (for example - 4 info elements of 75 bytes each) */
dflet 6:778b081f6a13 268 const uint16_t INFO_ELEMENT_MAX_TOTAL_LENGTH_AP = (300);
dflet 6:778b081f6a13 269 /* For P2P - the total length of all info elements is 150 bytes (for example - 4 info elements of 40 bytes each) */
dflet 6:778b081f6a13 270 const uint8_t INFO_ELEMENT_MAX_TOTAL_LENGTH_P2P_GO (160);
dflet 6:778b081f6a13 271
dflet 6:778b081f6a13 272 const uint8_t INFO_ELEMENT_AP_ROLE = (0);
dflet 6:778b081f6a13 273 const uint8_t INFO_ELEMENT_P2P_GO_ROLE = (1);
dflet 6:778b081f6a13 274
dflet 6:778b081f6a13 275 /* we support up to 4 info elements per Role. */
dflet 6:778b081f6a13 276 const uint8_t MAX_PRIVATE_INFO_ELEMENTS_SUPPROTED = (4);
dflet 6:778b081f6a13 277
dflet 6:778b081f6a13 278 const uint8_t INFO_ELEMENT_DEFAULT_OUI_0 = (0x08);
dflet 6:778b081f6a13 279 const uint8_t INFO_ELEMENT_DEFAULT_OUI_1 = (0x00);
dflet 6:778b081f6a13 280 const uint8_t INFO_ELEMENT_DEFAULT_OUI_2 = (0x28);
dflet 6:778b081f6a13 281
dflet 6:778b081f6a13 282 const uint32_t INFO_ELEMENT_DEFAULT_OUI = (0x000000); /* 08, 00, 28 will be used */
dflet 6:778b081f6a13 283
dflet 6:778b081f6a13 284
dflet 6:778b081f6a13 285 /*****************************************************************************/
dflet 6:778b081f6a13 286 /* Structure/Enum declarations */
dflet 6:778b081f6a13 287 /*****************************************************************************/
dflet 6:778b081f6a13 288
dflet 6:778b081f6a13 289 typedef enum {
dflet 6:778b081f6a13 290 RATE_1M = 1,
dflet 6:778b081f6a13 291 RATE_2M = 2,
dflet 6:778b081f6a13 292 RATE_5_5M = 3,
dflet 6:778b081f6a13 293 RATE_11M = 4,
dflet 6:778b081f6a13 294 RATE_6M = 6,
dflet 6:778b081f6a13 295 RATE_9M = 7,
dflet 6:778b081f6a13 296 RATE_12M = 8,
dflet 6:778b081f6a13 297 RATE_18M = 9,
dflet 6:778b081f6a13 298 RATE_24M = 10,
dflet 6:778b081f6a13 299 RATE_36M = 11,
dflet 6:778b081f6a13 300 RATE_48M = 12,
dflet 6:778b081f6a13 301 RATE_54M = 13,
dflet 6:778b081f6a13 302 RATE_MCS_0 = 14,
dflet 6:778b081f6a13 303 RATE_MCS_1 = 15,
dflet 6:778b081f6a13 304 RATE_MCS_2 = 16,
dflet 6:778b081f6a13 305 RATE_MCS_3 = 17,
dflet 6:778b081f6a13 306 RATE_MCS_4 = 18,
dflet 6:778b081f6a13 307 RATE_MCS_5 = 19,
dflet 6:778b081f6a13 308 RATE_MCS_6 = 20,
dflet 6:778b081f6a13 309 RATE_MCS_7 = 21,
dflet 6:778b081f6a13 310 MAX_NUM_RATES = 0xFF
dflet 6:778b081f6a13 311 } SlRateIndex_e;
dflet 6:778b081f6a13 312
dflet 6:778b081f6a13 313 typedef enum {
dflet 6:778b081f6a13 314 DEV_PW_DEFAULT=0,
dflet 6:778b081f6a13 315 DEV_PW_PIN_KEYPAD=1,
dflet 6:778b081f6a13 316 DEV_PW_PUSH_BUTTON=4,
dflet 6:778b081f6a13 317 DEV_PW_PIN_DISPLAY=5
dflet 6:778b081f6a13 318 } sl_p2p_dev_password_method;
dflet 6:778b081f6a13 319
dflet 6:778b081f6a13 320
dflet 6:778b081f6a13 321 typedef struct {
dflet 6:778b081f6a13 322 uint32_t status;
dflet 6:778b081f6a13 323 uint32_t ssid_len;
dflet 6:778b081f6a13 324 uint8_t ssid[32];
dflet 6:778b081f6a13 325 uint32_t private_token_len;
dflet 6:778b081f6a13 326 uint8_t private_token[32];
dflet 6:778b081f6a13 327 } slSmartConfigStartAsyncResponse_t;
dflet 6:778b081f6a13 328
dflet 6:778b081f6a13 329 typedef struct {
dflet 6:778b081f6a13 330 uint16_t status;
dflet 6:778b081f6a13 331 uint16_t padding;
dflet 6:778b081f6a13 332 } slSmartConfigStopAsyncResponse_t;
dflet 6:778b081f6a13 333
dflet 6:778b081f6a13 334 typedef struct {
dflet 6:778b081f6a13 335 uint16_t status;
dflet 6:778b081f6a13 336 uint16_t padding;
dflet 6:778b081f6a13 337 } slWlanConnFailureAsyncResponse_t;
dflet 6:778b081f6a13 338
dflet 6:778b081f6a13 339 typedef struct {
dflet 6:778b081f6a13 340 uint8_t connection_type;/* 0-STA,3-P2P_CL */
dflet 6:778b081f6a13 341 uint8_t ssid_len;
dflet 6:778b081f6a13 342 uint8_t ssid_name[32];
dflet 6:778b081f6a13 343 uint8_t go_peer_device_name_len;
dflet 6:778b081f6a13 344 uint8_t go_peer_device_name[32];
dflet 6:778b081f6a13 345 uint8_t bssid[6];
dflet 6:778b081f6a13 346 uint8_t reason_code;
dflet 6:778b081f6a13 347 uint8_t padding[2];
dflet 6:778b081f6a13 348 } slWlanConnectAsyncResponse_t;
dflet 6:778b081f6a13 349
dflet 6:778b081f6a13 350 typedef struct {
dflet 6:778b081f6a13 351 uint8_t go_peer_device_name[32];
dflet 6:778b081f6a13 352 uint8_t mac[6];
dflet 6:778b081f6a13 353 uint8_t go_peer_device_name_len;
dflet 6:778b081f6a13 354 uint8_t wps_dev_password_id;
dflet 6:778b081f6a13 355 uint8_t own_ssid[32];/* relevant for event sta-connected only */
dflet 6:778b081f6a13 356 uint8_t own_ssid_len;/* relevant for event sta-connected only */
dflet 6:778b081f6a13 357 uint8_t padding[3];
dflet 6:778b081f6a13 358 } slPeerInfoAsyncResponse_t;
dflet 6:778b081f6a13 359
dflet 6:778b081f6a13 360
dflet 6:778b081f6a13 361 typedef union {
dflet 6:778b081f6a13 362 slSmartConfigStartAsyncResponse_t smartConfigStartResponse; /*SL_WLAN_SMART_CONFIG_COMPLETE_EVENT*/
dflet 6:778b081f6a13 363 slSmartConfigStopAsyncResponse_t smartConfigStopResponse; /*SL_WLAN_SMART_CONFIG_STOP_EVENT */
dflet 6:778b081f6a13 364 slPeerInfoAsyncResponse_t APModeStaConnected; /* SL_WLAN_STA_CONNECTED_EVENT - relevant only in AP mode - holds information regarding a new STA connection */
dflet 6:778b081f6a13 365 slPeerInfoAsyncResponse_t APModestaDisconnected; /* SL_WLAN_STA_DISCONNECTED_EVENT - relevant only in AP mode - holds information regarding a STA disconnection */
dflet 6:778b081f6a13 366 slWlanConnectAsyncResponse_t STAandP2PModeWlanConnected; /* SL_WLAN_CONNECT_EVENT - relevant only in STA and P2P mode - holds information regarding a new connection */
dflet 6:778b081f6a13 367 slWlanConnectAsyncResponse_t STAandP2PModeDisconnected; /* SL_WLAN_DISCONNECT_EVENT - relevant only in STA and P2P mode - holds information regarding a disconnection */
dflet 6:778b081f6a13 368 slPeerInfoAsyncResponse_t P2PModeDevFound; /* SL_WLAN_P2P_DEV_FOUND_EVENT - relevant only in P2P mode */
dflet 6:778b081f6a13 369 slPeerInfoAsyncResponse_t P2PModeNegReqReceived; /* SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT - relevant only in P2P mode */
dflet 6:778b081f6a13 370 slWlanConnFailureAsyncResponse_t P2PModewlanConnectionFailure; /* SL_WLAN_CONNECTION_FAILED_EVENT - relevant only in P2P mode */
dflet 6:778b081f6a13 371
dflet 6:778b081f6a13 372 } SlWlanEventData_u;
dflet 6:778b081f6a13 373
dflet 6:778b081f6a13 374 typedef struct {
dflet 6:778b081f6a13 375 uint32_t Event;
dflet 6:778b081f6a13 376 SlWlanEventData_u EventData;
dflet 6:778b081f6a13 377 } SlWlanEvent_t;
dflet 6:778b081f6a13 378
dflet 6:778b081f6a13 379
dflet 6:778b081f6a13 380 typedef struct {
dflet 6:778b081f6a13 381 uint32_t ReceivedValidPacketsNumber; /* sum of the packets that been received OK (include filtered) */
dflet 6:778b081f6a13 382 uint32_t ReceivedFcsErrorPacketsNumber; /* sum of the packets that been dropped due to FCS error */
dflet 6:778b081f6a13 383 uint32_t ReceivedAddressMismatchPacketsNumber; /* sum of the packets that been received but filtered out by one of the HW filters */
dflet 6:778b081f6a13 384 int16_t AvarageDataCtrlRssi; /* average RSSI for all valid data packets received */
dflet 6:778b081f6a13 385 int16_t AvarageMgMntRssi; /* average RSSI for all valid management packets received */
dflet 6:778b081f6a13 386 uint16_t RateHistogram[NUM_OF_RATE_INDEXES]; /* rate histogram for all valid packets received */
dflet 6:778b081f6a13 387 uint16_t RssiHistogram[SIZE_OF_RSSI_HISTOGRAM]; /* RSSI histogram from -40 until -87 (all below and above\n RSSI will appear in the first and last cells */
dflet 6:778b081f6a13 388 uint32_t StartTimeStamp; /* the time stamp started collecting the statistics in uSec */
dflet 6:778b081f6a13 389 uint32_t GetTimeStamp; /* the time stamp called the get statistics command */
dflet 6:778b081f6a13 390 } SlGetRxStatResponse_t;
dflet 6:778b081f6a13 391
dflet 6:778b081f6a13 392
dflet 6:778b081f6a13 393 typedef struct {
dflet 6:778b081f6a13 394 uint8_t ssid[MAXIMAL_SSID_LENGTH];
dflet 6:778b081f6a13 395 uint8_t ssid_len;
dflet 6:778b081f6a13 396 uint8_t sec_type;
dflet 6:778b081f6a13 397 uint8_t bssid[SL_BSSID_LENGTH];
dflet 6:778b081f6a13 398 int8_t rssi;
dflet 6:778b081f6a13 399 int8_t reserved[3];
dflet 6:778b081f6a13 400 } Sl_WlanNetworkEntry_t;
dflet 6:778b081f6a13 401
dflet 6:778b081f6a13 402
dflet 6:778b081f6a13 403 typedef struct {
dflet 6:778b081f6a13 404 uint8_t Type;
dflet 6:778b081f6a13 405 int8_t* Key;
dflet 6:778b081f6a13 406 uint8_t KeyLen;
dflet 6:778b081f6a13 407 } SlSecParams_t;
dflet 6:778b081f6a13 408
dflet 6:778b081f6a13 409 typedef struct {
dflet 6:778b081f6a13 410 int8_t* User;
dflet 6:778b081f6a13 411 uint8_t UserLen;
dflet 6:778b081f6a13 412 int8_t* AnonUser;
dflet 6:778b081f6a13 413 uint8_t AnonUserLen;
dflet 6:778b081f6a13 414 uint8_t CertIndex; /* not supported */
dflet 6:778b081f6a13 415 uint32_t EapMethod;
dflet 6:778b081f6a13 416 } SlSecParamsExt_t;
dflet 6:778b081f6a13 417
dflet 6:778b081f6a13 418 typedef struct {
dflet 6:778b081f6a13 419 int8_t User[32];
dflet 6:778b081f6a13 420 uint8_t UserLen;
dflet 6:778b081f6a13 421 int8_t AnonUser[32];
dflet 6:778b081f6a13 422 uint8_t AnonUserLen;
dflet 6:778b081f6a13 423 uint8_t CertIndex; //not supported
dflet 6:778b081f6a13 424 uint32_t EapMethod;
dflet 6:778b081f6a13 425 } SlGetSecParamsExt_t;
dflet 6:778b081f6a13 426
dflet 6:778b081f6a13 427 typedef enum {
dflet 6:778b081f6a13 428 ROLE_STA = 0,
dflet 6:778b081f6a13 429 ROLE_AP = 2,
dflet 6:778b081f6a13 430 ROLE_P2P = 3,
dflet 6:778b081f6a13 431 ROLE_STA_ERR = -1, /* Failure to load MAC/PHY in STA role */
dflet 6:778b081f6a13 432 ROLE_AP_ERR = -ROLE_AP, /* Failure to load MAC/PHY in AP role */
dflet 6:778b081f6a13 433 ROLE_P2P_ERR = -ROLE_P2P /* Failure to load MAC/PHY in P2P role */
dflet 6:778b081f6a13 434 } SlWlanMode_t;
dflet 6:778b081f6a13 435
dflet 6:778b081f6a13 436 typedef struct {
dflet 6:778b081f6a13 437 uint32_t G_Channels_mask;
dflet 6:778b081f6a13 438 int32_t rssiThershold;
dflet 6:778b081f6a13 439 } slWlanScanParamCommand_t;
dflet 6:778b081f6a13 440
dflet 6:778b081f6a13 441
dflet 6:778b081f6a13 442 typedef struct {
dflet 6:778b081f6a13 443 uint8_t id;
dflet 6:778b081f6a13 444 uint8_t oui[3];
dflet 6:778b081f6a13 445 uint16_t length;
dflet 6:778b081f6a13 446 uint8_t data[252];
dflet 6:778b081f6a13 447 } sl_protocol_InfoElement_t;
dflet 6:778b081f6a13 448
dflet 6:778b081f6a13 449 typedef struct {
dflet 6:778b081f6a13 450 uint8_t index; /* 0 - MAX_PRIVATE_INFO_ELEMENTS_SUPPROTED */
dflet 6:778b081f6a13 451 uint8_t role; /* bit0: AP = 0, GO = 1 */
dflet 6:778b081f6a13 452 sl_protocol_InfoElement_t ie;
dflet 6:778b081f6a13 453 } sl_protocol_WlanSetInfoElement_t;
dflet 6:778b081f6a13 454
dflet 6:778b081f6a13 455
dflet 6:778b081f6a13 456 class cc3100_wlan_rx_filters;
dflet 6:778b081f6a13 457 class cc3100_wlan
dflet 6:778b081f6a13 458 {
dflet 6:778b081f6a13 459
dflet 6:778b081f6a13 460 public:
dflet 6:778b081f6a13 461
dflet 6:778b081f6a13 462 cc3100_wlan(cc3100_driver &driver, cc3100_wlan_rx_filters &wlan_rx_filters);
dflet 6:778b081f6a13 463
dflet 6:778b081f6a13 464 ~cc3100_wlan();
dflet 6:778b081f6a13 465
dflet 6:778b081f6a13 466
dflet 6:778b081f6a13 467 /*****************************************************************************/
dflet 6:778b081f6a13 468 /* Function prototypes */
dflet 6:778b081f6a13 469 /*****************************************************************************/
dflet 6:778b081f6a13 470
dflet 6:778b081f6a13 471
dflet 6:778b081f6a13 472 /*!
dflet 6:778b081f6a13 473 \brief Connect to wlan network as a station
dflet 6:778b081f6a13 474
dflet 6:778b081f6a13 475 \param[in] pName up to 32 bytes in case of STA the name is the SSID of the Access Point
dflet 6:778b081f6a13 476 \param[in] NameLen name length
dflet 6:778b081f6a13 477 \param[in] pMacAddr 6 bytes for MAC address
dflet 6:778b081f6a13 478 \param[in] pSecParams Security parameters (use NULL key for SL_SEC_TYPE_OPEN)
dflet 6:778b081f6a13 479 Security types options: \n
dflet 6:778b081f6a13 480 - SL_SEC_TYPE_OPEN
dflet 6:778b081f6a13 481 - SL_SEC_TYPE_WEP
dflet 6:778b081f6a13 482 - SL_SEC_TYPE_WPA_WPA2
dflet 6:778b081f6a13 483 - SL_SEC_TYPE_WPA_ENT
dflet 6:778b081f6a13 484 - SL_SEC_TYPE_WPS_PBC
dflet 6:778b081f6a13 485 - SL_SEC_TYPE_WPS_PIN
dflet 6:778b081f6a13 486 \param[in] pSecExtParams Enterprise parameters (set NULL in case Enterprise parameters is not in use)
dflet 6:778b081f6a13 487
dflet 6:778b081f6a13 488 \return On success, zero is returned. On error, negative is returned
dflet 6:778b081f6a13 489 In case error number (-71) is returned, it indicates a connection was activated while the device it running in AP role
dflet 6:778b081f6a13 490
dflet 6:778b081f6a13 491 \sa sl_WlanDisconnect
dflet 6:778b081f6a13 492 \note belongs to \ref ext_api
dflet 6:778b081f6a13 493 \warning In this version only single enterprise mode could be used
dflet 6:778b081f6a13 494 SL_SEC_TYPE_WPA is a deprecated definition, the new definition is SL_SEC_TYPE_WPA_WPA2
dflet 6:778b081f6a13 495 */
dflet 6:778b081f6a13 496 #if _SL_INCLUDE_FUNC(sl_WlanConnect)
dflet 6:778b081f6a13 497 int16_t sl_WlanConnect(const signed char* pName, const int16_t NameLen, const uint8_t *pMacAddr, const SlSecParams_t* pSecParams, const SlSecParamsExt_t* pSecExtParams);
dflet 6:778b081f6a13 498 #endif
dflet 6:778b081f6a13 499
dflet 6:778b081f6a13 500 /*!
dflet 6:778b081f6a13 501 \brief wlan disconnect
dflet 6:778b081f6a13 502
dflet 6:778b081f6a13 503 Disconnect connection
dflet 6:778b081f6a13 504
dflet 6:778b081f6a13 505 \return 0 disconnected done, other already disconnected
dflet 6:778b081f6a13 506
dflet 6:778b081f6a13 507 \sa sl_WlanConnect
dflet 6:778b081f6a13 508 \note belongs to \ref ext_api
dflet 6:778b081f6a13 509 \warning
dflet 6:778b081f6a13 510 */
dflet 6:778b081f6a13 511 #if _SL_INCLUDE_FUNC(sl_WlanDisconnect)
dflet 6:778b081f6a13 512 int16_t sl_WlanDisconnect(void);
dflet 6:778b081f6a13 513 #endif
dflet 6:778b081f6a13 514
dflet 6:778b081f6a13 515 /*!
dflet 6:778b081f6a13 516 \brief add profile
dflet 6:778b081f6a13 517
dflet 6:778b081f6a13 518 When auto start is enabled, the device connects to a
dflet 6:778b081f6a13 519 station from the profiles table. Up to 7 profiles are
dflet 6:778b081f6a13 520 supported. If several profiles configured the device chose
dflet 6:778b081f6a13 521 the highest priority profile, within each priority group,
dflet 6:778b081f6a13 522 device will chose profile based on security policy, signal
dflet 6:778b081f6a13 523 strength, etc parameters.
dflet 6:778b081f6a13 524
dflet 6:778b081f6a13 525
dflet 6:778b081f6a13 526 \param[in] pName up to 32 bytes in case of STA the name is the
dflet 6:778b081f6a13 527 SSID of the Access Point
dflet 6:778b081f6a13 528 in case of P2P the name is the remote device name
dflet 6:778b081f6a13 529 \param[in] NameLen name length
dflet 6:778b081f6a13 530 \param[in] pMacAddr 6 bytes for MAC address
dflet 6:778b081f6a13 531 \param[in] pSecParams Security parameters - security type
dflet 6:778b081f6a13 532 (SL_SEC_TYPE_OPEN,SL_SEC_TYPE_WEP,SL_SEC_TYPE_WPA_WPA2,
dflet 6:778b081f6a13 533 SL_SEC_TYPE_P2P_PBC,SL_SEC_TYPE_P2P_PIN_KEYPAD,SL_SEC_TYPE_P2P_PIN_DISPLAY, SL_SEC_TYPE_WPA_ENT), key, and key length
dflet 6:778b081f6a13 534 in case of p2p security type pin the key refers to pin code
dflet 6:778b081f6a13 535 \param[in] pSecExtParams Enterprise parameters - identity, identity length,
dflet 6:778b081f6a13 536 Anonymous, Anonymous length, CertIndex (not supported,
dflet 6:778b081f6a13 537 certificates need to be placed in a specific file ID),
dflet 6:778b081f6a13 538 EapMethod.Use NULL in case Enterprise parameters is not in use
dflet 6:778b081f6a13 539
dflet 6:778b081f6a13 540 \param[in] Priority profile priority. Lowest priority: 0
dflet 6:778b081f6a13 541 \param[in] Options Not supported
dflet 6:778b081f6a13 542
dflet 6:778b081f6a13 543 \return On success, profile stored index is returned. On error, negative value is returned
dflet 6:778b081f6a13 544
dflet 6:778b081f6a13 545 \sa sl_WlanProfileGet , sl_WlanProfileDel
dflet 6:778b081f6a13 546 \note belongs to \ref ext_api
dflet 6:778b081f6a13 547 \warning Only one Enterprise profile is supported.
dflet 6:778b081f6a13 548 Please Note that in case of adding an existing profile (compared by pName,pMACAddr and security type)
dflet 6:778b081f6a13 549 the old profile will be deleted and the same index will be returned.
dflet 6:778b081f6a13 550 SL_SEC_TYPE_WPA is a deprecated definition, the new definition is SL_SEC_TYPE_WPA_WPA2
dflet 6:778b081f6a13 551
dflet 6:778b081f6a13 552 */
dflet 6:778b081f6a13 553 #if _SL_INCLUDE_FUNC(sl_WlanProfileAdd)
dflet 6:778b081f6a13 554 int16_t sl_WlanProfileAdd(const int8_t* pName,
dflet 6:778b081f6a13 555 const int16_t NameLen,
dflet 6:778b081f6a13 556 const uint8_t *pMacAddr,
dflet 6:778b081f6a13 557 const SlSecParams_t* pSecParams ,
dflet 6:778b081f6a13 558 const SlSecParamsExt_t* pSecExtParams,
dflet 6:778b081f6a13 559 const uint32_t Priority,
dflet 6:778b081f6a13 560 const uint32_t Options);
dflet 6:778b081f6a13 561 #endif
dflet 6:778b081f6a13 562
dflet 6:778b081f6a13 563 /*!
dflet 6:778b081f6a13 564 \brief get profile
dflet 6:778b081f6a13 565
dflet 6:778b081f6a13 566 read profile from the device
dflet 6:778b081f6a13 567
dflet 6:778b081f6a13 568 \param[in] Index profile stored index, if index does not exists
dflet 6:778b081f6a13 569 error is return
dflet 6:778b081f6a13 570 \param[out] pName up to 32 bytes, in case of sta mode the name of the Access Point
dflet 6:778b081f6a13 571 in case of p2p mode the name of the Remote Device
dflet 6:778b081f6a13 572 \param[out] pNameLen name length
dflet 6:778b081f6a13 573 \param[out] pMacAddr 6 bytes for MAC address
dflet 6:778b081f6a13 574 \param[out] pSecParams security parameters - security type
dflet 6:778b081f6a13 575 (SL_SEC_TYPE_OPEN, SL_SEC_TYPE_WEP, SL_SEC_TYPE_WPA_WPA2 or
dflet 6:778b081f6a13 576 SL_SEC_TYPE_WPS_PBC, SL_SEC_TYPE_WPS_PIN, SL_SEC_TYPE_WPA_ENT,SL_SEC_TYPE_P2P_PBC,SL_SEC_TYPE_P2P_PIN_KEYPAD or SL_SEC_TYPE_P2P_PIN_DISPLAY),
dflet 6:778b081f6a13 577 key and key length are not
dflet 6:778b081f6a13 578 in case of p2p security type pin the key refers to pin code
dflet 6:778b081f6a13 579 return due to security reasons.
dflet 6:778b081f6a13 580 \param[out] pSecExtParams enterprise parameters - identity, identity
dflet 6:778b081f6a13 581 length, Anonymous, Anonymous length
dflet 6:778b081f6a13 582 CertIndex (not supported), EapMethod.
dflet 6:778b081f6a13 583 \param[out] Priority profile priority
dflet 6:778b081f6a13 584
dflet 6:778b081f6a13 585 \return On success, Profile security type is returned (0 or positive number). On error, -1 is
dflet 6:778b081f6a13 586 returned
dflet 6:778b081f6a13 587
dflet 6:778b081f6a13 588 \sa sl_WlanProfileAdd , sl_WlanProfileDel
dflet 6:778b081f6a13 589 \note belongs to \ref ext_api
dflet 6:778b081f6a13 590 \warning
dflet 6:778b081f6a13 591 */
dflet 6:778b081f6a13 592 #if _SL_INCLUDE_FUNC(sl_WlanProfileGet)
dflet 6:778b081f6a13 593 int16_t sl_WlanProfileGet(const int16_t Index,int8_t* pName, int16_t *pNameLen, uint8_t *pMacAddr, SlSecParams_t* pSecParams, SlGetSecParamsExt_t* pSecExtParams, uint32_t *pPriority);
dflet 6:778b081f6a13 594 #endif
dflet 6:778b081f6a13 595
dflet 6:778b081f6a13 596 /*!
dflet 6:778b081f6a13 597 \brief Delete WLAN profile
dflet 6:778b081f6a13 598
dflet 6:778b081f6a13 599 Delete WLAN profile
dflet 6:778b081f6a13 600
dflet 6:778b081f6a13 601 \param[in] index number of profile to delete.Possible values are 0 to 6.
dflet 6:778b081f6a13 602 Index value 255 will delete all saved profiles
dflet 6:778b081f6a13 603
dflet 6:778b081f6a13 604 \return On success, zero is returned. On error, -1 is
dflet 6:778b081f6a13 605 returned
dflet 6:778b081f6a13 606
dflet 6:778b081f6a13 607 \sa sl_WlanProfileAdd , sl_WlanProfileGet
dflet 6:778b081f6a13 608 \note belongs to \ref ext_api
dflet 6:778b081f6a13 609 \warning
dflet 6:778b081f6a13 610 */
dflet 6:778b081f6a13 611 #if _SL_INCLUDE_FUNC(sl_WlanProfileDel)
dflet 6:778b081f6a13 612 int16_t sl_WlanProfileDel(const int16_t Index);
dflet 6:778b081f6a13 613 #endif
dflet 6:778b081f6a13 614
dflet 6:778b081f6a13 615 /*!
dflet 6:778b081f6a13 616 \brief Set policy values
dflet 6:778b081f6a13 617
dflet 6:778b081f6a13 618 \param[in] Type Type of policy to be modified. The Options are:\n
dflet 6:778b081f6a13 619 - SL_POLICY_CONNECTION
dflet 6:778b081f6a13 620 - SL_POLICY_SCAN
dflet 6:778b081f6a13 621 - SL_POLICY_PM
dflet 6:778b081f6a13 622 - SL_POLICY_P2P
dflet 6:778b081f6a13 623 \param[in] Policy The option value which depends on action type
dflet 6:778b081f6a13 624 \param[in] pVal An optional value pointer
dflet 6:778b081f6a13 625 \param[in] ValLen An optional value length, in bytes
dflet 6:778b081f6a13 626 \return On success, zero is returned. On error, -1 is
dflet 6:778b081f6a13 627 returned
dflet 6:778b081f6a13 628 \sa sl_WlanPolicyGet
dflet 6:778b081f6a13 629 \note belongs to \ref ext_api
dflet 6:778b081f6a13 630 \warning
dflet 6:778b081f6a13 631 \par
dflet 6:778b081f6a13 632 SL_POLICY_CONNECTION type defines three options available to connect the CC31xx device to the AP: \n
dflet 6:778b081f6a13 633
dflet 6:778b081f6a13 634 - If Auto Connect is set, the CC31xx device tries to automatically reconnect to one of its stored profiles, each time the connection fails or the device is rebooted.\n
dflet 6:778b081f6a13 635 To set this option, use: \n
dflet 6:778b081f6a13 636 <b> sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(1,0,0,0,0),NULL,0) </b>
dflet 6:778b081f6a13 637 - If Fast Connect is set, the CC31xx device tries to establish a fast connection to AP. \n
dflet 6:778b081f6a13 638 To set this option, use: \n
dflet 6:778b081f6a13 639 <b> sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(0,1,0,0,0),NULL,0) </b>
dflet 6:778b081f6a13 640 - (relevant for P2P mode only) - If Any P2P is set, CC31xx/CC32xx device tries to automatically connect to the first P2P device available, \n
dflet 6:778b081f6a13 641 supporting push button only. To set this option, use: \n
dflet 6:778b081f6a13 642 <b> sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(0,0,0,1,0),NULL,0) </b>
dflet 6:778b081f6a13 643 - For auto smart config upon restart (any command from Host will end this state) use: \n
dflet 6:778b081f6a13 644 <b> sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(0,0,0,0,1),NULL,0) </b> \n
dflet 6:778b081f6a13 645 The options above could be combined to a single action, if more than one action is required. \n
dflet 6:778b081f6a13 646 \par
dflet 6:778b081f6a13 647 SL_POLICY_SCAN defines system scan time interval.Default interval is 10 minutes. \n
dflet 6:778b081f6a13 648 After settings scan interval, an immediate scan is activated. The next scan will be based on the interval settings. \n
dflet 6:778b081f6a13 649 - For example, setting scan interval to 1 minute interval use: \n
dflet 6:778b081f6a13 650 uint32_t intervalInSeconds = 60; \n
dflet 6:778b081f6a13 651 #define SL_SCAN_ENABLE 1 \n<b>
dflet 6:778b081f6a13 652 sl_WlanPolicySet(SL_POLICY_SCAN,SL_SCAN_ENABLE, (uint8_t *)&intervalInSeconds,sizeof(intervalInSeconds)); </b>\n
dflet 6:778b081f6a13 653
dflet 6:778b081f6a13 654 - For example, disable scan: \n
dflet 6:778b081f6a13 655 #define SL_SCAN_DISABLE 0 \n<b>
dflet 6:778b081f6a13 656 sl_WlanPolicySet(SL_POLICY_SCAN,SL_SCAN_DISABLE,0,0); </b>\n
dflet 6:778b081f6a13 657 \par
dflet 6:778b081f6a13 658 SL_POLICY_PM defines a power management policy for Station mode only:
dflet 6:778b081f6a13 659 - For setting normal power management (default) policy use: <b> sl_WlanPolicySet(SL_POLICY_PM , SL_NORMAL_POLICY, NULL,0) </b>
dflet 6:778b081f6a13 660 - For setting low latency power management policy use: <b> sl_WlanPolicySet(SL_POLICY_PM , SL_LOW_LATENCY_POLICY, NULL,0) </b>
dflet 6:778b081f6a13 661 - For setting low power management policy use: <b> sl_WlanPolicySet(SL_POLICY_PM , SL_LOW_POWER_POLICY, NULL,0) </b>
dflet 6:778b081f6a13 662 - For setting always on power management policy use: <b> sl_WlanPolicySet(SL_POLICY_PM , SL_ALWAYS_ON_POLICY, NULL,0) </b>
dflet 6:778b081f6a13 663 - For setting Long Sleep Interval policy use: \n
dflet 6:778b081f6a13 664 uint16_t PolicyBuff[4] = {0,0,800,0}; // PolicyBuff[2] is max sleep time in mSec \n<b>
dflet 6:778b081f6a13 665 sl_WlanPolicySet(SL_POLICY_PM , SL_LONG_SLEEP_INTERVAL_POLICY, (uint8_t*)PolicyBuff,sizeof(PolicyBuff)); </b>\n
dflet 6:778b081f6a13 666
dflet 6:778b081f6a13 667 SL_POLICY_P2P defines p2p negotiation policy parameters for P2P role:
dflet 6:778b081f6a13 668 - To set intent negotiation value, set on of the following:
dflet 6:778b081f6a13 669 SL_P2P_ROLE_NEGOTIATE - intent 3
dflet 6:778b081f6a13 670 SL_P2P_ROLE_GROUP_OWNER - intent 15
dflet 6:778b081f6a13 671 SL_P2P_ROLE_CLIENT - intent 0
dflet 6:778b081f6a13 672 - To set negotiation initiator value (initiator policy of first negotiation action frame), set on of the following:
dflet 6:778b081f6a13 673 SL_P2P_NEG_INITIATOR_ACTIVE
dflet 6:778b081f6a13 674 SL_P2P_NEG_INITIATOR_PASSIVE
dflet 6:778b081f6a13 675 SL_P2P_NEG_INITIATOR_RAND_BACKOFF
dflet 6:778b081f6a13 676 For example: \n
dflet 6:778b081f6a13 677 <b>sl_WlanPolicySet(SL_POLICY_P2P, SL_P2P_POLICY(SL_P2P_ROLE_NEGOTIATE,SL_P2P_NEG_INITIATOR_RAND_BACKOFF),NULL,0) </b>
dflet 6:778b081f6a13 678
dflet 6:778b081f6a13 679 */
dflet 6:778b081f6a13 680 #if _SL_INCLUDE_FUNC(sl_WlanPolicySet)
dflet 6:778b081f6a13 681 int16_t sl_WlanPolicySet(const uint8_t Type , const uint8_t Policy, uint8_t *pVal,const uint8_t ValLen);
dflet 6:778b081f6a13 682 #endif
dflet 6:778b081f6a13 683 /*!
dflet 6:778b081f6a13 684 \brief get policy values
dflet 6:778b081f6a13 685
dflet 6:778b081f6a13 686 \param[in] Type SL_POLICY_CONNECTION, SL_POLICY_SCAN, SL_POLICY_PM,SL_POLICY_P2P \n
dflet 6:778b081f6a13 687
dflet 6:778b081f6a13 688 \param[in] Policy argument may be set to any value \n
dflet 6:778b081f6a13 689
dflet 6:778b081f6a13 690 \param[out] The returned values, depends on each policy type, will be stored in the allocated buffer pointed by pVal
dflet 6:778b081f6a13 691 with a maximum buffer length set by the calling function and pointed to by argument *pValLen
dflet 6:778b081f6a13 692
dflet 6:778b081f6a13 693 \return On success, zero is returned. On error, -1 is returned
dflet 6:778b081f6a13 694
dflet 6:778b081f6a13 695 \sa sl_WlanPolicySet
dflet 6:778b081f6a13 696
dflet 6:778b081f6a13 697 \note belongs to \ref ext_api
dflet 6:778b081f6a13 698
dflet 6:778b081f6a13 699 \warning The value pointed by the argument *pValLen should be set to a value different from 0 and
dflet 6:778b081f6a13 700 greater than the buffer length returned from the SL device. Otherwise, an error will be returned.
dflet 6:778b081f6a13 701
dflet 6:778b081f6a13 702 */
dflet 6:778b081f6a13 703 #if _SL_INCLUDE_FUNC(sl_WlanPolicyGet)
dflet 6:778b081f6a13 704 int16_t sl_WlanPolicyGet(const uint8_t Type , uint8_t Policy,uint8_t *pVal,uint8_t *pValLen);
dflet 6:778b081f6a13 705 #endif
dflet 6:778b081f6a13 706 /*!
dflet 6:778b081f6a13 707 \brief Gets the WLAN scan operation results
dflet 6:778b081f6a13 708
dflet 6:778b081f6a13 709 Gets scan results , gets entry from scan result table
dflet 6:778b081f6a13 710
dflet 6:778b081f6a13 711 \param[in] Index - Starting index identifier (range 0-19) for getting scan results
dflet 6:778b081f6a13 712 \param[in] Count - How many entries to fetch. Max is (20-"Index").
dflet 6:778b081f6a13 713 \param[out] pEntries - pointer to an allocated Sl_WlanNetworkEntry_t.
dflet 6:778b081f6a13 714 the number of array items should match "Count"
dflet 6:778b081f6a13 715 sec_type: SL_SCAN_SEC_TYPE_OPEN, SL_SCAN_SEC_TYPE_WEP, SL_SCAN_SEC_TYPE_WPA or SL_SCAN_SEC_TYPE_WPA2
dflet 6:778b081f6a13 716
dflet 6:778b081f6a13 717
dflet 6:778b081f6a13 718 \return Number of valid networks list items
dflet 6:778b081f6a13 719
dflet 6:778b081f6a13 720 \sa
dflet 6:778b081f6a13 721 \note belongs to \ref ext_api
dflet 6:778b081f6a13 722 \warning This command do not initiate any active scanning action
dflet 6:778b081f6a13 723 \par Example:
dflet 6:778b081f6a13 724 \code An example of fetching max 10 results:
dflet 6:778b081f6a13 725
dflet 6:778b081f6a13 726 Sl_WlanNetworkEntry_t netEntries[10];
dflet 6:778b081f6a13 727 int16_t resultsCount = sl_WlanGetNetworkList(0,10,&netEntries[0]);
dflet 6:778b081f6a13 728 for(i=0; i< resultsCount; i++)
dflet 6:778b081f6a13 729 {
dflet 6:778b081f6a13 730 printf("%s\n",netEntries[i].ssid);
dflet 6:778b081f6a13 731 }
dflet 6:778b081f6a13 732 \endcode
dflet 6:778b081f6a13 733 */
dflet 6:778b081f6a13 734 #if _SL_INCLUDE_FUNC(sl_WlanGetNetworkList)
dflet 6:778b081f6a13 735 int16_t sl_WlanGetNetworkList(const uint8_t Index, const uint8_t Count, Sl_WlanNetworkEntry_t *pEntries);
dflet 6:778b081f6a13 736 #endif
dflet 6:778b081f6a13 737
dflet 6:778b081f6a13 738 /*!
dflet 6:778b081f6a13 739 \brief Start collecting wlan RX statistics, for unlimited time.
dflet 6:778b081f6a13 740
dflet 6:778b081f6a13 741 \return On success, zero is returned. On error, -1 is returned
dflet 6:778b081f6a13 742
dflet 6:778b081f6a13 743 \sa sl_WlanRxStatStop sl_WlanRxStatGet
dflet 6:778b081f6a13 744 \note belongs to \ref ext_api
dflet 6:778b081f6a13 745 \warning
dflet 6:778b081f6a13 746 \par Example:
dflet 6:778b081f6a13 747 \code Getting wlan RX statistics:
dflet 6:778b081f6a13 748
dflet 6:778b081f6a13 749 void RxStatCollectTwice()
dflet 6:778b081f6a13 750 {
dflet 6:778b081f6a13 751 SlGetRxStatResponse_t rxStat;
dflet 6:778b081f6a13 752 int16_t rawSocket;
dflet 6:778b081f6a13 753 int8_t DataFrame[200];
dflet 6:778b081f6a13 754 struct SlTimeval_t timeval;
dflet 6:778b081f6a13 755 timeval.tv_sec = 0; // Seconds
dflet 6:778b081f6a13 756 timeval.tv_usec = 20000; // Microseconds. 10000 microseconds resolution
dflet 6:778b081f6a13 757
dflet 6:778b081f6a13 758 sl_WlanRxStatStart(); // set statistics mode
dflet 6:778b081f6a13 759
dflet 6:778b081f6a13 760 rawSocket = sl_Socket(SL_AF_RF, SL_SOCK_RAW, eChannel);
dflet 6:778b081f6a13 761 // set timeout - in case we have no activity for the specified channel
dflet 6:778b081f6a13 762 sl_SetSockOpt(rawSocket,SL_SOL_SOCKET,SL_SO_RCVTIMEO, &timeval, sizeof(timeval)); // Enable receive timeout
dflet 6:778b081f6a13 763 status = sl_Recv(rawSocket, DataFrame, sizeof(DataFrame), 0);
dflet 6:778b081f6a13 764
dflet 6:778b081f6a13 765 Sleep(1000); // sleep for 1 sec
dflet 6:778b081f6a13 766 sl_WlanRxStatGet(&rxStat,0); // statistics has been cleared upon read
dflet 6:778b081f6a13 767 Sleep(1000); // sleep for 1 sec
dflet 6:778b081f6a13 768 sl_WlanRxStatGet(&rxStat,0);
dflet 6:778b081f6a13 769
dflet 6:778b081f6a13 770 }
dflet 6:778b081f6a13 771 \endcode
dflet 6:778b081f6a13 772 */
dflet 6:778b081f6a13 773 #if _SL_INCLUDE_FUNC(sl_WlanRxStatStart)
dflet 6:778b081f6a13 774 int16_t sl_WlanRxStatStart(void);
dflet 6:778b081f6a13 775 #endif
dflet 6:778b081f6a13 776
dflet 6:778b081f6a13 777
dflet 6:778b081f6a13 778 /*!
dflet 6:778b081f6a13 779 \brief Stop collecting wlan RX statistic, (if previous called sl_WlanRxStatStart)
dflet 6:778b081f6a13 780
dflet 6:778b081f6a13 781 \return On success, zero is returned. On error, -1 is returned
dflet 6:778b081f6a13 782
dflet 6:778b081f6a13 783 \sa sl_WlanRxStatStart sl_WlanRxStatGet
dflet 6:778b081f6a13 784 \note belongs to \ref ext_api
dflet 6:778b081f6a13 785 \warning
dflet 6:778b081f6a13 786 */
dflet 6:778b081f6a13 787 #if _SL_INCLUDE_FUNC(sl_WlanRxStatStop)
dflet 6:778b081f6a13 788 int16_t sl_WlanRxStatStop(void);
dflet 6:778b081f6a13 789 #endif
dflet 6:778b081f6a13 790
dflet 6:778b081f6a13 791
dflet 6:778b081f6a13 792 /*!
dflet 6:778b081f6a13 793 \brief Get wlan RX statistics. upon calling this command, the statistics counters will be cleared.
dflet 6:778b081f6a13 794
dflet 6:778b081f6a13 795 \param[in] Flags should be 0 ( not applicable right now, will be added the future )
dflet 6:778b081f6a13 796 \param[in] pRxStat a pointer to SlGetRxStatResponse_t filled with Rx statistics results
dflet 6:778b081f6a13 797 \return On success, zero is returned. On error, -1 is returned
dflet 6:778b081f6a13 798
dflet 6:778b081f6a13 799 \sa sl_WlanRxStatStart sl_WlanRxStatStop
dflet 6:778b081f6a13 800 \note belongs to \ref ext_api
dflet 6:778b081f6a13 801 \warning
dflet 6:778b081f6a13 802 */
dflet 6:778b081f6a13 803 #if _SL_INCLUDE_FUNC(sl_WlanRxStatGet)
dflet 6:778b081f6a13 804 int16_t sl_WlanRxStatGet(SlGetRxStatResponse_t *pRxStat, const uint32_t Flags);
dflet 6:778b081f6a13 805 #endif
dflet 6:778b081f6a13 806
dflet 6:778b081f6a13 807
dflet 6:778b081f6a13 808 /*!
dflet 6:778b081f6a13 809 \brief Stop Smart Config procedure. Once Smart Config will be stopped,
dflet 6:778b081f6a13 810 Asynchronous event will be received - SL_OPCODE_WLAN_SMART_CONFIG_STOP_ASYNC_RESPONSE.
dflet 6:778b081f6a13 811
dflet 6:778b081f6a13 812 \param[in] none
dflet 6:778b081f6a13 813 \param[out] none
dflet 6:778b081f6a13 814
dflet 6:778b081f6a13 815 \return 0 - if Stop Smart Config is about to be executed without errors.
dflet 6:778b081f6a13 816
dflet 6:778b081f6a13 817 \sa sl_WlanSmartConfigStart
dflet 6:778b081f6a13 818 \note belongs to \ref ext_api
dflet 6:778b081f6a13 819 \warning
dflet 6:778b081f6a13 820
dflet 6:778b081f6a13 821 */
dflet 6:778b081f6a13 822 #if _SL_INCLUDE_FUNC(sl_WlanSmartConfigStop)
dflet 6:778b081f6a13 823 int16_t sl_WlanSmartConfigStop(void);
dflet 6:778b081f6a13 824 #endif
dflet 6:778b081f6a13 825
dflet 6:778b081f6a13 826 /*!
dflet 6:778b081f6a13 827 \brief Start Smart Config procedure
dflet 6:778b081f6a13 828 \par
dflet 6:778b081f6a13 829 The target of the procedure is to let the \n
dflet 6:778b081f6a13 830 device to gain the network parameters: SSID and Password (if network is secured) \n
dflet 6:778b081f6a13 831 and to connect to it once located in the network range. \n
dflet 6:778b081f6a13 832 An external application should be used on a device connected to any mobile network. \n
dflet 6:778b081f6a13 833 The external application will transmit over the air the network parameters in secured manner.\n
dflet 6:778b081f6a13 834 The Password may be decrypted using a Key. \n
dflet 6:778b081f6a13 835 The decryption method may be decided in the command or embedded in the Flash. \n
dflet 6:778b081f6a13 836 The procedure can be activated for 1-3 group ID in the range of BIT_0 - BIT_15 where the default group ID id 0 (BIT_0) \n
dflet 6:778b081f6a13 837 Once Smart Config has ended successfully, Asynchronous event will be received - \n
dflet 6:778b081f6a13 838 SL_OPCODE_WLAN_SMART_CONFIG_START_ASYNC_RESPONSE. \n
dflet 6:778b081f6a13 839 The Event will hold the SSID and an extra field that might have been delivered as well (i.e. - device name)
dflet 6:778b081f6a13 840
dflet 6:778b081f6a13 841 \param[in] groupIdBitmask - each bit represent a group ID that should be searched.
dflet 6:778b081f6a13 842 The Default group ID id BIT_0. 2 more group can be searched
dflet 6:778b081f6a13 843 in addition. The range is BIT_0 - BIT_15.
dflet 6:778b081f6a13 844 \param[in] chiper - 0: check in flash, 1 - AES, 0xFF - do not check in flash
dflet 6:778b081f6a13 845 \param[in] publicKeyLen - public key len (used for the default group ID - BIT_0)
dflet 6:778b081f6a13 846 \param[in] group1KeyLen - group ID1 length
dflet 6:778b081f6a13 847 \param[in] group2KeyLen - group ID2 length
dflet 6:778b081f6a13 848 \param[in] publicKey - public key (used for the default group ID - BIT_0)
dflet 6:778b081f6a13 849 \param[in] group1Key - group ID1 key
dflet 6:778b081f6a13 850 \param[in] group2Key - group ID2 key
dflet 6:778b081f6a13 851
dflet 6:778b081f6a13 852 \param[out] none
dflet 6:778b081f6a13 853
dflet 6:778b081f6a13 854 \return 0 - if Smart Config started successfully.
dflet 6:778b081f6a13 855
dflet 6:778b081f6a13 856 \sa sl_WlanSmartConfigStop
dflet 6:778b081f6a13 857 \note belongs to \ref ext_api
dflet 6:778b081f6a13 858 \warning
dflet 6:778b081f6a13 859 \par
dflet 6:778b081f6a13 860 \code An example of starting smart Config on group ID's 0 + 1 + 2
dflet 6:778b081f6a13 861
dflet 6:778b081f6a13 862 sl_WlanSmartConfigStart(7, //group ID's (BIT_0 | BIT_1 | BIT_2)
dflet 6:778b081f6a13 863 1, //decrypt key by AES method
dflet 6:778b081f6a13 864 16, //decryption key length for group ID0
dflet 6:778b081f6a13 865 16, //decryption key length for group ID1
dflet 6:778b081f6a13 866 16, //decryption key length for group ID2
dflet 6:778b081f6a13 867 "Key0Key0Key0Key0", //decryption key for group ID0
dflet 6:778b081f6a13 868 "Key1Key1Key1Key1", //decryption key for group ID1
dflet 6:778b081f6a13 869 "Key2Key2Key2Key2" //decryption key for group ID2
dflet 6:778b081f6a13 870 );
dflet 6:778b081f6a13 871 \endcode
dflet 6:778b081f6a13 872 */
dflet 6:778b081f6a13 873 #if _SL_INCLUDE_FUNC(sl_WlanSmartConfigStart)
dflet 6:778b081f6a13 874 int16_t sl_WlanSmartConfigStart(const uint32_t groupIdBitmask,
dflet 6:778b081f6a13 875 const uint8_t cipher,
dflet 6:778b081f6a13 876 const uint8_t publicKeyLen,
dflet 6:778b081f6a13 877 const uint8_t group1KeyLen,
dflet 6:778b081f6a13 878 const uint8_t group2KeyLen,
dflet 6:778b081f6a13 879 const uint8_t* publicKey,
dflet 6:778b081f6a13 880 const uint8_t* group1Key,
dflet 6:778b081f6a13 881 const uint8_t* group2Key);
dflet 6:778b081f6a13 882 #endif
dflet 6:778b081f6a13 883
dflet 6:778b081f6a13 884
dflet 6:778b081f6a13 885 /*!
dflet 6:778b081f6a13 886 \brief Wlan set mode
dflet 6:778b081f6a13 887
dflet 6:778b081f6a13 888 Setting WLAN mode
dflet 6:778b081f6a13 889
dflet 6:778b081f6a13 890 \param[in] mode - WLAN mode to start the CC31xx device. Possible options are:
dflet 6:778b081f6a13 891 - ROLE_STA - for WLAN station mode
dflet 6:778b081f6a13 892 - ROLE_AP - for WLAN AP mode
dflet 6:778b081f6a13 893 - ROLE_P2P -for WLAN P2P mode
dflet 6:778b081f6a13 894 \return 0 - if mode was set correctly
dflet 6:778b081f6a13 895 \sa sl_Start sl_Stop
dflet 6:778b081f6a13 896 \note belongs to \ref ext_api
dflet 6:778b081f6a13 897 \warning After setting the mode the system must be restarted for activating the new mode
dflet 6:778b081f6a13 898 \par Example:
dflet 6:778b081f6a13 899 \code
dflet 6:778b081f6a13 900 //Switch from any role to STA:
dflet 6:778b081f6a13 901 sl_WlanSetMode(ROLE_STA);
dflet 6:778b081f6a13 902 sl_Stop(0);
dflet 6:778b081f6a13 903 sl_Start(NULL,NULL,NULL);
dflet 6:778b081f6a13 904 \endcode
dflet 6:778b081f6a13 905
dflet 6:778b081f6a13 906 */
dflet 6:778b081f6a13 907 #if _SL_INCLUDE_FUNC(sl_WlanSetMode)
dflet 6:778b081f6a13 908 int16_t sl_WlanSetMode(const uint8_t mode);
dflet 6:778b081f6a13 909 #endif
dflet 6:778b081f6a13 910
dflet 6:778b081f6a13 911
dflet 6:778b081f6a13 912 /*!
dflet 6:778b081f6a13 913 \brief Internal function for setting WLAN configurations
dflet 6:778b081f6a13 914
dflet 6:778b081f6a13 915 \return On success, zero is returned. On error one of the following error codes returned:
dflet 6:778b081f6a13 916 - CONF_ERROR (-1)
dflet 6:778b081f6a13 917 - CONF_NVMEM_ACCESS_FAILED (-2)
dflet 6:778b081f6a13 918 - CONF_OLD_FILE_VERSION (-3)
dflet 6:778b081f6a13 919 - CONF_ERROR_NO_SUCH_COUNTRY_CODE (-4)
dflet 6:778b081f6a13 920
dflet 6:778b081f6a13 921
dflet 6:778b081f6a13 922 \param[in] ConfigId - configuration id
dflet 6:778b081f6a13 923 - <b>SL_WLAN_CFG_AP_ID</b>
dflet 6:778b081f6a13 924 - <b>SL_WLAN_CFG_GENERAL_PARAM_ID</b>
dflet 6:778b081f6a13 925 - <b>SL_WLAN_CFG_P2P_PARAM_ID</b>
dflet 6:778b081f6a13 926
dflet 6:778b081f6a13 927 \param[in] ConfigOpt - configurations option
dflet 6:778b081f6a13 928 - <b>SL_WLAN_CFG_AP_ID</b>
dflet 6:778b081f6a13 929 - <b>WLAN_AP_OPT_SSID</b> \n
dflet 6:778b081f6a13 930 Set SSID for AP mode. \n
dflet 6:778b081f6a13 931 This options takes <b>uint8_t</b> buffer as parameter
dflet 6:778b081f6a13 932 - <b>WLAN_AP_OPT_CHANNEL</b> \n
dflet 6:778b081f6a13 933 Set channel for AP mode. \n
dflet 6:778b081f6a13 934 The channel is dependant on the country code which is set. i.e. for "US" the channel should be in the range of [1-11] \n
dflet 6:778b081f6a13 935 This option takes <b>uint8_t</b> as a parameter
dflet 6:778b081f6a13 936 - <b>WLAN_AP_OPT_HIDDEN_SSID</b> \n
dflet 6:778b081f6a13 937 Set Hidden SSID Mode for AP mode.Hidden options: \n
dflet 6:778b081f6a13 938 0: disabled \n
dflet 6:778b081f6a13 939 1: Send empty (length=0) SSID in beacon and ignore probe request for broadcast SSID \n
dflet 6:778b081f6a13 940 2: Clear SSID (ASCII 0), but keep the original length (this may be required with some \n
dflet 6:778b081f6a13 941 clients that do not support empty SSID) and ignore probe requests for broadcast SSID \n
dflet 6:778b081f6a13 942 This option takes <b>uint8_t</b> as a parameter
dflet 6:778b081f6a13 943 - <b>WLAN_AP_OPT_SECURITY_TYPE</b> \n
dflet 6:778b081f6a13 944 Set Security type for AP mode. Security options are:
dflet 6:778b081f6a13 945 - Open security: SL_SEC_TYPE_OPEN
dflet 6:778b081f6a13 946 - WEP security: SL_SEC_TYPE_WEP
dflet 6:778b081f6a13 947 - WPA security: SL_SEC_TYPE_WPA_WPA2 \n
dflet 6:778b081f6a13 948 This option takes <b>uint8_t</b> pointer as a parameter
dflet 6:778b081f6a13 949 - <b>WLAN_AP_OPT_PASSWORD</b> \n
dflet 6:778b081f6a13 950 Set Password for for AP mode (for WEP or for WPA): \n
dflet 6:778b081f6a13 951 Password - for WPA: 8 - 63 characters \n
dflet 6:778b081f6a13 952 for WEP: 5 / 13 characters (ascii) \n
dflet 6:778b081f6a13 953 This options takes <b>uint8_t</b> buffer as parameter
dflet 6:778b081f6a13 954 - <b>SL_WLAN_CFG_GENERAL_PARAM_ID</b>
dflet 6:778b081f6a13 955 - <b> WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS </b> \n
dflet 6:778b081f6a13 956 Set scan parameters.
dflet 6:778b081f6a13 957 This option uses slWlanScanParamCommand_t as parameter
dflet 6:778b081f6a13 958 - <b>WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE</b> \n
dflet 6:778b081f6a13 959 Set Country Code for AP mode \n
dflet 6:778b081f6a13 960 This options takes <b>uint8_t</b> 2 bytes buffer as parameter
dflet 6:778b081f6a13 961 - <b>WLAN_GENERAL_PARAM_OPT_STA_TX_POWER</b> \n
dflet 6:778b081f6a13 962 Set STA mode Tx power level \n
dflet 6:778b081f6a13 963 Number between 0-15, as dB offset from max power (0 will set MAX power) \n
dflet 6:778b081f6a13 964 This options takes <b>uint8_t</b> as parameter
dflet 6:778b081f6a13 965 - <b>WLAN_GENERAL_PARAM_OPT_AP_TX_POWER</b>
dflet 6:778b081f6a13 966 Set AP mode Tx power level \n
dflet 6:778b081f6a13 967 Number between 0-15, as dB offset from max power (0 will set MAX power) \n
dflet 6:778b081f6a13 968 This options takes <b>uint8_t</b> as parameter
dflet 6:778b081f6a13 969 - <b>WLAN_GENERAL_PARAM_OPT_INFO_ELEMENT</b>
dflet 6:778b081f6a13 970 Set Info Element for AP mode. \n
dflet 6:778b081f6a13 971 The Application can set up to MAX_PRIVATE_INFO_ELEMENTS_SUPPROTED info elements per Role (AP / P2P GO). \n
dflet 6:778b081f6a13 972 To delete an info element use the relevant index and length = 0. \n
dflet 6:778b081f6a13 973 The Application can set up to MAX_PRIVATE_INFO_ELEMENTS_SUPPROTED to the same role. \n
dflet 6:778b081f6a13 974 However, for AP - no more than INFO_ELEMENT_MAX_TOTAL_LENGTH_AP bytes can be stored for all info elements. \n
dflet 6:778b081f6a13 975 For P2P GO - no more than INFO_ELEMENT_MAX_TOTAL_LENGTH_P2P_GO bytes can be stored for all info elements. \n
dflet 6:778b081f6a13 976 This option takes sl_protocol_WlanSetInfoElement_t as parameter
dflet 6:778b081f6a13 977 - <b>SL_WLAN_CFG_P2P_PARAM_ID</b>
dflet 6:778b081f6a13 978 - <b>WLAN_P2P_OPT_DEV_TYPE</b> \n
dflet 6:778b081f6a13 979 Set P2P Device type.Maximum length of 17 characters. Device type is published under P2P I.E, \n
dflet 6:778b081f6a13 980 allows to make devices easier to recognize. \n
dflet 6:778b081f6a13 981 In case no device type is set, the default type is "1-0050F204-1" \n
dflet 6:778b081f6a13 982 This options takes <b>uint8_t</b> buffer as parameter
dflet 6:778b081f6a13 983 - <b>WLAN_P2P_OPT_CHANNEL_N_REGS</b> \n
dflet 6:778b081f6a13 984 Set P2P Channels. \n
dflet 6:778b081f6a13 985 listen channel (either 1/6/11 for 2.4GHz) \n
dflet 6:778b081f6a13 986 listen regulatory class (81 for 2.4GHz) \n
dflet 6:778b081f6a13 987 oper channel (either 1/6/11 for 2.4GHz) \n
dflet 6:778b081f6a13 988 oper regulatory class (81 for 2.4GHz) \n
dflet 6:778b081f6a13 989 listen channel and regulatory class will determine the device listen channel during p2p find listen phase \n
dflet 6:778b081f6a13 990 oper channel and regulatory class will determine the operating channel preferred by this device (in case it is group owner this will be the operating channel) \n
dflet 6:778b081f6a13 991 channels should be one of the social channels (1/6/11). In case no listen/oper channel selected, a random 1/6/11 will be selected.
dflet 6:778b081f6a13 992 This option takes pointer to <b>uint8_t[4]</b> as parameter
dflet 6:778b081f6a13 993
dflet 6:778b081f6a13 994 \param[in] ConfigLen - configurations len
dflet 6:778b081f6a13 995
dflet 6:778b081f6a13 996 \param[in] pValues - configurations values
dflet 6:778b081f6a13 997
dflet 6:778b081f6a13 998 \sa
dflet 6:778b081f6a13 999 \note
dflet 6:778b081f6a13 1000 \warning
dflet 6:778b081f6a13 1001 \par Examples:
dflet 6:778b081f6a13 1002 \par
dflet 6:778b081f6a13 1003 <b> WLAN_AP_OPT_SSID: </b>
dflet 6:778b081f6a13 1004 \code
dflet 6:778b081f6a13 1005 uint8_t str[33];
dflet 6:778b081f6a13 1006 memset(str, 0, 33);
dflet 6:778b081f6a13 1007 memcpy(str, ssid, len); // ssid string of 32 characters
dflet 6:778b081f6a13 1008 sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(ssid), str);
dflet 6:778b081f6a13 1009 \endcode
dflet 6:778b081f6a13 1010 \par
dflet 6:778b081f6a13 1011 <b> WLAN_AP_OPT_CHANNEL: </b>
dflet 6:778b081f6a13 1012 \code
dflet 6:778b081f6a13 1013 uint8_t val = channel;
dflet 6:778b081f6a13 1014 sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_CHANNEL, 1, (uint8_t *)&val);
dflet 6:778b081f6a13 1015 \endcode
dflet 6:778b081f6a13 1016 \par
dflet 6:778b081f6a13 1017 <b> WLAN_AP_OPT_HIDDEN_SSID: </b>
dflet 6:778b081f6a13 1018 \code
dflet 6:778b081f6a13 1019 uint8_t val = hidden;
dflet 6:778b081f6a13 1020 sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_HIDDEN_SSID, 1, (uint8_t *)&val);
dflet 6:778b081f6a13 1021 \endcode
dflet 6:778b081f6a13 1022 \par
dflet 6:778b081f6a13 1023 <b> WLAN_AP_OPT_SECURITY_TYPE: </b>
dflet 6:778b081f6a13 1024 \code
dflet 6:778b081f6a13 1025 uint8_t val = SL_SEC_TYPE_WPA_WPA2;
dflet 6:778b081f6a13 1026 sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1, (uint8_t *)&val);
dflet 6:778b081f6a13 1027 \endcode
dflet 6:778b081f6a13 1028 \par
dflet 6:778b081f6a13 1029 <b> WLAN_AP_OPT_PASSWORD: </b>
dflet 6:778b081f6a13 1030 \code
dflet 6:778b081f6a13 1031 uint8_t str[65];
dflet 6:778b081f6a13 1032 uint16_t len = strlen(password);
dflet 6:778b081f6a13 1033 memset(str, 0, 65);
dflet 6:778b081f6a13 1034 memcpy(str, password, len);
dflet 6:778b081f6a13 1035 sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_PASSWORD, len, (uint8_t *)str);
dflet 6:778b081f6a13 1036 \endcode
dflet 6:778b081f6a13 1037 \par
dflet 6:778b081f6a13 1038 <b> WLAN_GENERAL_PARAM_OPT_STA_TX_POWER: </b>
dflet 6:778b081f6a13 1039 \code
dflet 6:778b081f6a13 1040 uint8_t stapower=(uint8_t)power;
dflet 6:778b081f6a13 1041 sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER,1,(uint8_t *)&stapower);
dflet 6:778b081f6a13 1042 \endcode
dflet 6:778b081f6a13 1043 \par
dflet 6:778b081f6a13 1044 <b> WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS: </b>
dflet 6:778b081f6a13 1045 \code
dflet 6:778b081f6a13 1046 slWlanScanParamCommand_t ScanParamConfig;
dflet 6:778b081f6a13 1047 ScanParamConfig.G_Channels_mask = 0x01; // bit mask for channels:1 means channel 1 is enabled, 3 means channels 1 + 2 are enabled
dflet 6:778b081f6a13 1048 ScanParamConfig.rssiThershold = -70; // only for RSSI level which is higher than -70
dflet 6:778b081f6a13 1049 sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID ,WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS,sizeof(slWlanScanParamCommand_t),(_u8*)&ScanParamConfig);
dflet 6:778b081f6a13 1050 \endcode
dflet 6:778b081f6a13 1051 \par
dflet 6:778b081f6a13 1052 <b> WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE: </b>
dflet 6:778b081f6a13 1053 \code
dflet 6:778b081f6a13 1054 uint8_t* str = (uint8_t *) country; // string of 2 characters. i.e. - "US"
dflet 6:778b081f6a13 1055 sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE, 2, str);
dflet 6:778b081f6a13 1056 \endcode
dflet 6:778b081f6a13 1057 \par
dflet 6:778b081f6a13 1058 <b> WLAN_GENERAL_PARAM_OPT_AP_TX_POWER: </b>
dflet 6:778b081f6a13 1059 \code
dflet 6:778b081f6a13 1060 uint8_t appower=(uint8_t)power;
dflet 6:778b081f6a13 1061 sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_AP_TX_POWER,1,(uint8_t *)&appower);
dflet 6:778b081f6a13 1062 \endcode
dflet 6:778b081f6a13 1063 \par
dflet 6:778b081f6a13 1064 <b> WLAN_P2P_OPT_DEV_TYPE: </b>
dflet 6:778b081f6a13 1065 \code
dflet 6:778b081f6a13 1066 uint8_t str[17];
dflet 6:778b081f6a13 1067 uint16_t len = strlen(device_type);
dflet 6:778b081f6a13 1068 memset(str, 0, 17);
dflet 6:778b081f6a13 1069 memcpy(str, device_type, len);
dflet 6:778b081f6a13 1070 sl_WlanSet(SL_WLAN_CFG_P2P_PARAM_ID, WLAN_P2P_OPT_DEV_TYPE, len, str);
dflet 6:778b081f6a13 1071 \endcode
dflet 6:778b081f6a13 1072 \par
dflet 6:778b081f6a13 1073 <b> WLAN_P2P_OPT_CHANNEL_N_REGS: </b>
dflet 6:778b081f6a13 1074 \code
dflet 6:778b081f6a13 1075 uint8_t str[4];
dflet 6:778b081f6a13 1076 str[0] = (uint8_t)11; // listen channel
dflet 6:778b081f6a13 1077 str[1] = (uint8_t)81; // listen regulatory class
dflet 6:778b081f6a13 1078 str[2] = (uint8_t)6; // oper channel
dflet 6:778b081f6a13 1079 str[3] = (uint8_t)81; // oper regulatory class
dflet 6:778b081f6a13 1080 sl_WlanSet(SL_WLAN_CFG_P2P_PARAM_ID, WLAN_P2P_OPT_CHANNEL_N_REGS, 4, str);
dflet 6:778b081f6a13 1081 \endcode
dflet 6:778b081f6a13 1082 \par
dflet 6:778b081f6a13 1083 <b> WLAN_GENERAL_PARAM_OPT_INFO_ELEMENT: </b>
dflet 6:778b081f6a13 1084 \code
dflet 6:778b081f6a13 1085 sl_protocol_WlanSetInfoElement_t infoele;
dflet 6:778b081f6a13 1086 infoele.index = Index; // Index of the info element. range: 0 - MAX_PRIVATE_INFO_ELEMENTS_SUPPROTED
dflet 6:778b081f6a13 1087 infoele.role = Role; // INFO_ELEMENT_AP_ROLE (0) or INFO_ELEMENT_P2P_GO_ROLE (1)
dflet 6:778b081f6a13 1088 infoele.ie.id = Id; // Info element ID. if INFO_ELEMENT_DEFAULT_ID (0) is set, ID will be set to 221.
dflet 6:778b081f6a13 1089 // Organization unique ID. If all 3 bytes are zero - it will be replaced with 08,00,28.
dflet 6:778b081f6a13 1090 infoele.ie.oui[0] = Oui0; // Organization unique ID first Byte
dflet 6:778b081f6a13 1091 infoele.ie.oui[1] = Oui1; // Organization unique ID second Byte
dflet 6:778b081f6a13 1092 infoele.ie.oui[2] = Oui2; // Organization unique ID third Byte
dflet 6:778b081f6a13 1093 infoele.ie.length = Len; // Length of the info element. must be smaller than 253 bytes
dflet 6:778b081f6a13 1094 memset(infoele.ie.data, 0, INFO_ELEMENT_MAX_SIZE);
dflet 6:778b081f6a13 1095 if ( Len <= INFO_ELEMENT_MAX_SIZE )
dflet 6:778b081f6a13 1096 {
dflet 6:778b081f6a13 1097 memcpy(infoele.ie.data, IE, Len); // Info element. length of the info element is [0-252]
dflet 6:778b081f6a13 1098 sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,WLAN_GENERAL_PARAM_OPT_INFO_ELEMENT,sizeof(sl_protocol_WlanSetInfoElement_t),(uint8_t* ) &infoele);
dflet 6:778b081f6a13 1099 }
dflet 6:778b081f6a13 1100 sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,WLAN_GENERAL_PARAM_OPT_INFO_ELEMENT,sizeof(sl_protocol_WlanSetInfoElement_t),(uint8_t* ) &infoele);
dflet 6:778b081f6a13 1101 \endcode
dflet 6:778b081f6a13 1102
dflet 6:778b081f6a13 1103 */
dflet 6:778b081f6a13 1104 #if _SL_INCLUDE_FUNC(sl_WlanSet)
dflet 6:778b081f6a13 1105 int16_t sl_WlanSet(const uint16_t ConfigId ,const uint16_t ConfigOpt, const uint16_t ConfigLen, const uint8_t *pValues);
dflet 6:778b081f6a13 1106 #endif
dflet 6:778b081f6a13 1107
dflet 6:778b081f6a13 1108 /*!
dflet 6:778b081f6a13 1109 \brief Internal function for getting WLAN configurations
dflet 6:778b081f6a13 1110
dflet 6:778b081f6a13 1111 \return On success, zero is returned. On error, -1 is
dflet 6:778b081f6a13 1112 returned
dflet 6:778b081f6a13 1113
dflet 6:778b081f6a13 1114 \param[in] ConfigId - configuration id
dflet 6:778b081f6a13 1115 - <b>SL_WLAN_CFG_AP_ID</b>
dflet 6:778b081f6a13 1116 - <b>SL_WLAN_CFG_GENERAL_PARAM_ID</b>
dflet 6:778b081f6a13 1117 - <b>SL_WLAN_CFG_P2P_PARAM_ID</b>
dflet 6:778b081f6a13 1118
dflet 6:778b081f6a13 1119 \param[out] pConfigOpt - get configurations option
dflet 6:778b081f6a13 1120 - <b>SL_WLAN_CFG_AP_ID</b>
dflet 6:778b081f6a13 1121 - <b>WLAN_AP_OPT_SSID</b> \n
dflet 6:778b081f6a13 1122 Get SSID for AP mode. \n
dflet 6:778b081f6a13 1123 Get up to 32 characters of SSID \n
dflet 6:778b081f6a13 1124 This options takes <b>uint8_t</b> as parameter
dflet 6:778b081f6a13 1125 - <b>WLAN_AP_OPT_CHANNEL</b> \n
dflet 6:778b081f6a13 1126 Get channel for AP mode. \n
dflet 6:778b081f6a13 1127 This option takes <b>uint8_t</b> as a parameter
dflet 6:778b081f6a13 1128 - <b>WLAN_AP_OPT_HIDDEN_SSID</b> \n
dflet 6:778b081f6a13 1129 Get Hidden SSID Mode for AP mode.Hidden options: \n
dflet 6:778b081f6a13 1130 0: disabled \n
dflet 6:778b081f6a13 1131 1: Send empty (length=0) SSID in beacon and ignore probe request for broadcast SSID \n
dflet 6:778b081f6a13 1132 2: Clear SSID (ASCII 0), but keep the original length (this may be required with some \n
dflet 6:778b081f6a13 1133 clients that do not support empty SSID) and ignore probe requests for broadcast SSID \n
dflet 6:778b081f6a13 1134 This option takes <b>uint8_t</b> as a parameter
dflet 6:778b081f6a13 1135 - <b>WLAN_AP_OPT_SECURITY_TYPE</b> \n
dflet 6:778b081f6a13 1136 Get Security type for AP mode. Security options are:
dflet 6:778b081f6a13 1137 - Open security: SL_SEC_TYPE_OPEN
dflet 6:778b081f6a13 1138 - WEP security: SL_SEC_TYPE_WEP
dflet 6:778b081f6a13 1139 - WPA security: SL_SEC_TYPE_WPA_WPA2 \n
dflet 6:778b081f6a13 1140 This option takes <b>uint8_t</b> as a parameter
dflet 6:778b081f6a13 1141 - <b>WLAN_AP_OPT_PASSWORD</b> \n
dflet 6:778b081f6a13 1142 Get Password for for AP mode (for WEP or for WPA): \n
dflet 6:778b081f6a13 1143 Returns password - string, fills up to 64 characters. \n
dflet 6:778b081f6a13 1144 This options takes <b>uint8_t</b> buffer as parameter
dflet 6:778b081f6a13 1145 - <b>SL_WLAN_CFG_GENERAL_PARAM_ID</b>
dflet 6:778b081f6a13 1146 - <b> WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS </b> \n
dflet 6:778b081f6a13 1147 Get scan parameters.
dflet 6:778b081f6a13 1148 This option uses slWlanScanParamCommand_t as parameter
dflet 6:778b081f6a13 1149 - <b>WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE</b> \n
dflet 6:778b081f6a13 1150 Get Country Code for AP mode \n
dflet 6:778b081f6a13 1151 This options takes <b>uint8_t</b> buffer as parameter
dflet 6:778b081f6a13 1152 - <b>WLAN_GENERAL_PARAM_OPT_STA_TX_POWER</b> \n
dflet 6:778b081f6a13 1153 Get STA mode Tx power level \n
dflet 6:778b081f6a13 1154 Number between 0-15, as dB offset from max power (0 indicates MAX power) \n
dflet 6:778b081f6a13 1155 This options takes <b>uint8_t</b> as parameter
dflet 6:778b081f6a13 1156 - <b>WLAN_GENERAL_PARAM_OPT_AP_TX_POWER</b>
dflet 6:778b081f6a13 1157 Get AP mode Tx power level \n
dflet 6:778b081f6a13 1158 Number between 0-15, as dB offset from max power (0 indicates MAX power) \n
dflet 6:778b081f6a13 1159 This options takes <b>uint8_t</b> as parameter
dflet 6:778b081f6a13 1160 - <b>SL_WLAN_CFG_P2P_PARAM_ID</b>
dflet 6:778b081f6a13 1161 - <b>WLAN_P2P_OPT_CHANNEL_N_REGS</b> \n
dflet 6:778b081f6a13 1162 Get P2P Channels. \n
dflet 6:778b081f6a13 1163 listen channel (either 1/6/11 for 2.4GHz) \n
dflet 6:778b081f6a13 1164 listen regulatory class (81 for 2.4GHz) \n
dflet 6:778b081f6a13 1165 oper channel (either 1/6/11 for 2.4GHz) \n
dflet 6:778b081f6a13 1166 oper regulatory class (81 for 2.4GHz) \n
dflet 6:778b081f6a13 1167 listen channel and regulatory class will determine the device listen channel during p2p find listen phase \n
dflet 6:778b081f6a13 1168 oper channel and regulatory class will determine the operating channel preferred by this device (in case it is group owner this will be the operating channel) \n
dflet 6:778b081f6a13 1169 channels should be one of the social channels (1/6/11). In case no listen/oper channel selected, a random 1/6/11 will be selected. \n
dflet 6:778b081f6a13 1170 This option takes pointer to <b>uint8_t[4]</b> as parameter
dflet 6:778b081f6a13 1171
dflet 6:778b081f6a13 1172 \param[out] pConfigLen - The length of the allocated memory as input, when the
dflet 6:778b081f6a13 1173 function complete, the value of this parameter would be
dflet 6:778b081f6a13 1174 the len that actually read from the device.
dflet 6:778b081f6a13 1175 If the device return length that is longer from the input
dflet 6:778b081f6a13 1176 value, the function will cut the end of the returned structure
dflet 6:778b081f6a13 1177 and will return SL_ESMALLBUF.
dflet 6:778b081f6a13 1178
dflet 6:778b081f6a13 1179
dflet 6:778b081f6a13 1180 \param[out] pValues - get configurations values
dflet 6:778b081f6a13 1181
dflet 6:778b081f6a13 1182 \sa sl_WlanSet
dflet 6:778b081f6a13 1183
dflet 6:778b081f6a13 1184 \note
dflet 6:778b081f6a13 1185
dflet 6:778b081f6a13 1186 \warning
dflet 6:778b081f6a13 1187
dflet 6:778b081f6a13 1188 \par Examples:
dflet 6:778b081f6a13 1189 \par
dflet 6:778b081f6a13 1190 <b> WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS: </b>
dflet 6:778b081f6a13 1191 \code
dflet 6:778b081f6a13 1192 slWlanScanParamCommand_t ScanParamConfig;
dflet 6:778b081f6a13 1193 uint16_t Option = WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS;
dflet 6:778b081f6a13 1194 uint16_t OptionLen = sizeof(slWlanScanParamCommand_t);
dflet 6:778b081f6a13 1195 sl_WlanGet(SL_WLAN_CFG_GENERAL_PARAM_ID ,&Option,&OptionLen,(uint8_t *)&ScanParamConfig);
dflet 6:778b081f6a13 1196 \endcode
dflet 6:778b081f6a13 1197 \par
dflet 6:778b081f6a13 1198 <b> WLAN_GENERAL_PARAM_OPT_AP_TX_POWER: </b>
dflet 6:778b081f6a13 1199 \code
dflet 6:778b081f6a13 1200 _i8 TXPower = 0;
dflet 6:778b081f6a13 1201 _u16 Option = WLAN_GENERAL_PARAM_OPT_AP_TX_POWER;
dflet 6:778b081f6a13 1202 _u16 OptionLen = sizeof(_i8);
dflet 6:778b081f6a13 1203 sl_WlanGet(SL_WLAN_CFG_GENERAL_PARAM_ID ,&Option,&OptionLen,(_u8 *)&TXPower);
dflet 6:778b081f6a13 1204 \endcode
dflet 6:778b081f6a13 1205 \par
dflet 6:778b081f6a13 1206 <b> WLAN_GENERAL_PARAM_OPT_STA_TX_POWER: </b>
dflet 6:778b081f6a13 1207 \code
dflet 6:778b081f6a13 1208 _i8 TXPower = 0;
dflet 6:778b081f6a13 1209 _u16 Option = WLAN_GENERAL_PARAM_OPT_STA_TX_POWER;
dflet 6:778b081f6a13 1210 _u16 OptionLen = sizeof(_i8);
dflet 6:778b081f6a13 1211
dflet 6:778b081f6a13 1212 sl_WlanGet(SL_WLAN_CFG_GENERAL_PARAM_ID ,&Option,&OptionLen,(uint8_t *)&TXPower);
dflet 6:778b081f6a13 1213 \endcode
dflet 6:778b081f6a13 1214 \par
dflet 6:778b081f6a13 1215 <b> WLAN_P2P_OPT_DEV_TYPE: </b>
dflet 6:778b081f6a13 1216 \code
dflet 6:778b081f6a13 1217 int8_t device_type[18];
dflet 6:778b081f6a13 1218 uint16_t len = 18;
dflet 6:778b081f6a13 1219 uint16_t config_opt = WLAN_P2P_OPT_DEV_TYPE;
dflet 6:778b081f6a13 1220 sl_WlanGet(SL_WLAN_CFG_P2P_PARAM_ID, &config_opt , &len, (uint8_t* )device_type);
dflet 6:778b081f6a13 1221 \endcode
dflet 6:778b081f6a13 1222 \par
dflet 6:778b081f6a13 1223 <b> WLAN_AP_OPT_SSID: </b>
dflet 6:778b081f6a13 1224 \code
dflet 6:778b081f6a13 1225 int8_t ssid[32];
dflet 6:778b081f6a13 1226 uint16_t len = 32;
dflet 6:778b081f6a13 1227 uint16_t config_opt = WLAN_AP_OPT_SSID;
dflet 6:778b081f6a13 1228 sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt , &len, (uint8_t* )ssid);
dflet 6:778b081f6a13 1229 \endcode
dflet 6:778b081f6a13 1230 \par
dflet 6:778b081f6a13 1231 <b> WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE: </b>
dflet 6:778b081f6a13 1232 \code
dflet 6:778b081f6a13 1233 int8_t country[3];
dflet 6:778b081f6a13 1234 uint16_t len = 3;
dflet 6:778b081f6a13 1235 uint16_t config_opt = WLAN_GENERAL_PARAM_OPT_COUNTRY_CODE;
dflet 6:778b081f6a13 1236 sl_WlanGet(SL_WLAN_CFG_GENERAL_PARAM_ID, &config_opt, &len, (uint8_t* )country);
dflet 6:778b081f6a13 1237 \endcode
dflet 6:778b081f6a13 1238 \par
dflet 6:778b081f6a13 1239 <b> WLAN_AP_OPT_CHANNEL: </b>
dflet 6:778b081f6a13 1240 \code
dflet 6:778b081f6a13 1241 int8_t channel;
dflet 6:778b081f6a13 1242 uint16_t len = 1;
dflet 6:778b081f6a13 1243 uint16_t config_opt = WLAN_AP_OPT_CHANNEL;
dflet 6:778b081f6a13 1244 sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt, &len, (uint8_t* )&channel);
dflet 6:778b081f6a13 1245 \endcode
dflet 6:778b081f6a13 1246 \par
dflet 6:778b081f6a13 1247 <b> WLAN_AP_OPT_HIDDEN_SSID: </b>
dflet 6:778b081f6a13 1248 \code
dflet 6:778b081f6a13 1249 uint8_t hidden;
dflet 6:778b081f6a13 1250 uint16_t len = 1;
dflet 6:778b081f6a13 1251 uint16_t config_opt = WLAN_AP_OPT_HIDDEN_SSID;
dflet 6:778b081f6a13 1252 sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt, &len, (uint8_t* )&hidden);
dflet 6:778b081f6a13 1253 \endcode
dflet 6:778b081f6a13 1254 \par
dflet 6:778b081f6a13 1255 <b> WLAN_AP_OPT_SECURITY_TYPE: </b>
dflet 6:778b081f6a13 1256 \code
dflet 6:778b081f6a13 1257 uint8_t sec_type;
dflet 6:778b081f6a13 1258 uint16_t len = 1;
dflet 6:778b081f6a13 1259 uint16_t config_opt = WLAN_AP_OPT_SECURITY_TYPE;
dflet 6:778b081f6a13 1260 sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt, &len, (uint8_t* )&sec_type);
dflet 6:778b081f6a13 1261 \endcode
dflet 6:778b081f6a13 1262 \par
dflet 6:778b081f6a13 1263 <b> WLAN_AP_OPT_PASSWORD: </b>
dflet 6:778b081f6a13 1264 \code
dflet 6:778b081f6a13 1265 uint8_t password[64];
dflet 6:778b081f6a13 1266 uint16_t len = 64;
dflet 6:778b081f6a13 1267 memset(password,0,64);
dflet 6:778b081f6a13 1268 uint16_t config_opt = WLAN_AP_OPT_PASSWORD;
dflet 6:778b081f6a13 1269 sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt, &len, (uint8_t* )password);
dflet 6:778b081f6a13 1270
dflet 6:778b081f6a13 1271 \endcode
dflet 6:778b081f6a13 1272 \par
dflet 6:778b081f6a13 1273 <b> WLAN_P2P_OPT_CHANNEL_N_REGS: </b>
dflet 6:778b081f6a13 1274 \code
dflet 6:778b081f6a13 1275 uint16_t listen_channel,listen_reg,oper_channel,oper_reg;
dflet 6:778b081f6a13 1276 uint16_t len = 4;
dflet 6:778b081f6a13 1277 uint16_t config_opt = WLAN_P2P_OPT_CHANNEL_N_REGS;
dflet 6:778b081f6a13 1278 uint8_t channel_n_regs[4];
dflet 6:778b081f6a13 1279 sl_WlanGet(SL_WLAN_CFG_P2P_PARAM_ID, &config_opt, &len, (uint8_t* )channel_n_regs);
dflet 6:778b081f6a13 1280 listen_channel = channel_n_regs[0];
dflet 6:778b081f6a13 1281 listen_reg = channel_n_regs[1];
dflet 6:778b081f6a13 1282 oper_channel = channel_n_regs[2];
dflet 6:778b081f6a13 1283 oper_reg = channel_n_regs[3];
dflet 6:778b081f6a13 1284 \endcode
dflet 6:778b081f6a13 1285 */
dflet 6:778b081f6a13 1286
dflet 6:778b081f6a13 1287 #if _SL_INCLUDE_FUNC(sl_WlanGet)
dflet 6:778b081f6a13 1288 int16_t sl_WlanGet(const uint16_t ConfigId, uint16_t *pConfigOpt,uint16_t *pConfigLen, uint8_t *pValues);
dflet 6:778b081f6a13 1289 #endif
dflet 6:778b081f6a13 1290
dflet 6:778b081f6a13 1291 private:
dflet 6:778b081f6a13 1292
dflet 6:778b081f6a13 1293 cc3100_driver &_driver;
dflet 6:778b081f6a13 1294 cc3100_wlan_rx_filters &_wlan_filters;
dflet 6:778b081f6a13 1295
dflet 6:778b081f6a13 1296 /*!
dflet 6:778b081f6a13 1297
dflet 6:778b081f6a13 1298 Close the Doxygen group.
dflet 6:778b081f6a13 1299 @}
dflet 6:778b081f6a13 1300
dflet 6:778b081f6a13 1301 */
dflet 6:778b081f6a13 1302
dflet 6:778b081f6a13 1303 };//class
dflet 6:778b081f6a13 1304
dflet 6:778b081f6a13 1305 }//namespace mbed_cc3100
dflet 6:778b081f6a13 1306
dflet 6:778b081f6a13 1307 #endif /* __WLAN_H__ */
dflet 6:778b081f6a13 1308
dflet 6:778b081f6a13 1309