TI's CC3100. A test demo with very little testing done!

Dependencies:   mbed

Fork of cc3100_Test_Demo2 by 高 杨

Committer:
dflet
Date:
Tue Feb 10 12:09:29 2015 +0000
Revision:
0:e89ba455dbcf
For test only! Not much has been tested, but the 2 demo apps run ok. Alot more work needs to be done!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:e89ba455dbcf 1 /*
dflet 0:e89ba455dbcf 2 * wlan.c - CC31xx/CC32xx Host Driver Implementation
dflet 0:e89ba455dbcf 3 *
dflet 0:e89ba455dbcf 4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 0:e89ba455dbcf 5 *
dflet 0:e89ba455dbcf 6 *
dflet 0:e89ba455dbcf 7 * Redistribution and use in source and binary forms, with or without
dflet 0:e89ba455dbcf 8 * modification, are permitted provided that the following conditions
dflet 0:e89ba455dbcf 9 * are met:
dflet 0:e89ba455dbcf 10 *
dflet 0:e89ba455dbcf 11 * Redistributions of source code must retain the above copyright
dflet 0:e89ba455dbcf 12 * notice, this list of conditions and the following disclaimer.
dflet 0:e89ba455dbcf 13 *
dflet 0:e89ba455dbcf 14 * Redistributions in binary form must reproduce the above copyright
dflet 0:e89ba455dbcf 15 * notice, this list of conditions and the following disclaimer in the
dflet 0:e89ba455dbcf 16 * documentation and/or other materials provided with the
dflet 0:e89ba455dbcf 17 * distribution.
dflet 0:e89ba455dbcf 18 *
dflet 0:e89ba455dbcf 19 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 0:e89ba455dbcf 20 * its contributors may be used to endorse or promote products derived
dflet 0:e89ba455dbcf 21 * from this software without specific prior written permission.
dflet 0:e89ba455dbcf 22 *
dflet 0:e89ba455dbcf 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 0:e89ba455dbcf 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 0:e89ba455dbcf 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 0:e89ba455dbcf 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 0:e89ba455dbcf 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 0:e89ba455dbcf 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 0:e89ba455dbcf 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 0:e89ba455dbcf 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 0:e89ba455dbcf 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 0:e89ba455dbcf 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 0:e89ba455dbcf 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 0:e89ba455dbcf 34 *
dflet 0:e89ba455dbcf 35 */
dflet 0:e89ba455dbcf 36
dflet 0:e89ba455dbcf 37
dflet 0:e89ba455dbcf 38
dflet 0:e89ba455dbcf 39 /*****************************************************************************/
dflet 0:e89ba455dbcf 40 /* Include files */
dflet 0:e89ba455dbcf 41 /*****************************************************************************/
dflet 0:e89ba455dbcf 42 #include "cc3100_simplelink.h"
dflet 0:e89ba455dbcf 43 #include "cc3100_protocol.h"
dflet 0:e89ba455dbcf 44 #include "cc3100_driver.h"
dflet 0:e89ba455dbcf 45
dflet 0:e89ba455dbcf 46 #include "cc3100_wlan.h"
dflet 0:e89ba455dbcf 47 #include "cc3100_wlan_rx_filters.h"
dflet 0:e89ba455dbcf 48
dflet 0:e89ba455dbcf 49 /*****************************************************************************/
dflet 0:e89ba455dbcf 50 /* Macro declarations */
dflet 0:e89ba455dbcf 51 /*****************************************************************************/
dflet 0:e89ba455dbcf 52 #define MAX_SSID_LEN (32)
dflet 0:e89ba455dbcf 53 #define MAX_KEY_LEN (63)
dflet 0:e89ba455dbcf 54 #define MAX_USER_LEN (32)
dflet 0:e89ba455dbcf 55 #define MAX_ANON_USER_LEN (32)
dflet 0:e89ba455dbcf 56 #define MAX_SMART_CONFIG_KEY (16)
dflet 0:e89ba455dbcf 57
dflet 0:e89ba455dbcf 58 namespace mbed_cc3100 {
dflet 0:e89ba455dbcf 59
dflet 0:e89ba455dbcf 60 cc3100_wlan::cc3100_wlan(cc3100_driver &driver, cc3100_wlan_rx_filters &wlan_filters)
dflet 0:e89ba455dbcf 61 : _driver(driver), _wlan_filters(wlan_filters)
dflet 0:e89ba455dbcf 62 {
dflet 0:e89ba455dbcf 63
dflet 0:e89ba455dbcf 64 }
dflet 0:e89ba455dbcf 65
dflet 0:e89ba455dbcf 66 cc3100_wlan::~cc3100_wlan()
dflet 0:e89ba455dbcf 67 {
dflet 0:e89ba455dbcf 68
dflet 0:e89ba455dbcf 69 }
dflet 0:e89ba455dbcf 70
dflet 0:e89ba455dbcf 71 /*****************************************************************************
dflet 0:e89ba455dbcf 72 sl_WlanConnect
dflet 0:e89ba455dbcf 73 *****************************************************************************/
dflet 0:e89ba455dbcf 74 typedef struct {
dflet 0:e89ba455dbcf 75 _WlanConnectEapCommand_t Args;
dflet 0:e89ba455dbcf 76 int8_t Strings[MAX_SSID_LEN + MAX_KEY_LEN + MAX_USER_LEN + MAX_ANON_USER_LEN];
dflet 0:e89ba455dbcf 77 } _WlanConnectCmd_t;
dflet 0:e89ba455dbcf 78
dflet 0:e89ba455dbcf 79 typedef union {
dflet 0:e89ba455dbcf 80 _WlanConnectCmd_t Cmd;
dflet 0:e89ba455dbcf 81 _BasicResponse_t Rsp;
dflet 0:e89ba455dbcf 82 } _SlWlanConnectMsg_u;
dflet 0:e89ba455dbcf 83
dflet 0:e89ba455dbcf 84
dflet 0:e89ba455dbcf 85 #if _SL_INCLUDE_FUNC(sl_WlanConnect)
dflet 0:e89ba455dbcf 86 int16_t cc3100_wlan::sl_WlanConnect(signed char* pName, int16_t NameLen, uint8_t *pMacAddr, SlSecParams_t* pSecParams , SlSecParamsExt_t* pSecExtParams)
dflet 0:e89ba455dbcf 87 {
dflet 0:e89ba455dbcf 88 _SlWlanConnectMsg_u Msg = {0};
dflet 0:e89ba455dbcf 89 _SlCmdCtrl_t CmdCtrl = {0};
dflet 0:e89ba455dbcf 90
dflet 0:e89ba455dbcf 91 CmdCtrl.TxDescLen = 0;/* init */
dflet 0:e89ba455dbcf 92 CmdCtrl.RxDescLen = sizeof(_BasicResponse_t);
dflet 0:e89ba455dbcf 93
dflet 0:e89ba455dbcf 94 /* verify SSID length */
dflet 0:e89ba455dbcf 95 VERIFY_PROTOCOL(NameLen <= MAX_SSID_LEN);
dflet 0:e89ba455dbcf 96 /* update SSID length */
dflet 0:e89ba455dbcf 97 Msg.Cmd.Args.Common.SsidLen = (uint8_t)NameLen;
dflet 0:e89ba455dbcf 98 /* Profile with no security */
dflet 0:e89ba455dbcf 99 /* Enterprise security profile */
dflet 0:e89ba455dbcf 100 if (NULL != pSecExtParams) {
dflet 0:e89ba455dbcf 101 /* Update command opcode */
dflet 0:e89ba455dbcf 102 CmdCtrl.Opcode = SL_OPCODE_WLAN_WLANCONNECTEAPCOMMAND;
dflet 0:e89ba455dbcf 103 CmdCtrl.TxDescLen += sizeof(_WlanConnectEapCommand_t);
dflet 0:e89ba455dbcf 104 /* copy SSID */
dflet 0:e89ba455dbcf 105 memcpy(EAP_SSID_STRING(&Msg), pName, NameLen);
dflet 0:e89ba455dbcf 106 CmdCtrl.TxDescLen += NameLen;
dflet 0:e89ba455dbcf 107 /* Copy password if supplied */
dflet 0:e89ba455dbcf 108 if ((NULL != pSecParams) && (pSecParams->KeyLen > 0)) {
dflet 0:e89ba455dbcf 109 /* update security type */
dflet 0:e89ba455dbcf 110 Msg.Cmd.Args.Common.SecType = pSecParams->Type;
dflet 0:e89ba455dbcf 111 /* verify key length */
dflet 0:e89ba455dbcf 112 if (pSecParams->KeyLen > MAX_KEY_LEN) {
dflet 0:e89ba455dbcf 113 return SL_INVALPARAM;
dflet 0:e89ba455dbcf 114 }
dflet 0:e89ba455dbcf 115 /* update key length */
dflet 0:e89ba455dbcf 116 Msg.Cmd.Args.Common.PasswordLen = pSecParams->KeyLen;
dflet 0:e89ba455dbcf 117 ARG_CHECK_PTR(pSecParams->Key);
dflet 0:e89ba455dbcf 118 /* copy key */
dflet 0:e89ba455dbcf 119 memcpy(EAP_PASSWORD_STRING(&Msg), pSecParams->Key, pSecParams->KeyLen);
dflet 0:e89ba455dbcf 120 CmdCtrl.TxDescLen += pSecParams->KeyLen;
dflet 0:e89ba455dbcf 121 } else {
dflet 0:e89ba455dbcf 122 Msg.Cmd.Args.Common.PasswordLen = 0;
dflet 0:e89ba455dbcf 123 }
dflet 0:e89ba455dbcf 124 ARG_CHECK_PTR(pSecExtParams);
dflet 0:e89ba455dbcf 125 /* Update Eap bitmask */
dflet 0:e89ba455dbcf 126 Msg.Cmd.Args.EapBitmask = pSecExtParams->EapMethod;
dflet 0:e89ba455dbcf 127 /* Update Certificate file ID index - currently not supported */
dflet 0:e89ba455dbcf 128 Msg.Cmd.Args.CertIndex = pSecExtParams->CertIndex;
dflet 0:e89ba455dbcf 129 /* verify user length */
dflet 0:e89ba455dbcf 130 if (pSecExtParams->UserLen > MAX_USER_LEN) {
dflet 0:e89ba455dbcf 131 return SL_INVALPARAM;
dflet 0:e89ba455dbcf 132 }
dflet 0:e89ba455dbcf 133 Msg.Cmd.Args.UserLen = pSecExtParams->UserLen;
dflet 0:e89ba455dbcf 134 /* copy user name (identity) */
dflet 0:e89ba455dbcf 135 if(pSecExtParams->UserLen > 0) {
dflet 0:e89ba455dbcf 136 memcpy(EAP_USER_STRING(&Msg), pSecExtParams->User, pSecExtParams->UserLen);
dflet 0:e89ba455dbcf 137 CmdCtrl.TxDescLen += pSecExtParams->UserLen;
dflet 0:e89ba455dbcf 138 }
dflet 0:e89ba455dbcf 139 /* verify Anonymous user length */
dflet 0:e89ba455dbcf 140 if (pSecExtParams->AnonUserLen > MAX_ANON_USER_LEN) {
dflet 0:e89ba455dbcf 141 return SL_INVALPARAM;
dflet 0:e89ba455dbcf 142 }
dflet 0:e89ba455dbcf 143 Msg.Cmd.Args.AnonUserLen = pSecExtParams->AnonUserLen;
dflet 0:e89ba455dbcf 144 /* copy Anonymous user */
dflet 0:e89ba455dbcf 145 if(pSecExtParams->AnonUserLen > 0) {
dflet 0:e89ba455dbcf 146 memcpy(EAP_ANON_USER_STRING(&Msg), pSecExtParams->AnonUser, pSecExtParams->AnonUserLen);
dflet 0:e89ba455dbcf 147 CmdCtrl.TxDescLen += pSecExtParams->AnonUserLen;
dflet 0:e89ba455dbcf 148 }
dflet 0:e89ba455dbcf 149
dflet 0:e89ba455dbcf 150 }
dflet 0:e89ba455dbcf 151
dflet 0:e89ba455dbcf 152 /* Regular or open security profile */
dflet 0:e89ba455dbcf 153 else {
dflet 0:e89ba455dbcf 154 /* Update command opcode */
dflet 0:e89ba455dbcf 155 CmdCtrl.Opcode = SL_OPCODE_WLAN_WLANCONNECTCOMMAND;
dflet 0:e89ba455dbcf 156 CmdCtrl.TxDescLen += sizeof(_WlanConnectCommon_t);
dflet 0:e89ba455dbcf 157 /* copy SSID */
dflet 0:e89ba455dbcf 158 memcpy(SSID_STRING(&Msg), pName, NameLen);
dflet 0:e89ba455dbcf 159 CmdCtrl.TxDescLen += NameLen;
dflet 0:e89ba455dbcf 160 /* Copy password if supplied */
dflet 0:e89ba455dbcf 161 if( NULL != pSecParams ) {
dflet 0:e89ba455dbcf 162 /* update security type */
dflet 0:e89ba455dbcf 163 Msg.Cmd.Args.Common.SecType = pSecParams->Type;
dflet 0:e89ba455dbcf 164 /* verify key length is valid */
dflet 0:e89ba455dbcf 165 if (pSecParams->KeyLen > MAX_KEY_LEN) {
dflet 0:e89ba455dbcf 166 return SL_INVALPARAM;
dflet 0:e89ba455dbcf 167 }
dflet 0:e89ba455dbcf 168 /* update key length */
dflet 0:e89ba455dbcf 169 Msg.Cmd.Args.Common.PasswordLen = pSecParams->KeyLen;
dflet 0:e89ba455dbcf 170 CmdCtrl.TxDescLen += pSecParams->KeyLen;
dflet 0:e89ba455dbcf 171 /* copy key (could be no key in case of WPS pin) */
dflet 0:e89ba455dbcf 172 if( NULL != pSecParams->Key ) {
dflet 0:e89ba455dbcf 173 memcpy(PASSWORD_STRING(&Msg), pSecParams->Key, pSecParams->KeyLen);
dflet 0:e89ba455dbcf 174 }
dflet 0:e89ba455dbcf 175 }
dflet 0:e89ba455dbcf 176 /* Profile with no security */
dflet 0:e89ba455dbcf 177 else {
dflet 0:e89ba455dbcf 178 Msg.Cmd.Args.Common.PasswordLen = 0;
dflet 0:e89ba455dbcf 179 Msg.Cmd.Args.Common.SecType = SL_SEC_TYPE_OPEN;
dflet 0:e89ba455dbcf 180 }
dflet 0:e89ba455dbcf 181 }
dflet 0:e89ba455dbcf 182 /* If BSSID is not null, copy to buffer, otherwise set to 0 */
dflet 0:e89ba455dbcf 183 if(NULL != pMacAddr) {
dflet 0:e89ba455dbcf 184 memcpy(Msg.Cmd.Args.Common.Bssid, pMacAddr, sizeof(Msg.Cmd.Args.Common.Bssid));
dflet 0:e89ba455dbcf 185 } else {
dflet 0:e89ba455dbcf 186 memset(Msg.Cmd.Args.Common.Bssid, 0, sizeof(Msg.Cmd.Args.Common.Bssid));
dflet 0:e89ba455dbcf 187 }
dflet 0:e89ba455dbcf 188
dflet 0:e89ba455dbcf 189 VERIFY_RET_OK ( _driver._SlDrvCmdOp(&CmdCtrl, &Msg, NULL));
dflet 0:e89ba455dbcf 190 return (int16_t)Msg.Rsp.status;
dflet 0:e89ba455dbcf 191 }
dflet 0:e89ba455dbcf 192 #endif
dflet 0:e89ba455dbcf 193
dflet 0:e89ba455dbcf 194 /*******************************************************************************/
dflet 0:e89ba455dbcf 195 /* sl_Disconnect */
dflet 0:e89ba455dbcf 196 /* ******************************************************************************/
dflet 0:e89ba455dbcf 197 #if _SL_INCLUDE_FUNC(sl_WlanDisconnect)
dflet 0:e89ba455dbcf 198 int16_t cc3100_wlan::sl_WlanDisconnect(void)
dflet 0:e89ba455dbcf 199 {
dflet 0:e89ba455dbcf 200 return _driver._SlDrvBasicCmd(SL_OPCODE_WLAN_WLANDISCONNECTCOMMAND);
dflet 0:e89ba455dbcf 201 }
dflet 0:e89ba455dbcf 202 #endif
dflet 0:e89ba455dbcf 203
dflet 0:e89ba455dbcf 204 /******************************************************************************/
dflet 0:e89ba455dbcf 205 /* sl_PolicySet */
dflet 0:e89ba455dbcf 206 /******************************************************************************/
dflet 0:e89ba455dbcf 207 typedef union {
dflet 0:e89ba455dbcf 208 _WlanPoliciySetGet_t Cmd;
dflet 0:e89ba455dbcf 209 _BasicResponse_t Rsp;
dflet 0:e89ba455dbcf 210 } _SlPolicyMsg_u;
dflet 0:e89ba455dbcf 211
dflet 0:e89ba455dbcf 212 const _SlCmdCtrl_t _SlPolicySetCmdCtrl = {
dflet 0:e89ba455dbcf 213 SL_OPCODE_WLAN_POLICYSETCOMMAND,
dflet 0:e89ba455dbcf 214 sizeof(_WlanPoliciySetGet_t),
dflet 0:e89ba455dbcf 215 sizeof(_BasicResponse_t)
dflet 0:e89ba455dbcf 216 };
dflet 0:e89ba455dbcf 217
dflet 0:e89ba455dbcf 218 #if _SL_INCLUDE_FUNC(sl_WlanPolicySet)
dflet 0:e89ba455dbcf 219 int16_t cc3100_wlan::sl_WlanPolicySet(uint8_t Type , const uint8_t Policy, uint8_t *pVal,uint8_t ValLen)
dflet 0:e89ba455dbcf 220 {
dflet 0:e89ba455dbcf 221
dflet 0:e89ba455dbcf 222 _SlPolicyMsg_u Msg;
dflet 0:e89ba455dbcf 223 _SlCmdExt_t CmdExt;
dflet 0:e89ba455dbcf 224
dflet 0:e89ba455dbcf 225 CmdExt.TxPayloadLen = ValLen;
dflet 0:e89ba455dbcf 226 CmdExt.RxPayloadLen = 0;
dflet 0:e89ba455dbcf 227 CmdExt.pTxPayload = (uint8_t *)pVal;
dflet 0:e89ba455dbcf 228 CmdExt.pRxPayload = NULL;
dflet 0:e89ba455dbcf 229
dflet 0:e89ba455dbcf 230
dflet 0:e89ba455dbcf 231 Msg.Cmd.PolicyType = Type;
dflet 0:e89ba455dbcf 232 Msg.Cmd.PolicyOption = Policy;
dflet 0:e89ba455dbcf 233 Msg.Cmd.PolicyOptionLen = ValLen;
dflet 0:e89ba455dbcf 234
dflet 0:e89ba455dbcf 235 VERIFY_RET_OK(_driver._SlDrvCmdOp((_SlCmdCtrl_t *)&_SlPolicySetCmdCtrl, &Msg, &CmdExt));
dflet 0:e89ba455dbcf 236
dflet 0:e89ba455dbcf 237 return (int16_t)Msg.Rsp.status;
dflet 0:e89ba455dbcf 238 }
dflet 0:e89ba455dbcf 239 #endif
dflet 0:e89ba455dbcf 240
dflet 0:e89ba455dbcf 241
dflet 0:e89ba455dbcf 242 /******************************************************************************/
dflet 0:e89ba455dbcf 243 /* sl_PolicyGet */
dflet 0:e89ba455dbcf 244 /******************************************************************************/
dflet 0:e89ba455dbcf 245 typedef union {
dflet 0:e89ba455dbcf 246 _WlanPoliciySetGet_t Cmd;
dflet 0:e89ba455dbcf 247 _WlanPoliciySetGet_t Rsp;
dflet 0:e89ba455dbcf 248 } _SlPolicyGetMsg_u;
dflet 0:e89ba455dbcf 249
dflet 0:e89ba455dbcf 250 const _SlCmdCtrl_t _SlPolicyGetCmdCtrl = {
dflet 0:e89ba455dbcf 251 SL_OPCODE_WLAN_POLICYGETCOMMAND,
dflet 0:e89ba455dbcf 252 sizeof(_WlanPoliciySetGet_t),
dflet 0:e89ba455dbcf 253 sizeof(_WlanPoliciySetGet_t)
dflet 0:e89ba455dbcf 254 };
dflet 0:e89ba455dbcf 255
dflet 0:e89ba455dbcf 256 #if _SL_INCLUDE_FUNC(sl_WlanPolicyGet)
dflet 0:e89ba455dbcf 257 int16_t cc3100_wlan::sl_WlanPolicyGet(uint8_t Type , uint8_t Policy,uint8_t *pVal,uint8_t *pValLen)
dflet 0:e89ba455dbcf 258 {
dflet 0:e89ba455dbcf 259 _SlPolicyGetMsg_u Msg;
dflet 0:e89ba455dbcf 260 _SlCmdExt_t CmdExt;
dflet 0:e89ba455dbcf 261
dflet 0:e89ba455dbcf 262 if (*pValLen == 0) {
dflet 0:e89ba455dbcf 263 return SL_EZEROLEN;
dflet 0:e89ba455dbcf 264 }
dflet 0:e89ba455dbcf 265 CmdExt.TxPayloadLen = 0;
dflet 0:e89ba455dbcf 266 CmdExt.RxPayloadLen = *pValLen;
dflet 0:e89ba455dbcf 267 CmdExt.pTxPayload = NULL;
dflet 0:e89ba455dbcf 268 CmdExt.pRxPayload = pVal;
dflet 0:e89ba455dbcf 269 CmdExt.ActualRxPayloadLen = 0;
dflet 0:e89ba455dbcf 270
dflet 0:e89ba455dbcf 271
dflet 0:e89ba455dbcf 272 Msg.Cmd.PolicyType = Type;
dflet 0:e89ba455dbcf 273 Msg.Cmd.PolicyOption = Policy;
dflet 0:e89ba455dbcf 274 VERIFY_RET_OK(_driver._SlDrvCmdOp((_SlCmdCtrl_t *)&_SlPolicyGetCmdCtrl, &Msg, &CmdExt));
dflet 0:e89ba455dbcf 275
dflet 0:e89ba455dbcf 276
dflet 0:e89ba455dbcf 277 if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) {
dflet 0:e89ba455dbcf 278 *pValLen = Msg.Rsp.PolicyOptionLen;
dflet 0:e89ba455dbcf 279 return SL_ESMALLBUF;
dflet 0:e89ba455dbcf 280 } else {
dflet 0:e89ba455dbcf 281 /* no pointer valus, fill the results into int8_t */
dflet 0:e89ba455dbcf 282 *pValLen = (uint8_t)CmdExt.ActualRxPayloadLen;
dflet 0:e89ba455dbcf 283 if( 0 == CmdExt.ActualRxPayloadLen ) {
dflet 0:e89ba455dbcf 284 *pValLen = 1;
dflet 0:e89ba455dbcf 285 pVal[0] = Msg.Rsp.PolicyOption;
dflet 0:e89ba455dbcf 286 }
dflet 0:e89ba455dbcf 287 }
dflet 0:e89ba455dbcf 288 return (int16_t)SL_OS_RET_CODE_OK;
dflet 0:e89ba455dbcf 289 }
dflet 0:e89ba455dbcf 290 #endif
dflet 0:e89ba455dbcf 291
dflet 0:e89ba455dbcf 292
dflet 0:e89ba455dbcf 293 /*******************************************************************************/
dflet 0:e89ba455dbcf 294 /* sl_ProfileAdd */
dflet 0:e89ba455dbcf 295 /*******************************************************************************/
dflet 0:e89ba455dbcf 296 typedef struct {
dflet 0:e89ba455dbcf 297 _WlanAddGetEapProfile_t Args;
dflet 0:e89ba455dbcf 298 int8_t Strings[MAX_SSID_LEN + MAX_KEY_LEN + MAX_USER_LEN + MAX_ANON_USER_LEN];
dflet 0:e89ba455dbcf 299 } _SlProfileParams_t;
dflet 0:e89ba455dbcf 300
dflet 0:e89ba455dbcf 301 typedef union {
dflet 0:e89ba455dbcf 302 _SlProfileParams_t Cmd;
dflet 0:e89ba455dbcf 303 _BasicResponse_t Rsp;
dflet 0:e89ba455dbcf 304 } _SlProfileAddMsg_u;
dflet 0:e89ba455dbcf 305
dflet 0:e89ba455dbcf 306
dflet 0:e89ba455dbcf 307
dflet 0:e89ba455dbcf 308 #if _SL_INCLUDE_FUNC(sl_WlanProfileAdd)
dflet 0:e89ba455dbcf 309 int16_t cc3100_wlan::sl_WlanProfileAdd(int8_t* pName, int16_t NameLen, uint8_t *pMacAddr, SlSecParams_t* pSecParams , SlSecParamsExt_t* pSecExtParams, uint32_t Priority, uint32_t Options)
dflet 0:e89ba455dbcf 310 {
dflet 0:e89ba455dbcf 311 _SlProfileAddMsg_u Msg;
dflet 0:e89ba455dbcf 312 _SlCmdCtrl_t CmdCtrl = {0};
dflet 0:e89ba455dbcf 313 CmdCtrl.TxDescLen = 0;/* init */
dflet 0:e89ba455dbcf 314 CmdCtrl.RxDescLen = sizeof(_BasicResponse_t);
dflet 0:e89ba455dbcf 315
dflet 0:e89ba455dbcf 316 /* update priority */
dflet 0:e89ba455dbcf 317 Msg.Cmd.Args.Common.Priority = (uint8_t)Priority;
dflet 0:e89ba455dbcf 318 /* verify SSID length */
dflet 0:e89ba455dbcf 319 VERIFY_PROTOCOL(NameLen <= MAX_SSID_LEN);
dflet 0:e89ba455dbcf 320 /* update SSID length */
dflet 0:e89ba455dbcf 321 Msg.Cmd.Args.Common.SsidLen = (uint8_t)NameLen;
dflet 0:e89ba455dbcf 322
dflet 0:e89ba455dbcf 323
dflet 0:e89ba455dbcf 324 /* Enterprise security profile */
dflet 0:e89ba455dbcf 325 if (NULL != pSecExtParams) {
dflet 0:e89ba455dbcf 326 /* Update command opcode */
dflet 0:e89ba455dbcf 327 CmdCtrl.Opcode = SL_OPCODE_WLAN_EAP_PROFILEADDCOMMAND;
dflet 0:e89ba455dbcf 328 CmdCtrl.TxDescLen += sizeof(_WlanAddGetEapProfile_t);
dflet 0:e89ba455dbcf 329
dflet 0:e89ba455dbcf 330 /* copy SSID */
dflet 0:e89ba455dbcf 331 memcpy(EAP_PROFILE_SSID_STRING(&Msg), pName, NameLen);
dflet 0:e89ba455dbcf 332 CmdCtrl.TxDescLen += NameLen;
dflet 0:e89ba455dbcf 333
dflet 0:e89ba455dbcf 334 /* Copy password if supplied */
dflet 0:e89ba455dbcf 335 if ((NULL != pSecParams) && (pSecParams->KeyLen > 0)) {
dflet 0:e89ba455dbcf 336 /* update security type */
dflet 0:e89ba455dbcf 337 Msg.Cmd.Args.Common.SecType = pSecParams->Type;
dflet 0:e89ba455dbcf 338
dflet 0:e89ba455dbcf 339 if( SL_SEC_TYPE_WEP == Msg.Cmd.Args.Common.SecType ) {
dflet 0:e89ba455dbcf 340 Msg.Cmd.Args.Common.WepKeyId = 0;
dflet 0:e89ba455dbcf 341 }
dflet 0:e89ba455dbcf 342
dflet 0:e89ba455dbcf 343 /* verify key length */
dflet 0:e89ba455dbcf 344 if (pSecParams->KeyLen > MAX_KEY_LEN) {
dflet 0:e89ba455dbcf 345 return SL_INVALPARAM;
dflet 0:e89ba455dbcf 346 }
dflet 0:e89ba455dbcf 347 VERIFY_PROTOCOL(pSecParams->KeyLen <= MAX_KEY_LEN);
dflet 0:e89ba455dbcf 348 /* update key length */
dflet 0:e89ba455dbcf 349 Msg.Cmd.Args.Common.PasswordLen = pSecParams->KeyLen;
dflet 0:e89ba455dbcf 350 CmdCtrl.TxDescLen += pSecParams->KeyLen;
dflet 0:e89ba455dbcf 351 ARG_CHECK_PTR(pSecParams->Key);
dflet 0:e89ba455dbcf 352 /* copy key */
dflet 0:e89ba455dbcf 353 memcpy(EAP_PROFILE_PASSWORD_STRING(&Msg), pSecParams->Key, pSecParams->KeyLen);
dflet 0:e89ba455dbcf 354 } else {
dflet 0:e89ba455dbcf 355 Msg.Cmd.Args.Common.PasswordLen = 0;
dflet 0:e89ba455dbcf 356 }
dflet 0:e89ba455dbcf 357
dflet 0:e89ba455dbcf 358 ARG_CHECK_PTR(pSecExtParams);
dflet 0:e89ba455dbcf 359 /* Update Eap bitmask */
dflet 0:e89ba455dbcf 360 Msg.Cmd.Args.EapBitmask = pSecExtParams->EapMethod;
dflet 0:e89ba455dbcf 361 /* Update Certificate file ID index - currently not supported */
dflet 0:e89ba455dbcf 362 Msg.Cmd.Args.CertIndex = pSecExtParams->CertIndex;
dflet 0:e89ba455dbcf 363 /* verify user length */
dflet 0:e89ba455dbcf 364 if (pSecExtParams->UserLen > MAX_USER_LEN) {
dflet 0:e89ba455dbcf 365 return SL_INVALPARAM;
dflet 0:e89ba455dbcf 366 }
dflet 0:e89ba455dbcf 367 Msg.Cmd.Args.UserLen = pSecExtParams->UserLen;
dflet 0:e89ba455dbcf 368 /* copy user name (identity) */
dflet 0:e89ba455dbcf 369 if(pSecExtParams->UserLen > 0) {
dflet 0:e89ba455dbcf 370 memcpy(EAP_PROFILE_USER_STRING(&Msg), pSecExtParams->User, pSecExtParams->UserLen);
dflet 0:e89ba455dbcf 371 CmdCtrl.TxDescLen += pSecExtParams->UserLen;
dflet 0:e89ba455dbcf 372 }
dflet 0:e89ba455dbcf 373
dflet 0:e89ba455dbcf 374 /* verify Anonymous user length (for tunneled) */
dflet 0:e89ba455dbcf 375 if (pSecExtParams->AnonUserLen > MAX_ANON_USER_LEN) {
dflet 0:e89ba455dbcf 376 return SL_INVALPARAM;
dflet 0:e89ba455dbcf 377 }
dflet 0:e89ba455dbcf 378 Msg.Cmd.Args.AnonUserLen = pSecExtParams->AnonUserLen;
dflet 0:e89ba455dbcf 379
dflet 0:e89ba455dbcf 380 /* copy Anonymous user */
dflet 0:e89ba455dbcf 381 if(pSecExtParams->AnonUserLen > 0) {
dflet 0:e89ba455dbcf 382 memcpy(EAP_PROFILE_ANON_USER_STRING(&Msg), pSecExtParams->AnonUser, pSecExtParams->AnonUserLen);
dflet 0:e89ba455dbcf 383 CmdCtrl.TxDescLen += pSecExtParams->AnonUserLen;
dflet 0:e89ba455dbcf 384 }
dflet 0:e89ba455dbcf 385
dflet 0:e89ba455dbcf 386 }
dflet 0:e89ba455dbcf 387 /* Regular or open security profile */
dflet 0:e89ba455dbcf 388 else {
dflet 0:e89ba455dbcf 389 /* Update command opcode */
dflet 0:e89ba455dbcf 390 CmdCtrl.Opcode = SL_OPCODE_WLAN_PROFILEADDCOMMAND;
dflet 0:e89ba455dbcf 391 /* update commnad length */
dflet 0:e89ba455dbcf 392 CmdCtrl.TxDescLen += sizeof(_WlanAddGetProfile_t);
dflet 0:e89ba455dbcf 393
dflet 0:e89ba455dbcf 394 if (NULL != pName) {
dflet 0:e89ba455dbcf 395 /* copy SSID */
dflet 0:e89ba455dbcf 396 memcpy(PROFILE_SSID_STRING(&Msg), pName, NameLen);
dflet 0:e89ba455dbcf 397 CmdCtrl.TxDescLen += NameLen;
dflet 0:e89ba455dbcf 398 }
dflet 0:e89ba455dbcf 399
dflet 0:e89ba455dbcf 400 /* Copy password if supplied */
dflet 0:e89ba455dbcf 401 if( NULL != pSecParams ) {
dflet 0:e89ba455dbcf 402 /* update security type */
dflet 0:e89ba455dbcf 403 Msg.Cmd.Args.Common.SecType = pSecParams->Type;
dflet 0:e89ba455dbcf 404
dflet 0:e89ba455dbcf 405 if( SL_SEC_TYPE_WEP == Msg.Cmd.Args.Common.SecType ) {
dflet 0:e89ba455dbcf 406 Msg.Cmd.Args.Common.WepKeyId = 0;
dflet 0:e89ba455dbcf 407 }
dflet 0:e89ba455dbcf 408
dflet 0:e89ba455dbcf 409 /* verify key length */
dflet 0:e89ba455dbcf 410 if (pSecParams->KeyLen > MAX_KEY_LEN) {
dflet 0:e89ba455dbcf 411 return SL_INVALPARAM;
dflet 0:e89ba455dbcf 412 }
dflet 0:e89ba455dbcf 413 /* update key length */
dflet 0:e89ba455dbcf 414 Msg.Cmd.Args.Common.PasswordLen = pSecParams->KeyLen;
dflet 0:e89ba455dbcf 415 CmdCtrl.TxDescLen += pSecParams->KeyLen;
dflet 0:e89ba455dbcf 416 /* copy key (could be no key in case of WPS pin) */
dflet 0:e89ba455dbcf 417 if( NULL != pSecParams->Key ) {
dflet 0:e89ba455dbcf 418 memcpy(PROFILE_PASSWORD_STRING(&Msg), pSecParams->Key, pSecParams->KeyLen);
dflet 0:e89ba455dbcf 419 }
dflet 0:e89ba455dbcf 420 } else {
dflet 0:e89ba455dbcf 421 Msg.Cmd.Args.Common.SecType = SL_SEC_TYPE_OPEN;
dflet 0:e89ba455dbcf 422 Msg.Cmd.Args.Common.PasswordLen = 0;
dflet 0:e89ba455dbcf 423 }
dflet 0:e89ba455dbcf 424
dflet 0:e89ba455dbcf 425 }
dflet 0:e89ba455dbcf 426
dflet 0:e89ba455dbcf 427
dflet 0:e89ba455dbcf 428 /* If BSSID is not null, copy to buffer, otherwise set to 0 */
dflet 0:e89ba455dbcf 429 if(NULL != pMacAddr) {
dflet 0:e89ba455dbcf 430 memcpy(Msg.Cmd.Args.Common.Bssid, pMacAddr, sizeof(Msg.Cmd.Args.Common.Bssid));
dflet 0:e89ba455dbcf 431 } else {
dflet 0:e89ba455dbcf 432 memset(Msg.Cmd.Args.Common.Bssid, 0, sizeof(Msg.Cmd.Args.Common.Bssid));
dflet 0:e89ba455dbcf 433 }
dflet 0:e89ba455dbcf 434
dflet 0:e89ba455dbcf 435 VERIFY_RET_OK(_driver._SlDrvCmdOp(&CmdCtrl, &Msg, NULL));
dflet 0:e89ba455dbcf 436
dflet 0:e89ba455dbcf 437 return (int16_t)Msg.Rsp.status;
dflet 0:e89ba455dbcf 438 }
dflet 0:e89ba455dbcf 439 #endif
dflet 0:e89ba455dbcf 440
dflet 0:e89ba455dbcf 441 /*******************************************************************************/
dflet 0:e89ba455dbcf 442 /* sl_ProfileGet */
dflet 0:e89ba455dbcf 443 /*******************************************************************************/
dflet 0:e89ba455dbcf 444 typedef union {
dflet 0:e89ba455dbcf 445 _WlanProfileDelGetCommand_t Cmd;
dflet 0:e89ba455dbcf 446 _SlProfileParams_t Rsp;
dflet 0:e89ba455dbcf 447 } _SlProfileGetMsg_u;
dflet 0:e89ba455dbcf 448
dflet 0:e89ba455dbcf 449 const _SlCmdCtrl_t _SlProfileGetCmdCtrl = {
dflet 0:e89ba455dbcf 450 SL_OPCODE_WLAN_PROFILEGETCOMMAND,
dflet 0:e89ba455dbcf 451 sizeof(_WlanProfileDelGetCommand_t),
dflet 0:e89ba455dbcf 452 sizeof(_SlProfileParams_t)
dflet 0:e89ba455dbcf 453 };
dflet 0:e89ba455dbcf 454
dflet 0:e89ba455dbcf 455 #if _SL_INCLUDE_FUNC(sl_WlanProfileGet)
dflet 0:e89ba455dbcf 456 int16_t cc3100_wlan::sl_WlanProfileGet(int16_t Index,int8_t* pName, int16_t *pNameLen, uint8_t *pMacAddr, SlSecParams_t* pSecParams, SlGetSecParamsExt_t* pEntParams, uint32_t *pPriority)
dflet 0:e89ba455dbcf 457 {
dflet 0:e89ba455dbcf 458 _SlProfileGetMsg_u Msg;
dflet 0:e89ba455dbcf 459 Msg.Cmd.index = (uint8_t)Index;
dflet 0:e89ba455dbcf 460
dflet 0:e89ba455dbcf 461 VERIFY_RET_OK(_driver._SlDrvCmdOp((_SlCmdCtrl_t *)&_SlProfileGetCmdCtrl, &Msg, NULL));
dflet 0:e89ba455dbcf 462
dflet 0:e89ba455dbcf 463 pSecParams->Type = Msg.Rsp.Args.Common.SecType;
dflet 0:e89ba455dbcf 464 /* since password is not transferred in getprofile, password length should always be zero */
dflet 0:e89ba455dbcf 465 pSecParams->KeyLen = Msg.Rsp.Args.Common.PasswordLen;
dflet 0:e89ba455dbcf 466 if (NULL != pEntParams) {
dflet 0:e89ba455dbcf 467 pEntParams->UserLen = Msg.Rsp.Args.UserLen;
dflet 0:e89ba455dbcf 468 /* copy user name */
dflet 0:e89ba455dbcf 469 if (pEntParams->UserLen > 0) {
dflet 0:e89ba455dbcf 470 memcpy(pEntParams->User, EAP_PROFILE_USER_STRING(&Msg), pEntParams->UserLen);
dflet 0:e89ba455dbcf 471 }
dflet 0:e89ba455dbcf 472 pEntParams->AnonUserLen = Msg.Rsp.Args.AnonUserLen;
dflet 0:e89ba455dbcf 473 /* copy anonymous user name */
dflet 0:e89ba455dbcf 474 if (pEntParams->AnonUserLen > 0) {
dflet 0:e89ba455dbcf 475 memcpy(pEntParams->AnonUser, EAP_PROFILE_ANON_USER_STRING(&Msg), pEntParams->AnonUserLen);
dflet 0:e89ba455dbcf 476 }
dflet 0:e89ba455dbcf 477 }
dflet 0:e89ba455dbcf 478
dflet 0:e89ba455dbcf 479 *pNameLen = Msg.Rsp.Args.Common.SsidLen;
dflet 0:e89ba455dbcf 480 *pPriority = Msg.Rsp.Args.Common.Priority;
dflet 0:e89ba455dbcf 481
dflet 0:e89ba455dbcf 482 if (NULL != Msg.Rsp.Args.Common.Bssid) {
dflet 0:e89ba455dbcf 483 memcpy(pMacAddr, Msg.Rsp.Args.Common.Bssid, sizeof(Msg.Rsp.Args.Common.Bssid));
dflet 0:e89ba455dbcf 484 }
dflet 0:e89ba455dbcf 485
dflet 0:e89ba455dbcf 486 memcpy(pName, EAP_PROFILE_SSID_STRING(&Msg), *pNameLen);
dflet 0:e89ba455dbcf 487
dflet 0:e89ba455dbcf 488 return (int16_t)Msg.Rsp.Args.Common.SecType;
dflet 0:e89ba455dbcf 489
dflet 0:e89ba455dbcf 490 }
dflet 0:e89ba455dbcf 491 #endif
dflet 0:e89ba455dbcf 492
dflet 0:e89ba455dbcf 493 /*******************************************************************************/
dflet 0:e89ba455dbcf 494 /* sl_ProfileDel */
dflet 0:e89ba455dbcf 495 /*******************************************************************************/
dflet 0:e89ba455dbcf 496 typedef union {
dflet 0:e89ba455dbcf 497 _WlanProfileDelGetCommand_t Cmd;
dflet 0:e89ba455dbcf 498 _BasicResponse_t Rsp;
dflet 0:e89ba455dbcf 499 } _SlProfileDelMsg_u;
dflet 0:e89ba455dbcf 500
dflet 0:e89ba455dbcf 501 const _SlCmdCtrl_t _SlProfileDelCmdCtrl = {
dflet 0:e89ba455dbcf 502 SL_OPCODE_WLAN_PROFILEDELCOMMAND,
dflet 0:e89ba455dbcf 503 sizeof(_WlanProfileDelGetCommand_t),
dflet 0:e89ba455dbcf 504 sizeof(_BasicResponse_t)
dflet 0:e89ba455dbcf 505 };
dflet 0:e89ba455dbcf 506
dflet 0:e89ba455dbcf 507 #if _SL_INCLUDE_FUNC(sl_WlanProfileDel)
dflet 0:e89ba455dbcf 508 int16_t cc3100_wlan::sl_WlanProfileDel(int16_t Index)
dflet 0:e89ba455dbcf 509 {
dflet 0:e89ba455dbcf 510 _SlProfileDelMsg_u Msg;
dflet 0:e89ba455dbcf 511
dflet 0:e89ba455dbcf 512 Msg.Cmd.index = (uint8_t)Index;
dflet 0:e89ba455dbcf 513
dflet 0:e89ba455dbcf 514 VERIFY_RET_OK(_driver._SlDrvCmdOp((_SlCmdCtrl_t *)&_SlProfileDelCmdCtrl, &Msg, NULL));
dflet 0:e89ba455dbcf 515
dflet 0:e89ba455dbcf 516 return (int16_t)Msg.Rsp.status;
dflet 0:e89ba455dbcf 517 }
dflet 0:e89ba455dbcf 518 #endif
dflet 0:e89ba455dbcf 519
dflet 0:e89ba455dbcf 520 /******************************************************************************/
dflet 0:e89ba455dbcf 521 /* sl_WlanGetNetworkList */
dflet 0:e89ba455dbcf 522 /******************************************************************************/
dflet 0:e89ba455dbcf 523 typedef union {
dflet 0:e89ba455dbcf 524 _WlanGetNetworkListCommand_t Cmd;
dflet 0:e89ba455dbcf 525 _WlanGetNetworkListResponse_t Rsp;
dflet 0:e89ba455dbcf 526 } _SlWlanGetNetworkListMsg_u;
dflet 0:e89ba455dbcf 527
dflet 0:e89ba455dbcf 528 const _SlCmdCtrl_t _SlWlanGetNetworkListCtrl = {
dflet 0:e89ba455dbcf 529 SL_OPCODE_WLAN_SCANRESULTSGETCOMMAND,
dflet 0:e89ba455dbcf 530 sizeof(_WlanGetNetworkListCommand_t),
dflet 0:e89ba455dbcf 531 sizeof(_WlanGetNetworkListResponse_t)
dflet 0:e89ba455dbcf 532 };
dflet 0:e89ba455dbcf 533
dflet 0:e89ba455dbcf 534
dflet 0:e89ba455dbcf 535 #if _SL_INCLUDE_FUNC(sl_WlanGetNetworkList)
dflet 0:e89ba455dbcf 536 int16_t cc3100_wlan::sl_WlanGetNetworkList(uint8_t Index, uint8_t Count, Sl_WlanNetworkEntry_t *pEntries)
dflet 0:e89ba455dbcf 537 {
dflet 0:e89ba455dbcf 538 int16_t retVal = 0;
dflet 0:e89ba455dbcf 539 _SlWlanGetNetworkListMsg_u Msg;
dflet 0:e89ba455dbcf 540 _SlCmdExt_t CmdExt;
dflet 0:e89ba455dbcf 541
dflet 0:e89ba455dbcf 542 if (Count == 0) {
dflet 0:e89ba455dbcf 543 return SL_EZEROLEN;
dflet 0:e89ba455dbcf 544 }
dflet 0:e89ba455dbcf 545 CmdExt.TxPayloadLen = 0;
dflet 0:e89ba455dbcf 546 CmdExt.RxPayloadLen = sizeof(Sl_WlanNetworkEntry_t)*(Count);
dflet 0:e89ba455dbcf 547 CmdExt.pTxPayload = NULL;
dflet 0:e89ba455dbcf 548 CmdExt.pRxPayload = (uint8_t *)pEntries;
dflet 0:e89ba455dbcf 549
dflet 0:e89ba455dbcf 550 Msg.Cmd.index = Index;
dflet 0:e89ba455dbcf 551 Msg.Cmd.count = Count;
dflet 0:e89ba455dbcf 552
dflet 0:e89ba455dbcf 553 VERIFY_RET_OK(_driver._SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanGetNetworkListCtrl, &Msg, &CmdExt));
dflet 0:e89ba455dbcf 554 retVal = Msg.Rsp.status;
dflet 0:e89ba455dbcf 555
dflet 0:e89ba455dbcf 556 return (int16_t)retVal;
dflet 0:e89ba455dbcf 557 }
dflet 0:e89ba455dbcf 558 #endif
dflet 0:e89ba455dbcf 559
dflet 0:e89ba455dbcf 560 /*******************************************************************************/
dflet 0:e89ba455dbcf 561 /* sl_WlanRxStatStart */
dflet 0:e89ba455dbcf 562 /*******************************************************************************/
dflet 0:e89ba455dbcf 563 #if _SL_INCLUDE_FUNC(sl_WlanRxStatStart)
dflet 0:e89ba455dbcf 564 int16_t cc3100_wlan::sl_WlanRxStatStart(void)
dflet 0:e89ba455dbcf 565 {
dflet 0:e89ba455dbcf 566 return _driver._SlDrvBasicCmd(SL_OPCODE_WLAN_STARTRXSTATCOMMAND);
dflet 0:e89ba455dbcf 567 }
dflet 0:e89ba455dbcf 568 #endif
dflet 0:e89ba455dbcf 569
dflet 0:e89ba455dbcf 570 #if _SL_INCLUDE_FUNC(sl_WlanRxStatStop)
dflet 0:e89ba455dbcf 571 int16_t cc3100_wlan::sl_WlanRxStatStop(void)
dflet 0:e89ba455dbcf 572 {
dflet 0:e89ba455dbcf 573 return _driver._SlDrvBasicCmd(SL_OPCODE_WLAN_STOPRXSTATCOMMAND);
dflet 0:e89ba455dbcf 574 }
dflet 0:e89ba455dbcf 575 #endif
dflet 0:e89ba455dbcf 576
dflet 0:e89ba455dbcf 577 #if _SL_INCLUDE_FUNC(sl_WlanRxStatGet)
dflet 0:e89ba455dbcf 578 int16_t cc3100_wlan::sl_WlanRxStatGet(SlGetRxStatResponse_t *pRxStat,uint32_t Flags)
dflet 0:e89ba455dbcf 579 {
dflet 0:e89ba455dbcf 580 _SlCmdCtrl_t CmdCtrl = {SL_OPCODE_WLAN_GETRXSTATCOMMAND, 0, sizeof(SlGetRxStatResponse_t)};
dflet 0:e89ba455dbcf 581 memset(pRxStat,0,sizeof(SlGetRxStatResponse_t));
dflet 0:e89ba455dbcf 582 VERIFY_RET_OK(_driver._SlDrvCmdOp((_SlCmdCtrl_t *)&CmdCtrl, pRxStat, NULL));
dflet 0:e89ba455dbcf 583
dflet 0:e89ba455dbcf 584 return 0;
dflet 0:e89ba455dbcf 585 }
dflet 0:e89ba455dbcf 586 #endif
dflet 0:e89ba455dbcf 587
dflet 0:e89ba455dbcf 588
dflet 0:e89ba455dbcf 589
dflet 0:e89ba455dbcf 590 /******************************************************************************/
dflet 0:e89ba455dbcf 591 /* sl_WlanSmartConfigStop */
dflet 0:e89ba455dbcf 592 /******************************************************************************/
dflet 0:e89ba455dbcf 593 #if _SL_INCLUDE_FUNC(sl_WlanSmartConfigStop)
dflet 0:e89ba455dbcf 594 int16_t cc3100_wlan::sl_WlanSmartConfigStop(void)
dflet 0:e89ba455dbcf 595 {
dflet 0:e89ba455dbcf 596 return _driver._SlDrvBasicCmd(SL_OPCODE_WLAN_SMART_CONFIG_STOP_COMMAND);
dflet 0:e89ba455dbcf 597 }
dflet 0:e89ba455dbcf 598 #endif
dflet 0:e89ba455dbcf 599
dflet 0:e89ba455dbcf 600
dflet 0:e89ba455dbcf 601 /******************************************************************************/
dflet 0:e89ba455dbcf 602 /* sl_WlanSmartConfigStart */
dflet 0:e89ba455dbcf 603 /******************************************************************************/
dflet 0:e89ba455dbcf 604
dflet 0:e89ba455dbcf 605
dflet 0:e89ba455dbcf 606 typedef struct {
dflet 0:e89ba455dbcf 607 _WlanSmartConfigStartCommand_t Args;
dflet 0:e89ba455dbcf 608 int8_t Strings[3 * MAX_SMART_CONFIG_KEY]; /* public key + groupId1 key + groupId2 key */
dflet 0:e89ba455dbcf 609 } _SlSmartConfigStart_t;
dflet 0:e89ba455dbcf 610
dflet 0:e89ba455dbcf 611 typedef union {
dflet 0:e89ba455dbcf 612 _SlSmartConfigStart_t Cmd;
dflet 0:e89ba455dbcf 613 _BasicResponse_t Rsp;
dflet 0:e89ba455dbcf 614 } _SlSmartConfigStartMsg_u;
dflet 0:e89ba455dbcf 615
dflet 0:e89ba455dbcf 616 const _SlCmdCtrl_t _SlSmartConfigStartCmdCtrl = {
dflet 0:e89ba455dbcf 617 SL_OPCODE_WLAN_SMART_CONFIG_START_COMMAND,
dflet 0:e89ba455dbcf 618 sizeof(_SlSmartConfigStart_t),
dflet 0:e89ba455dbcf 619 sizeof(_BasicResponse_t)
dflet 0:e89ba455dbcf 620 };
dflet 0:e89ba455dbcf 621
dflet 0:e89ba455dbcf 622 #if _SL_INCLUDE_FUNC(sl_WlanSmartConfigStart)
dflet 0:e89ba455dbcf 623 int16_t cc3100_wlan::sl_WlanSmartConfigStart( const uint32_t groupIdBitmask,
dflet 0:e89ba455dbcf 624 const uint8_t cipher,
dflet 0:e89ba455dbcf 625 const uint8_t publicKeyLen,
dflet 0:e89ba455dbcf 626 const uint8_t group1KeyLen,
dflet 0:e89ba455dbcf 627 const uint8_t group2KeyLen,
dflet 0:e89ba455dbcf 628 const uint8_t* pPublicKey,
dflet 0:e89ba455dbcf 629 const uint8_t* pGroup1Key,
dflet 0:e89ba455dbcf 630 const uint8_t* pGroup2Key)
dflet 0:e89ba455dbcf 631 {
dflet 0:e89ba455dbcf 632 _SlSmartConfigStartMsg_u Msg;
dflet 0:e89ba455dbcf 633
dflet 0:e89ba455dbcf 634 Msg.Cmd.Args.groupIdBitmask = (uint8_t)groupIdBitmask;
dflet 0:e89ba455dbcf 635 Msg.Cmd.Args.cipher = (uint8_t)cipher;
dflet 0:e89ba455dbcf 636 Msg.Cmd.Args.publicKeyLen = (uint8_t)publicKeyLen;
dflet 0:e89ba455dbcf 637 Msg.Cmd.Args.group1KeyLen = (uint8_t)group1KeyLen;
dflet 0:e89ba455dbcf 638 Msg.Cmd.Args.group2KeyLen = (uint8_t)group2KeyLen;
dflet 0:e89ba455dbcf 639
dflet 0:e89ba455dbcf 640 /* copy keys (if exist) after command (one after another) */
dflet 0:e89ba455dbcf 641 memcpy(SMART_CONFIG_START_PUBLIC_KEY_STRING(&Msg), pPublicKey, publicKeyLen);
dflet 0:e89ba455dbcf 642 memcpy(SMART_CONFIG_START_GROUP1_KEY_STRING(&Msg), pGroup1Key, group1KeyLen);
dflet 0:e89ba455dbcf 643 memcpy(SMART_CONFIG_START_GROUP2_KEY_STRING(&Msg), pGroup2Key, group2KeyLen);
dflet 0:e89ba455dbcf 644
dflet 0:e89ba455dbcf 645 VERIFY_RET_OK(_driver._SlDrvCmdOp((_SlCmdCtrl_t *)&_SlSmartConfigStartCmdCtrl , &Msg, NULL));
dflet 0:e89ba455dbcf 646
dflet 0:e89ba455dbcf 647 return (int16_t)Msg.Rsp.status;
dflet 0:e89ba455dbcf 648
dflet 0:e89ba455dbcf 649
dflet 0:e89ba455dbcf 650 }
dflet 0:e89ba455dbcf 651 #endif
dflet 0:e89ba455dbcf 652
dflet 0:e89ba455dbcf 653 /*******************************************************************************/
dflet 0:e89ba455dbcf 654 /* sl_WlanSetMode */
dflet 0:e89ba455dbcf 655 /*******************************************************************************/
dflet 0:e89ba455dbcf 656 typedef union {
dflet 0:e89ba455dbcf 657 _WlanSetMode_t Cmd;
dflet 0:e89ba455dbcf 658 _BasicResponse_t Rsp;
dflet 0:e89ba455dbcf 659 } _SlwlanSetModeMsg_u;
dflet 0:e89ba455dbcf 660
dflet 0:e89ba455dbcf 661 const _SlCmdCtrl_t _SlWlanSetModeCmdCtrl = {
dflet 0:e89ba455dbcf 662 SL_OPCODE_WLAN_SET_MODE,
dflet 0:e89ba455dbcf 663 sizeof(_WlanSetMode_t),
dflet 0:e89ba455dbcf 664 sizeof(_BasicResponse_t)
dflet 0:e89ba455dbcf 665 };
dflet 0:e89ba455dbcf 666
dflet 0:e89ba455dbcf 667 /* possible values are:
dflet 0:e89ba455dbcf 668 WLAN_SET_STA_MODE = 1
dflet 0:e89ba455dbcf 669 WLAN_SET_AP_MODE = 2
dflet 0:e89ba455dbcf 670 WLAN_SET_P2P_MODE = 3 */
dflet 0:e89ba455dbcf 671
dflet 0:e89ba455dbcf 672 #if _SL_INCLUDE_FUNC(sl_WlanSetMode)
dflet 0:e89ba455dbcf 673 int16_t cc3100_wlan::sl_WlanSetMode(const uint8_t mode)
dflet 0:e89ba455dbcf 674 {
dflet 0:e89ba455dbcf 675 _SlwlanSetModeMsg_u Msg;
dflet 0:e89ba455dbcf 676
dflet 0:e89ba455dbcf 677 Msg.Cmd.mode = mode;
dflet 0:e89ba455dbcf 678
dflet 0:e89ba455dbcf 679 VERIFY_RET_OK(_driver._SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanSetModeCmdCtrl , &Msg, NULL));
dflet 0:e89ba455dbcf 680
dflet 0:e89ba455dbcf 681 return (int16_t)Msg.Rsp.status;
dflet 0:e89ba455dbcf 682
dflet 0:e89ba455dbcf 683 }
dflet 0:e89ba455dbcf 684 #endif
dflet 0:e89ba455dbcf 685
dflet 0:e89ba455dbcf 686 /*******************************************************************************/
dflet 0:e89ba455dbcf 687 /* sl_WlanSet */
dflet 0:e89ba455dbcf 688 /* ******************************************************************************/
dflet 0:e89ba455dbcf 689 typedef union {
dflet 0:e89ba455dbcf 690 _WlanCfgSetGet_t Cmd;
dflet 0:e89ba455dbcf 691 _BasicResponse_t Rsp;
dflet 0:e89ba455dbcf 692 } _SlWlanCfgSetMsg_u;
dflet 0:e89ba455dbcf 693
dflet 0:e89ba455dbcf 694 const _SlCmdCtrl_t _SlWlanCfgSetCmdCtrl = {
dflet 0:e89ba455dbcf 695 SL_OPCODE_WLAN_CFG_SET,
dflet 0:e89ba455dbcf 696 sizeof(_WlanCfgSetGet_t),
dflet 0:e89ba455dbcf 697 sizeof(_BasicResponse_t)
dflet 0:e89ba455dbcf 698 };
dflet 0:e89ba455dbcf 699
dflet 0:e89ba455dbcf 700
dflet 0:e89ba455dbcf 701 #if _SL_INCLUDE_FUNC(sl_WlanSet)
dflet 0:e89ba455dbcf 702 int16_t cc3100_wlan::sl_WlanSet(uint16_t ConfigId ,uint16_t ConfigOpt,uint16_t ConfigLen, uint8_t *pValues)
dflet 0:e89ba455dbcf 703 {
dflet 0:e89ba455dbcf 704 _SlWlanCfgSetMsg_u Msg;
dflet 0:e89ba455dbcf 705 _SlCmdExt_t CmdExt;
dflet 0:e89ba455dbcf 706
dflet 0:e89ba455dbcf 707 CmdExt.TxPayloadLen = (ConfigLen+3) & (~3);
dflet 0:e89ba455dbcf 708 CmdExt.RxPayloadLen = 0;
dflet 0:e89ba455dbcf 709 CmdExt.pTxPayload = (uint8_t *)pValues;
dflet 0:e89ba455dbcf 710 CmdExt.pRxPayload = NULL;
dflet 0:e89ba455dbcf 711
dflet 0:e89ba455dbcf 712
dflet 0:e89ba455dbcf 713 Msg.Cmd.ConfigId = ConfigId;
dflet 0:e89ba455dbcf 714 Msg.Cmd.ConfigLen = ConfigLen;
dflet 0:e89ba455dbcf 715 Msg.Cmd.ConfigOpt = ConfigOpt;
dflet 0:e89ba455dbcf 716
dflet 0:e89ba455dbcf 717 VERIFY_RET_OK(_driver._SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanCfgSetCmdCtrl, &Msg, &CmdExt));
dflet 0:e89ba455dbcf 718
dflet 0:e89ba455dbcf 719 return (int16_t)Msg.Rsp.status;
dflet 0:e89ba455dbcf 720 }
dflet 0:e89ba455dbcf 721 #endif
dflet 0:e89ba455dbcf 722
dflet 0:e89ba455dbcf 723
dflet 0:e89ba455dbcf 724 /******************************************************************************/
dflet 0:e89ba455dbcf 725 /* sl_WlanGet */
dflet 0:e89ba455dbcf 726 /******************************************************************************/
dflet 0:e89ba455dbcf 727 typedef union {
dflet 0:e89ba455dbcf 728 _WlanCfgSetGet_t Cmd;
dflet 0:e89ba455dbcf 729 _WlanCfgSetGet_t Rsp;
dflet 0:e89ba455dbcf 730 } _SlWlanCfgMsgGet_u;
dflet 0:e89ba455dbcf 731
dflet 0:e89ba455dbcf 732 const _SlCmdCtrl_t _SlWlanCfgGetCmdCtrl = {
dflet 0:e89ba455dbcf 733 SL_OPCODE_WLAN_CFG_GET,
dflet 0:e89ba455dbcf 734 sizeof(_WlanCfgSetGet_t),
dflet 0:e89ba455dbcf 735 sizeof(_WlanCfgSetGet_t)
dflet 0:e89ba455dbcf 736 };
dflet 0:e89ba455dbcf 737
dflet 0:e89ba455dbcf 738 #if _SL_INCLUDE_FUNC(sl_WlanGet)
dflet 0:e89ba455dbcf 739 int16_t cc3100_wlan::sl_WlanGet(uint16_t ConfigId, uint16_t *pConfigOpt,uint16_t *pConfigLen, uint8_t *pValues)
dflet 0:e89ba455dbcf 740 {
dflet 0:e89ba455dbcf 741 _SlWlanCfgMsgGet_u Msg;
dflet 0:e89ba455dbcf 742 _SlCmdExt_t CmdExt;
dflet 0:e89ba455dbcf 743
dflet 0:e89ba455dbcf 744 if (*pConfigLen == 0) {
dflet 0:e89ba455dbcf 745 return SL_EZEROLEN;
dflet 0:e89ba455dbcf 746 }
dflet 0:e89ba455dbcf 747 CmdExt.TxPayloadLen = 0;
dflet 0:e89ba455dbcf 748 CmdExt.RxPayloadLen = *pConfigLen;
dflet 0:e89ba455dbcf 749 CmdExt.pTxPayload = NULL;
dflet 0:e89ba455dbcf 750 CmdExt.pRxPayload = (uint8_t *)pValues;
dflet 0:e89ba455dbcf 751 CmdExt.ActualRxPayloadLen = 0;
dflet 0:e89ba455dbcf 752
dflet 0:e89ba455dbcf 753 Msg.Cmd.ConfigId = ConfigId;
dflet 0:e89ba455dbcf 754 if( pConfigOpt ) {
dflet 0:e89ba455dbcf 755 Msg.Cmd.ConfigOpt = (uint16_t)*pConfigOpt;
dflet 0:e89ba455dbcf 756 }
dflet 0:e89ba455dbcf 757 VERIFY_RET_OK(_driver._SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanCfgGetCmdCtrl, &Msg, &CmdExt));
dflet 0:e89ba455dbcf 758
dflet 0:e89ba455dbcf 759 if( pConfigOpt ) {
dflet 0:e89ba455dbcf 760 *pConfigOpt = (uint8_t)Msg.Rsp.ConfigOpt;
dflet 0:e89ba455dbcf 761 }
dflet 0:e89ba455dbcf 762 if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) {
dflet 0:e89ba455dbcf 763 *pConfigLen = (uint8_t)CmdExt.RxPayloadLen;
dflet 0:e89ba455dbcf 764 return SL_ESMALLBUF;
dflet 0:e89ba455dbcf 765 } else {
dflet 0:e89ba455dbcf 766 *pConfigLen = (uint8_t)CmdExt.ActualRxPayloadLen;
dflet 0:e89ba455dbcf 767 }
dflet 0:e89ba455dbcf 768
dflet 0:e89ba455dbcf 769
dflet 0:e89ba455dbcf 770 return (int16_t)Msg.Rsp.Status;
dflet 0:e89ba455dbcf 771 }
dflet 0:e89ba455dbcf 772 #endif
dflet 0:e89ba455dbcf 773
dflet 0:e89ba455dbcf 774 cc3100_wlan_rx_filters::cc3100_wlan_rx_filters(cc3100_driver &driver)
dflet 0:e89ba455dbcf 775 : _driver(driver)
dflet 0:e89ba455dbcf 776 {
dflet 0:e89ba455dbcf 777
dflet 0:e89ba455dbcf 778 }
dflet 0:e89ba455dbcf 779
dflet 0:e89ba455dbcf 780 cc3100_wlan_rx_filters::~cc3100_wlan_rx_filters()
dflet 0:e89ba455dbcf 781 {
dflet 0:e89ba455dbcf 782
dflet 0:e89ba455dbcf 783 }
dflet 0:e89ba455dbcf 784
dflet 0:e89ba455dbcf 785 /******************************************************************************/
dflet 0:e89ba455dbcf 786 /* RX filters message command response structures */
dflet 0:e89ba455dbcf 787 /******************************************************************************/
dflet 0:e89ba455dbcf 788
dflet 0:e89ba455dbcf 789 /* Set command */
dflet 0:e89ba455dbcf 790 typedef union {
dflet 0:e89ba455dbcf 791 _WlanRxFilterAddCommand_t Cmd;
dflet 0:e89ba455dbcf 792 _WlanRxFilterAddCommandReponse_t Rsp;
dflet 0:e89ba455dbcf 793 } _SlrxFilterAddMsg_u;
dflet 0:e89ba455dbcf 794
dflet 0:e89ba455dbcf 795 const _SlCmdCtrl_t _SlRxFilterAddtCmdCtrl = {
dflet 0:e89ba455dbcf 796 SL_OPCODE_WLAN_WLANRXFILTERADDCOMMAND,
dflet 0:e89ba455dbcf 797 sizeof(_WlanRxFilterAddCommand_t),
dflet 0:e89ba455dbcf 798 sizeof(_WlanRxFilterAddCommandReponse_t)
dflet 0:e89ba455dbcf 799 };
dflet 0:e89ba455dbcf 800
dflet 0:e89ba455dbcf 801
dflet 0:e89ba455dbcf 802 /* Set command */
dflet 0:e89ba455dbcf 803 typedef union _SlRxFilterSetMsg_u {
dflet 0:e89ba455dbcf 804 _WlanRxFilterSetCommand_t Cmd;
dflet 0:e89ba455dbcf 805 _WlanRxFilterSetCommandReponse_t Rsp;
dflet 0:e89ba455dbcf 806 } _SlRxFilterSetMsg_u;
dflet 0:e89ba455dbcf 807
dflet 0:e89ba455dbcf 808
dflet 0:e89ba455dbcf 809 const _SlCmdCtrl_t _SlRxFilterSetCmdCtrl = {
dflet 0:e89ba455dbcf 810 SL_OPCODE_WLAN_WLANRXFILTERSETCOMMAND,
dflet 0:e89ba455dbcf 811 sizeof(_WlanRxFilterSetCommand_t),
dflet 0:e89ba455dbcf 812 sizeof(_WlanRxFilterSetCommandReponse_t)
dflet 0:e89ba455dbcf 813 };
dflet 0:e89ba455dbcf 814
dflet 0:e89ba455dbcf 815 /* Get command */
dflet 0:e89ba455dbcf 816 typedef union _SlRxFilterGetMsg_u {
dflet 0:e89ba455dbcf 817 _WlanRxFilterGetCommand_t Cmd;
dflet 0:e89ba455dbcf 818 _WlanRxFilterGetCommandReponse_t Rsp;
dflet 0:e89ba455dbcf 819 } _SlRxFilterGetMsg_u;
dflet 0:e89ba455dbcf 820
dflet 0:e89ba455dbcf 821
dflet 0:e89ba455dbcf 822 const _SlCmdCtrl_t _SlRxFilterGetCmdCtrl = {
dflet 0:e89ba455dbcf 823 SL_OPCODE_WLAN_WLANRXFILTERGETCOMMAND,
dflet 0:e89ba455dbcf 824 sizeof(_WlanRxFilterGetCommand_t),
dflet 0:e89ba455dbcf 825 sizeof(_WlanRxFilterGetCommandReponse_t)
dflet 0:e89ba455dbcf 826 };
dflet 0:e89ba455dbcf 827
dflet 0:e89ba455dbcf 828
dflet 0:e89ba455dbcf 829 /*******************************************************************************/
dflet 0:e89ba455dbcf 830 /* RX filters */
dflet 0:e89ba455dbcf 831 /*******************************************************************************/
dflet 0:e89ba455dbcf 832
dflet 0:e89ba455dbcf 833 #if _SL_INCLUDE_FUNC(sl_WlanRxFilterAdd)
dflet 0:e89ba455dbcf 834 SlrxFilterID_t cc3100_wlan_rx_filters::sl_WlanRxFilterAdd( SlrxFilterRuleType_t RuleType,
dflet 0:e89ba455dbcf 835 SlrxFilterFlags_t FilterFlags,
dflet 0:e89ba455dbcf 836 const SlrxFilterRule_t* const Rule,
dflet 0:e89ba455dbcf 837 const SlrxFilterTrigger_t* const Trigger,
dflet 0:e89ba455dbcf 838 const SlrxFilterAction_t* const Action,
dflet 0:e89ba455dbcf 839 SlrxFilterID_t* pFilterId)
dflet 0:e89ba455dbcf 840 {
dflet 0:e89ba455dbcf 841
dflet 0:e89ba455dbcf 842
dflet 0:e89ba455dbcf 843 _SlrxFilterAddMsg_u Msg;
dflet 0:e89ba455dbcf 844 Msg.Cmd.RuleType = RuleType;
dflet 0:e89ba455dbcf 845 /* filterId is zero */
dflet 0:e89ba455dbcf 846 Msg.Cmd.FilterId = 0;
dflet 0:e89ba455dbcf 847 Msg.Cmd.FilterFlags = FilterFlags;
dflet 0:e89ba455dbcf 848 memcpy( &(Msg.Cmd.Rule), Rule, sizeof(SlrxFilterRule_t) );
dflet 0:e89ba455dbcf 849 memcpy( &(Msg.Cmd.Trigger), Trigger, sizeof(SlrxFilterTrigger_t) );
dflet 0:e89ba455dbcf 850 memcpy( &(Msg.Cmd.Action), Action, sizeof(SlrxFilterAction_t) );
dflet 0:e89ba455dbcf 851 VERIFY_RET_OK(_driver._SlDrvCmdOp((_SlCmdCtrl_t *)&_SlRxFilterAddtCmdCtrl, &Msg, NULL) );
dflet 0:e89ba455dbcf 852 *pFilterId = Msg.Rsp.FilterId;
dflet 0:e89ba455dbcf 853 return (int16_t)Msg.Rsp.Status;
dflet 0:e89ba455dbcf 854
dflet 0:e89ba455dbcf 855 }
dflet 0:e89ba455dbcf 856 #endif
dflet 0:e89ba455dbcf 857
dflet 0:e89ba455dbcf 858
dflet 0:e89ba455dbcf 859
dflet 0:e89ba455dbcf 860 /*******************************************************************************/
dflet 0:e89ba455dbcf 861 /* RX filters */
dflet 0:e89ba455dbcf 862 /*******************************************************************************/
dflet 0:e89ba455dbcf 863 #if _SL_INCLUDE_FUNC(sl_WlanRxFilterSet)
dflet 0:e89ba455dbcf 864 int16_t cc3100_wlan_rx_filters::sl_WlanRxFilterSet(const SLrxFilterOperation_t RxFilterOperation,
dflet 0:e89ba455dbcf 865 const uint8_t* const pInputBuffer,
dflet 0:e89ba455dbcf 866 uint16_t InputbufferLength)
dflet 0:e89ba455dbcf 867 {
dflet 0:e89ba455dbcf 868 _SlRxFilterSetMsg_u Msg;
dflet 0:e89ba455dbcf 869 _SlCmdExt_t CmdExt;
dflet 0:e89ba455dbcf 870
dflet 0:e89ba455dbcf 871 CmdExt.TxPayloadLen = InputbufferLength;
dflet 0:e89ba455dbcf 872 CmdExt.pTxPayload = (uint8_t *)pInputBuffer;
dflet 0:e89ba455dbcf 873 CmdExt.RxPayloadLen = 0;
dflet 0:e89ba455dbcf 874 CmdExt.pRxPayload = (uint8_t *)NULL;
dflet 0:e89ba455dbcf 875
dflet 0:e89ba455dbcf 876 Msg.Cmd.RxFilterOperation = RxFilterOperation;
dflet 0:e89ba455dbcf 877 Msg.Cmd.InputBufferLength = InputbufferLength;
dflet 0:e89ba455dbcf 878
dflet 0:e89ba455dbcf 879
dflet 0:e89ba455dbcf 880 VERIFY_RET_OK(_driver._SlDrvCmdOp((_SlCmdCtrl_t *)&_SlRxFilterSetCmdCtrl, &Msg, &CmdExt) );
dflet 0:e89ba455dbcf 881
dflet 0:e89ba455dbcf 882
dflet 0:e89ba455dbcf 883 return (int16_t)Msg.Rsp.Status;
dflet 0:e89ba455dbcf 884 }
dflet 0:e89ba455dbcf 885 #endif
dflet 0:e89ba455dbcf 886
dflet 0:e89ba455dbcf 887 /******************************************************************************/
dflet 0:e89ba455dbcf 888 /* RX filters */
dflet 0:e89ba455dbcf 889 /******************************************************************************/
dflet 0:e89ba455dbcf 890 #if _SL_INCLUDE_FUNC(sl_WlanRxFilterGet)
dflet 0:e89ba455dbcf 891 int16_t cc3100_wlan_rx_filters::sl_WlanRxFilterGet(const SLrxFilterOperation_t RxFilterOperation,
dflet 0:e89ba455dbcf 892 uint8_t* pOutputBuffer,
dflet 0:e89ba455dbcf 893 uint16_t OutputbufferLength)
dflet 0:e89ba455dbcf 894 {
dflet 0:e89ba455dbcf 895 _SlRxFilterGetMsg_u Msg;
dflet 0:e89ba455dbcf 896 _SlCmdExt_t CmdExt;
dflet 0:e89ba455dbcf 897
dflet 0:e89ba455dbcf 898 if (OutputbufferLength == 0) {
dflet 0:e89ba455dbcf 899 return SL_EZEROLEN;
dflet 0:e89ba455dbcf 900 }
dflet 0:e89ba455dbcf 901 CmdExt.TxPayloadLen = 0;
dflet 0:e89ba455dbcf 902 CmdExt.pTxPayload = NULL;
dflet 0:e89ba455dbcf 903 CmdExt.RxPayloadLen = OutputbufferLength;
dflet 0:e89ba455dbcf 904 CmdExt.pRxPayload = (uint8_t *)pOutputBuffer;
dflet 0:e89ba455dbcf 905 CmdExt.ActualRxPayloadLen = 0;
dflet 0:e89ba455dbcf 906
dflet 0:e89ba455dbcf 907 Msg.Cmd.RxFilterOperation = RxFilterOperation;
dflet 0:e89ba455dbcf 908 Msg.Cmd.OutputBufferLength = OutputbufferLength;
dflet 0:e89ba455dbcf 909
dflet 0:e89ba455dbcf 910
dflet 0:e89ba455dbcf 911 VERIFY_RET_OK(_driver._SlDrvCmdOp((_SlCmdCtrl_t *)&_SlRxFilterGetCmdCtrl, &Msg, &CmdExt) );
dflet 0:e89ba455dbcf 912
dflet 0:e89ba455dbcf 913 if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) {
dflet 0:e89ba455dbcf 914 return SL_ESMALLBUF;
dflet 0:e89ba455dbcf 915 }
dflet 0:e89ba455dbcf 916
dflet 0:e89ba455dbcf 917 return (int16_t)Msg.Rsp.Status;
dflet 0:e89ba455dbcf 918 }
dflet 0:e89ba455dbcf 919 #endif
dflet 0:e89ba455dbcf 920
dflet 0:e89ba455dbcf 921 }//namespace mbed_cc3100
dflet 0:e89ba455dbcf 922
dflet 0:e89ba455dbcf 923