DeepCover Embedded Security in IoT: Public-key Secured Data Paths
Dependencies: MaximInterface
The MAXREFDES155# is an internet-of-things (IoT) embedded-security reference design, built to authenticate and control a sensing node using elliptic-curve-based public-key cryptography with control and notification from a web server.
The hardware includes an ARM® mbed™ shield and attached sensor endpoint. The shield contains a DS2476 DeepCover® ECDSA/SHA-2 coprocessor, Wifi communication, LCD push-button controls, and status LEDs. The sensor endpoint is attached to the shield using a 300mm cable and contains a DS28C36 DeepCover ECDSA/SHA-2 authenticator, IR-thermal sensor, and aiming laser for the IR sensor. The MAXREFDES155# is equipped with a standard Arduino® form-factor shield connector for immediate testing using an mbed board such as the MAX32600MBED#. The combination of these two devices represent an IoT device. Communication to the web server is accomplished with the shield Wifi circuitry. Communication from the shield to the attached sensor module is accomplished over I2C . The sensor module represents an IoT endpoint that generates small data with a requirement for message authenticity/integrity and secure on/off operational control.
The design is hierarchical with each mbed platform and shield communicating data from the sensor node to a web server that maintains a centralized log and dispatches notifications as necessary. The simplicity of this design enables rapid integration into any star-topology IoT network to provide security with the low overhead and cost provided by the ECDSA-P256 asymmetric-key and SHA-256 symmetric-key algorithms.
More information about the MAXREFDES155# is available on the Maxim Integrated website.
xternal/simplelink/source/wlan.c@16:a004191a79ab, 2019-10-03 (annotated)
- Committer:
- IanBenzMaxim
- Date:
- Thu Oct 03 11:40:13 2019 -0500
- Revision:
- 16:a004191a79ab
- Parent:
- simplelink/source/wlan.c@0:33d4e66780c0
Updated MaximInterface to version 2.0. Updated mbed-os to version 5.5.7. Cleaned up code styling.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
IanBenzMaxim | 0:33d4e66780c0 | 1 | /* |
IanBenzMaxim | 0:33d4e66780c0 | 2 | * wlan.c - CC31xx/CC32xx Host Driver Implementation |
IanBenzMaxim | 0:33d4e66780c0 | 3 | * |
IanBenzMaxim | 0:33d4e66780c0 | 4 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ |
IanBenzMaxim | 0:33d4e66780c0 | 5 | * |
IanBenzMaxim | 0:33d4e66780c0 | 6 | * |
IanBenzMaxim | 0:33d4e66780c0 | 7 | * Redistribution and use in source and binary forms, with or without |
IanBenzMaxim | 0:33d4e66780c0 | 8 | * modification, are permitted provided that the following conditions |
IanBenzMaxim | 0:33d4e66780c0 | 9 | * are met: |
IanBenzMaxim | 0:33d4e66780c0 | 10 | * |
IanBenzMaxim | 0:33d4e66780c0 | 11 | * Redistributions of source code must retain the above copyright |
IanBenzMaxim | 0:33d4e66780c0 | 12 | * notice, this list of conditions and the following disclaimer. |
IanBenzMaxim | 0:33d4e66780c0 | 13 | * |
IanBenzMaxim | 0:33d4e66780c0 | 14 | * Redistributions in binary form must reproduce the above copyright |
IanBenzMaxim | 0:33d4e66780c0 | 15 | * notice, this list of conditions and the following disclaimer in the |
IanBenzMaxim | 0:33d4e66780c0 | 16 | * documentation and/or other materials provided with the |
IanBenzMaxim | 0:33d4e66780c0 | 17 | * distribution. |
IanBenzMaxim | 0:33d4e66780c0 | 18 | * |
IanBenzMaxim | 0:33d4e66780c0 | 19 | * Neither the name of Texas Instruments Incorporated nor the names of |
IanBenzMaxim | 0:33d4e66780c0 | 20 | * its contributors may be used to endorse or promote products derived |
IanBenzMaxim | 0:33d4e66780c0 | 21 | * from this software without specific prior written permission. |
IanBenzMaxim | 0:33d4e66780c0 | 22 | * |
IanBenzMaxim | 0:33d4e66780c0 | 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
IanBenzMaxim | 0:33d4e66780c0 | 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
IanBenzMaxim | 0:33d4e66780c0 | 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
IanBenzMaxim | 0:33d4e66780c0 | 26 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
IanBenzMaxim | 0:33d4e66780c0 | 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
IanBenzMaxim | 0:33d4e66780c0 | 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
IanBenzMaxim | 0:33d4e66780c0 | 29 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
IanBenzMaxim | 0:33d4e66780c0 | 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
IanBenzMaxim | 0:33d4e66780c0 | 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
IanBenzMaxim | 0:33d4e66780c0 | 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
IanBenzMaxim | 0:33d4e66780c0 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
IanBenzMaxim | 0:33d4e66780c0 | 34 | * |
IanBenzMaxim | 0:33d4e66780c0 | 35 | */ |
IanBenzMaxim | 0:33d4e66780c0 | 36 | |
IanBenzMaxim | 0:33d4e66780c0 | 37 | |
IanBenzMaxim | 0:33d4e66780c0 | 38 | |
IanBenzMaxim | 0:33d4e66780c0 | 39 | /*****************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 40 | /* Include files */ |
IanBenzMaxim | 0:33d4e66780c0 | 41 | /*****************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 42 | #include "simplelink.h" |
IanBenzMaxim | 0:33d4e66780c0 | 43 | #include "protocol.h" |
IanBenzMaxim | 0:33d4e66780c0 | 44 | #include "driver.h" |
IanBenzMaxim | 0:33d4e66780c0 | 45 | |
IanBenzMaxim | 0:33d4e66780c0 | 46 | /*****************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 47 | /* Macro declarations */ |
IanBenzMaxim | 0:33d4e66780c0 | 48 | /*****************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 49 | #define MAX_SSID_LEN (32) |
IanBenzMaxim | 0:33d4e66780c0 | 50 | #define MAX_KEY_LEN (63) |
IanBenzMaxim | 0:33d4e66780c0 | 51 | #define MAX_USER_LEN (32) |
IanBenzMaxim | 0:33d4e66780c0 | 52 | #define MAX_ANON_USER_LEN (32) |
IanBenzMaxim | 0:33d4e66780c0 | 53 | #define MAX_SMART_CONFIG_KEY (16) |
IanBenzMaxim | 0:33d4e66780c0 | 54 | |
IanBenzMaxim | 0:33d4e66780c0 | 55 | |
IanBenzMaxim | 0:33d4e66780c0 | 56 | /***************************************************************************** |
IanBenzMaxim | 0:33d4e66780c0 | 57 | sl_WlanConnect |
IanBenzMaxim | 0:33d4e66780c0 | 58 | *****************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 59 | typedef struct |
IanBenzMaxim | 0:33d4e66780c0 | 60 | { |
IanBenzMaxim | 0:33d4e66780c0 | 61 | _WlanConnectEapCommand_t Args; |
IanBenzMaxim | 0:33d4e66780c0 | 62 | _i8 Strings[MAX_SSID_LEN + MAX_KEY_LEN + MAX_USER_LEN + MAX_ANON_USER_LEN]; |
IanBenzMaxim | 0:33d4e66780c0 | 63 | }_WlanConnectCmd_t; |
IanBenzMaxim | 0:33d4e66780c0 | 64 | |
IanBenzMaxim | 0:33d4e66780c0 | 65 | typedef union |
IanBenzMaxim | 0:33d4e66780c0 | 66 | { |
IanBenzMaxim | 0:33d4e66780c0 | 67 | _WlanConnectCmd_t Cmd; |
IanBenzMaxim | 0:33d4e66780c0 | 68 | _BasicResponse_t Rsp; |
IanBenzMaxim | 0:33d4e66780c0 | 69 | }_SlWlanConnectMsg_u; |
IanBenzMaxim | 0:33d4e66780c0 | 70 | |
IanBenzMaxim | 0:33d4e66780c0 | 71 | |
IanBenzMaxim | 0:33d4e66780c0 | 72 | #if _SL_INCLUDE_FUNC(sl_WlanConnect) |
IanBenzMaxim | 0:33d4e66780c0 | 73 | _i16 sl_WlanConnect(const _i8* pName,const _i16 NameLen,const _u8 *pMacAddr,const SlSecParams_t* pSecParams ,const SlSecParamsExt_t* pSecExtParams) |
IanBenzMaxim | 0:33d4e66780c0 | 74 | { |
IanBenzMaxim | 0:33d4e66780c0 | 75 | _SlWlanConnectMsg_u Msg; |
IanBenzMaxim | 0:33d4e66780c0 | 76 | _SlCmdCtrl_t CmdCtrl = {0,0,0}; |
IanBenzMaxim | 0:33d4e66780c0 | 77 | |
IanBenzMaxim | 0:33d4e66780c0 | 78 | _SlDrvMemZero(&Msg, (_u16)sizeof(_SlWlanConnectMsg_u)); |
IanBenzMaxim | 0:33d4e66780c0 | 79 | |
IanBenzMaxim | 0:33d4e66780c0 | 80 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 81 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 82 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 83 | |
IanBenzMaxim | 0:33d4e66780c0 | 84 | CmdCtrl.TxDescLen = 0;/* init */ |
IanBenzMaxim | 0:33d4e66780c0 | 85 | CmdCtrl.RxDescLen = (_SlArgSize_t)sizeof(_BasicResponse_t); |
IanBenzMaxim | 0:33d4e66780c0 | 86 | |
IanBenzMaxim | 0:33d4e66780c0 | 87 | /* verify SSID length */ |
IanBenzMaxim | 0:33d4e66780c0 | 88 | VERIFY_PROTOCOL(NameLen <= MAX_SSID_LEN); |
IanBenzMaxim | 0:33d4e66780c0 | 89 | /* verify SSID is not NULL */ |
IanBenzMaxim | 0:33d4e66780c0 | 90 | if( NULL == pName ) |
IanBenzMaxim | 0:33d4e66780c0 | 91 | { |
IanBenzMaxim | 0:33d4e66780c0 | 92 | return SL_INVALPARAM; |
IanBenzMaxim | 0:33d4e66780c0 | 93 | } |
IanBenzMaxim | 0:33d4e66780c0 | 94 | /* update SSID length */ |
IanBenzMaxim | 0:33d4e66780c0 | 95 | Msg.Cmd.Args.Common.SsidLen = (_u8)NameLen; |
IanBenzMaxim | 0:33d4e66780c0 | 96 | |
IanBenzMaxim | 0:33d4e66780c0 | 97 | /* Profile with no security */ |
IanBenzMaxim | 0:33d4e66780c0 | 98 | /* Enterprise security profile */ |
IanBenzMaxim | 0:33d4e66780c0 | 99 | if (NULL != pSecExtParams) |
IanBenzMaxim | 0:33d4e66780c0 | 100 | { |
IanBenzMaxim | 0:33d4e66780c0 | 101 | /* Update command opcode */ |
IanBenzMaxim | 0:33d4e66780c0 | 102 | CmdCtrl.Opcode = SL_OPCODE_WLAN_WLANCONNECTEAPCOMMAND; |
IanBenzMaxim | 0:33d4e66780c0 | 103 | CmdCtrl.TxDescLen += sizeof(_WlanConnectEapCommand_t); |
IanBenzMaxim | 0:33d4e66780c0 | 104 | /* copy SSID */ |
IanBenzMaxim | 0:33d4e66780c0 | 105 | sl_Memcpy(EAP_SSID_STRING(&Msg), pName, NameLen); |
IanBenzMaxim | 0:33d4e66780c0 | 106 | CmdCtrl.TxDescLen += NameLen; |
IanBenzMaxim | 0:33d4e66780c0 | 107 | /* Copy password if supplied */ |
IanBenzMaxim | 0:33d4e66780c0 | 108 | if ((NULL != pSecParams) && (pSecParams->KeyLen > 0)) |
IanBenzMaxim | 0:33d4e66780c0 | 109 | { |
IanBenzMaxim | 0:33d4e66780c0 | 110 | /* update security type */ |
IanBenzMaxim | 0:33d4e66780c0 | 111 | Msg.Cmd.Args.Common.SecType = pSecParams->Type; |
IanBenzMaxim | 0:33d4e66780c0 | 112 | /* verify key length */ |
IanBenzMaxim | 0:33d4e66780c0 | 113 | if (pSecParams->KeyLen > MAX_KEY_LEN) |
IanBenzMaxim | 0:33d4e66780c0 | 114 | { |
IanBenzMaxim | 0:33d4e66780c0 | 115 | return SL_INVALPARAM; |
IanBenzMaxim | 0:33d4e66780c0 | 116 | } |
IanBenzMaxim | 0:33d4e66780c0 | 117 | /* update key length */ |
IanBenzMaxim | 0:33d4e66780c0 | 118 | Msg.Cmd.Args.Common.PasswordLen = pSecParams->KeyLen; |
IanBenzMaxim | 0:33d4e66780c0 | 119 | ARG_CHECK_PTR(pSecParams->Key); |
IanBenzMaxim | 0:33d4e66780c0 | 120 | /* copy key */ |
IanBenzMaxim | 0:33d4e66780c0 | 121 | sl_Memcpy(EAP_PASSWORD_STRING(&Msg), pSecParams->Key, pSecParams->KeyLen); |
IanBenzMaxim | 0:33d4e66780c0 | 122 | CmdCtrl.TxDescLen += pSecParams->KeyLen; |
IanBenzMaxim | 0:33d4e66780c0 | 123 | } |
IanBenzMaxim | 0:33d4e66780c0 | 124 | else |
IanBenzMaxim | 0:33d4e66780c0 | 125 | { |
IanBenzMaxim | 0:33d4e66780c0 | 126 | Msg.Cmd.Args.Common.PasswordLen = 0; |
IanBenzMaxim | 0:33d4e66780c0 | 127 | } |
IanBenzMaxim | 0:33d4e66780c0 | 128 | |
IanBenzMaxim | 0:33d4e66780c0 | 129 | ARG_CHECK_PTR(pSecExtParams); |
IanBenzMaxim | 0:33d4e66780c0 | 130 | /* Update Eap bitmask */ |
IanBenzMaxim | 0:33d4e66780c0 | 131 | Msg.Cmd.Args.EapBitmask = pSecExtParams->EapMethod; |
IanBenzMaxim | 0:33d4e66780c0 | 132 | /* Update Certificate file ID index - currently not supported */ |
IanBenzMaxim | 0:33d4e66780c0 | 133 | Msg.Cmd.Args.CertIndex = pSecExtParams->CertIndex; |
IanBenzMaxim | 0:33d4e66780c0 | 134 | /* verify user length */ |
IanBenzMaxim | 0:33d4e66780c0 | 135 | if (pSecExtParams->UserLen > MAX_USER_LEN) |
IanBenzMaxim | 0:33d4e66780c0 | 136 | { |
IanBenzMaxim | 0:33d4e66780c0 | 137 | return SL_INVALPARAM; |
IanBenzMaxim | 0:33d4e66780c0 | 138 | } |
IanBenzMaxim | 0:33d4e66780c0 | 139 | Msg.Cmd.Args.UserLen = pSecExtParams->UserLen; |
IanBenzMaxim | 0:33d4e66780c0 | 140 | /* copy user name (identity) */ |
IanBenzMaxim | 0:33d4e66780c0 | 141 | if(pSecExtParams->UserLen > 0) |
IanBenzMaxim | 0:33d4e66780c0 | 142 | { |
IanBenzMaxim | 0:33d4e66780c0 | 143 | sl_Memcpy(EAP_USER_STRING(&Msg), pSecExtParams->User, pSecExtParams->UserLen); |
IanBenzMaxim | 0:33d4e66780c0 | 144 | CmdCtrl.TxDescLen += pSecExtParams->UserLen; |
IanBenzMaxim | 0:33d4e66780c0 | 145 | } |
IanBenzMaxim | 0:33d4e66780c0 | 146 | /* verify Anonymous user length */ |
IanBenzMaxim | 0:33d4e66780c0 | 147 | if (pSecExtParams->AnonUserLen > MAX_ANON_USER_LEN) |
IanBenzMaxim | 0:33d4e66780c0 | 148 | { |
IanBenzMaxim | 0:33d4e66780c0 | 149 | return SL_INVALPARAM; |
IanBenzMaxim | 0:33d4e66780c0 | 150 | } |
IanBenzMaxim | 0:33d4e66780c0 | 151 | Msg.Cmd.Args.AnonUserLen = pSecExtParams->AnonUserLen; |
IanBenzMaxim | 0:33d4e66780c0 | 152 | /* copy Anonymous user */ |
IanBenzMaxim | 0:33d4e66780c0 | 153 | if(pSecExtParams->AnonUserLen > 0) |
IanBenzMaxim | 0:33d4e66780c0 | 154 | { |
IanBenzMaxim | 0:33d4e66780c0 | 155 | sl_Memcpy(EAP_ANON_USER_STRING(&Msg), pSecExtParams->AnonUser, pSecExtParams->AnonUserLen); |
IanBenzMaxim | 0:33d4e66780c0 | 156 | CmdCtrl.TxDescLen += pSecExtParams->AnonUserLen; |
IanBenzMaxim | 0:33d4e66780c0 | 157 | } |
IanBenzMaxim | 0:33d4e66780c0 | 158 | |
IanBenzMaxim | 0:33d4e66780c0 | 159 | } |
IanBenzMaxim | 0:33d4e66780c0 | 160 | |
IanBenzMaxim | 0:33d4e66780c0 | 161 | /* Regular or open security profile */ |
IanBenzMaxim | 0:33d4e66780c0 | 162 | else |
IanBenzMaxim | 0:33d4e66780c0 | 163 | { |
IanBenzMaxim | 0:33d4e66780c0 | 164 | /* Update command opcode */ |
IanBenzMaxim | 0:33d4e66780c0 | 165 | CmdCtrl.Opcode = SL_OPCODE_WLAN_WLANCONNECTCOMMAND; |
IanBenzMaxim | 0:33d4e66780c0 | 166 | CmdCtrl.TxDescLen += sizeof(_WlanConnectCommon_t); |
IanBenzMaxim | 0:33d4e66780c0 | 167 | /* copy SSID */ |
IanBenzMaxim | 0:33d4e66780c0 | 168 | sl_Memcpy(SSID_STRING(&Msg), pName, NameLen); |
IanBenzMaxim | 0:33d4e66780c0 | 169 | CmdCtrl.TxDescLen += NameLen; |
IanBenzMaxim | 0:33d4e66780c0 | 170 | /* Copy password if supplied */ |
IanBenzMaxim | 0:33d4e66780c0 | 171 | if( NULL != pSecParams ) |
IanBenzMaxim | 0:33d4e66780c0 | 172 | { |
IanBenzMaxim | 0:33d4e66780c0 | 173 | /* update security type */ |
IanBenzMaxim | 0:33d4e66780c0 | 174 | Msg.Cmd.Args.Common.SecType = pSecParams->Type; |
IanBenzMaxim | 0:33d4e66780c0 | 175 | /* verify key length is valid */ |
IanBenzMaxim | 0:33d4e66780c0 | 176 | if (pSecParams->KeyLen > MAX_KEY_LEN) |
IanBenzMaxim | 0:33d4e66780c0 | 177 | { |
IanBenzMaxim | 0:33d4e66780c0 | 178 | return SL_INVALPARAM; |
IanBenzMaxim | 0:33d4e66780c0 | 179 | } |
IanBenzMaxim | 0:33d4e66780c0 | 180 | /* update key length */ |
IanBenzMaxim | 0:33d4e66780c0 | 181 | Msg.Cmd.Args.Common.PasswordLen = pSecParams->KeyLen; |
IanBenzMaxim | 0:33d4e66780c0 | 182 | CmdCtrl.TxDescLen += pSecParams->KeyLen; |
IanBenzMaxim | 0:33d4e66780c0 | 183 | /* copy key (could be no key in case of WPS pin) */ |
IanBenzMaxim | 0:33d4e66780c0 | 184 | if( NULL != pSecParams->Key ) |
IanBenzMaxim | 0:33d4e66780c0 | 185 | { |
IanBenzMaxim | 0:33d4e66780c0 | 186 | sl_Memcpy(PASSWORD_STRING(&Msg), pSecParams->Key, pSecParams->KeyLen); |
IanBenzMaxim | 0:33d4e66780c0 | 187 | } |
IanBenzMaxim | 0:33d4e66780c0 | 188 | } |
IanBenzMaxim | 0:33d4e66780c0 | 189 | /* Profile with no security */ |
IanBenzMaxim | 0:33d4e66780c0 | 190 | else |
IanBenzMaxim | 0:33d4e66780c0 | 191 | { |
IanBenzMaxim | 0:33d4e66780c0 | 192 | Msg.Cmd.Args.Common.PasswordLen = 0; |
IanBenzMaxim | 0:33d4e66780c0 | 193 | Msg.Cmd.Args.Common.SecType = SL_SEC_TYPE_OPEN; |
IanBenzMaxim | 0:33d4e66780c0 | 194 | } |
IanBenzMaxim | 0:33d4e66780c0 | 195 | } |
IanBenzMaxim | 0:33d4e66780c0 | 196 | /* If BSSID is not null, copy to buffer, otherwise set to 0 */ |
IanBenzMaxim | 0:33d4e66780c0 | 197 | if(NULL != pMacAddr) |
IanBenzMaxim | 0:33d4e66780c0 | 198 | { |
IanBenzMaxim | 0:33d4e66780c0 | 199 | sl_Memcpy(Msg.Cmd.Args.Common.Bssid, pMacAddr, sizeof(Msg.Cmd.Args.Common.Bssid)); |
IanBenzMaxim | 0:33d4e66780c0 | 200 | } |
IanBenzMaxim | 0:33d4e66780c0 | 201 | else |
IanBenzMaxim | 0:33d4e66780c0 | 202 | { |
IanBenzMaxim | 0:33d4e66780c0 | 203 | _SlDrvMemZero(Msg.Cmd.Args.Common.Bssid, (_u16)sizeof(Msg.Cmd.Args.Common.Bssid)); |
IanBenzMaxim | 0:33d4e66780c0 | 204 | } |
IanBenzMaxim | 0:33d4e66780c0 | 205 | |
IanBenzMaxim | 0:33d4e66780c0 | 206 | |
IanBenzMaxim | 0:33d4e66780c0 | 207 | VERIFY_RET_OK ( _SlDrvCmdOp(&CmdCtrl, &Msg, NULL)); |
IanBenzMaxim | 0:33d4e66780c0 | 208 | |
IanBenzMaxim | 0:33d4e66780c0 | 209 | return (_i16)Msg.Rsp.status; |
IanBenzMaxim | 0:33d4e66780c0 | 210 | } |
IanBenzMaxim | 0:33d4e66780c0 | 211 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 212 | |
IanBenzMaxim | 0:33d4e66780c0 | 213 | /*******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 214 | /* sl_Disconnect */ |
IanBenzMaxim | 0:33d4e66780c0 | 215 | /* ******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 216 | #if _SL_INCLUDE_FUNC(sl_WlanDisconnect) |
IanBenzMaxim | 0:33d4e66780c0 | 217 | _i16 sl_WlanDisconnect(void) |
IanBenzMaxim | 0:33d4e66780c0 | 218 | { |
IanBenzMaxim | 0:33d4e66780c0 | 219 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 220 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 221 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 222 | |
IanBenzMaxim | 0:33d4e66780c0 | 223 | return _SlDrvBasicCmd(SL_OPCODE_WLAN_WLANDISCONNECTCOMMAND); |
IanBenzMaxim | 0:33d4e66780c0 | 224 | } |
IanBenzMaxim | 0:33d4e66780c0 | 225 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 226 | |
IanBenzMaxim | 0:33d4e66780c0 | 227 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 228 | /* sl_PolicySet */ |
IanBenzMaxim | 0:33d4e66780c0 | 229 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 230 | typedef union |
IanBenzMaxim | 0:33d4e66780c0 | 231 | { |
IanBenzMaxim | 0:33d4e66780c0 | 232 | _WlanPoliciySetGet_t Cmd; |
IanBenzMaxim | 0:33d4e66780c0 | 233 | _BasicResponse_t Rsp; |
IanBenzMaxim | 0:33d4e66780c0 | 234 | }_SlPolicyMsg_u; |
IanBenzMaxim | 0:33d4e66780c0 | 235 | |
IanBenzMaxim | 0:33d4e66780c0 | 236 | #if _SL_INCLUDE_FUNC(sl_WlanPolicySet) |
IanBenzMaxim | 0:33d4e66780c0 | 237 | |
IanBenzMaxim | 0:33d4e66780c0 | 238 | static const _SlCmdCtrl_t _SlPolicySetCmdCtrl = |
IanBenzMaxim | 0:33d4e66780c0 | 239 | { |
IanBenzMaxim | 0:33d4e66780c0 | 240 | SL_OPCODE_WLAN_POLICYSETCOMMAND, |
IanBenzMaxim | 0:33d4e66780c0 | 241 | (_SlArgSize_t)sizeof(_WlanPoliciySetGet_t), |
IanBenzMaxim | 0:33d4e66780c0 | 242 | (_SlArgSize_t)sizeof(_BasicResponse_t) |
IanBenzMaxim | 0:33d4e66780c0 | 243 | }; |
IanBenzMaxim | 0:33d4e66780c0 | 244 | |
IanBenzMaxim | 0:33d4e66780c0 | 245 | _i16 sl_WlanPolicySet(const _u8 Type , const _u8 Policy, _u8 *pVal,const _u8 ValLen) |
IanBenzMaxim | 0:33d4e66780c0 | 246 | { |
IanBenzMaxim | 0:33d4e66780c0 | 247 | _SlPolicyMsg_u Msg; |
IanBenzMaxim | 0:33d4e66780c0 | 248 | _SlCmdExt_t CmdExt; |
IanBenzMaxim | 0:33d4e66780c0 | 249 | |
IanBenzMaxim | 0:33d4e66780c0 | 250 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 251 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 252 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 253 | |
IanBenzMaxim | 0:33d4e66780c0 | 254 | _SlDrvResetCmdExt(&CmdExt); |
IanBenzMaxim | 0:33d4e66780c0 | 255 | CmdExt.TxPayloadLen = ValLen; |
IanBenzMaxim | 0:33d4e66780c0 | 256 | CmdExt.pTxPayload = (_u8 *)pVal; |
IanBenzMaxim | 0:33d4e66780c0 | 257 | |
IanBenzMaxim | 0:33d4e66780c0 | 258 | |
IanBenzMaxim | 0:33d4e66780c0 | 259 | Msg.Cmd.PolicyType = Type; |
IanBenzMaxim | 0:33d4e66780c0 | 260 | Msg.Cmd.PolicyOption = Policy; |
IanBenzMaxim | 0:33d4e66780c0 | 261 | Msg.Cmd.PolicyOptionLen = ValLen; |
IanBenzMaxim | 0:33d4e66780c0 | 262 | |
IanBenzMaxim | 0:33d4e66780c0 | 263 | VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlPolicySetCmdCtrl, &Msg, &CmdExt)); |
IanBenzMaxim | 0:33d4e66780c0 | 264 | |
IanBenzMaxim | 0:33d4e66780c0 | 265 | return (_i16)Msg.Rsp.status; |
IanBenzMaxim | 0:33d4e66780c0 | 266 | } |
IanBenzMaxim | 0:33d4e66780c0 | 267 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 268 | |
IanBenzMaxim | 0:33d4e66780c0 | 269 | |
IanBenzMaxim | 0:33d4e66780c0 | 270 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 271 | /* sl_PolicyGet */ |
IanBenzMaxim | 0:33d4e66780c0 | 272 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 273 | typedef union |
IanBenzMaxim | 0:33d4e66780c0 | 274 | { |
IanBenzMaxim | 0:33d4e66780c0 | 275 | _WlanPoliciySetGet_t Cmd; |
IanBenzMaxim | 0:33d4e66780c0 | 276 | _WlanPoliciySetGet_t Rsp; |
IanBenzMaxim | 0:33d4e66780c0 | 277 | }_SlPolicyGetMsg_u; |
IanBenzMaxim | 0:33d4e66780c0 | 278 | |
IanBenzMaxim | 0:33d4e66780c0 | 279 | #if _SL_INCLUDE_FUNC(sl_WlanPolicyGet) |
IanBenzMaxim | 0:33d4e66780c0 | 280 | |
IanBenzMaxim | 0:33d4e66780c0 | 281 | static const _SlCmdCtrl_t _SlPolicyGetCmdCtrl = |
IanBenzMaxim | 0:33d4e66780c0 | 282 | { |
IanBenzMaxim | 0:33d4e66780c0 | 283 | SL_OPCODE_WLAN_POLICYGETCOMMAND, |
IanBenzMaxim | 0:33d4e66780c0 | 284 | (_SlArgSize_t)sizeof(_WlanPoliciySetGet_t), |
IanBenzMaxim | 0:33d4e66780c0 | 285 | (_SlArgSize_t)sizeof(_WlanPoliciySetGet_t) |
IanBenzMaxim | 0:33d4e66780c0 | 286 | }; |
IanBenzMaxim | 0:33d4e66780c0 | 287 | |
IanBenzMaxim | 0:33d4e66780c0 | 288 | _i16 sl_WlanPolicyGet(const _u8 Type ,_u8 Policy,_u8 *pVal,_u8 *pValLen) |
IanBenzMaxim | 0:33d4e66780c0 | 289 | { |
IanBenzMaxim | 0:33d4e66780c0 | 290 | _SlPolicyGetMsg_u Msg; |
IanBenzMaxim | 0:33d4e66780c0 | 291 | _SlCmdExt_t CmdExt; |
IanBenzMaxim | 0:33d4e66780c0 | 292 | |
IanBenzMaxim | 0:33d4e66780c0 | 293 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 294 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 295 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 296 | |
IanBenzMaxim | 0:33d4e66780c0 | 297 | if (*pValLen == 0) |
IanBenzMaxim | 0:33d4e66780c0 | 298 | { |
IanBenzMaxim | 0:33d4e66780c0 | 299 | return SL_EZEROLEN; |
IanBenzMaxim | 0:33d4e66780c0 | 300 | } |
IanBenzMaxim | 0:33d4e66780c0 | 301 | |
IanBenzMaxim | 0:33d4e66780c0 | 302 | _SlDrvResetCmdExt(&CmdExt); |
IanBenzMaxim | 0:33d4e66780c0 | 303 | CmdExt.RxPayloadLen = (_i16)(*pValLen); |
IanBenzMaxim | 0:33d4e66780c0 | 304 | CmdExt.pRxPayload = pVal; |
IanBenzMaxim | 0:33d4e66780c0 | 305 | |
IanBenzMaxim | 0:33d4e66780c0 | 306 | Msg.Cmd.PolicyType = Type; |
IanBenzMaxim | 0:33d4e66780c0 | 307 | Msg.Cmd.PolicyOption = Policy; |
IanBenzMaxim | 0:33d4e66780c0 | 308 | VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlPolicyGetCmdCtrl, &Msg, &CmdExt)); |
IanBenzMaxim | 0:33d4e66780c0 | 309 | |
IanBenzMaxim | 0:33d4e66780c0 | 310 | |
IanBenzMaxim | 0:33d4e66780c0 | 311 | if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) |
IanBenzMaxim | 0:33d4e66780c0 | 312 | { |
IanBenzMaxim | 0:33d4e66780c0 | 313 | *pValLen = Msg.Rsp.PolicyOptionLen; |
IanBenzMaxim | 0:33d4e66780c0 | 314 | return SL_ESMALLBUF; |
IanBenzMaxim | 0:33d4e66780c0 | 315 | } |
IanBenzMaxim | 0:33d4e66780c0 | 316 | else |
IanBenzMaxim | 0:33d4e66780c0 | 317 | { |
IanBenzMaxim | 0:33d4e66780c0 | 318 | /* no pointer valus, fill the results into _i8 */ |
IanBenzMaxim | 0:33d4e66780c0 | 319 | *pValLen = (_u8)CmdExt.ActualRxPayloadLen; |
IanBenzMaxim | 0:33d4e66780c0 | 320 | if( 0 == CmdExt.ActualRxPayloadLen ) |
IanBenzMaxim | 0:33d4e66780c0 | 321 | { |
IanBenzMaxim | 0:33d4e66780c0 | 322 | *pValLen = 1; |
IanBenzMaxim | 0:33d4e66780c0 | 323 | pVal[0] = Msg.Rsp.PolicyOption; |
IanBenzMaxim | 0:33d4e66780c0 | 324 | } |
IanBenzMaxim | 0:33d4e66780c0 | 325 | } |
IanBenzMaxim | 0:33d4e66780c0 | 326 | return (_i16)SL_OS_RET_CODE_OK; |
IanBenzMaxim | 0:33d4e66780c0 | 327 | } |
IanBenzMaxim | 0:33d4e66780c0 | 328 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 329 | |
IanBenzMaxim | 0:33d4e66780c0 | 330 | |
IanBenzMaxim | 0:33d4e66780c0 | 331 | /*******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 332 | /* sl_ProfileAdd */ |
IanBenzMaxim | 0:33d4e66780c0 | 333 | /*******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 334 | typedef struct |
IanBenzMaxim | 0:33d4e66780c0 | 335 | { |
IanBenzMaxim | 0:33d4e66780c0 | 336 | _WlanAddGetEapProfile_t Args; |
IanBenzMaxim | 0:33d4e66780c0 | 337 | _i8 Strings[MAX_SSID_LEN + MAX_KEY_LEN + MAX_USER_LEN + MAX_ANON_USER_LEN]; |
IanBenzMaxim | 0:33d4e66780c0 | 338 | }_SlProfileParams_t; |
IanBenzMaxim | 0:33d4e66780c0 | 339 | |
IanBenzMaxim | 0:33d4e66780c0 | 340 | typedef union |
IanBenzMaxim | 0:33d4e66780c0 | 341 | { |
IanBenzMaxim | 0:33d4e66780c0 | 342 | _SlProfileParams_t Cmd; |
IanBenzMaxim | 0:33d4e66780c0 | 343 | _BasicResponse_t Rsp; |
IanBenzMaxim | 0:33d4e66780c0 | 344 | }_SlProfileAddMsg_u; |
IanBenzMaxim | 0:33d4e66780c0 | 345 | |
IanBenzMaxim | 0:33d4e66780c0 | 346 | |
IanBenzMaxim | 0:33d4e66780c0 | 347 | |
IanBenzMaxim | 0:33d4e66780c0 | 348 | #if _SL_INCLUDE_FUNC(sl_WlanProfileAdd) |
IanBenzMaxim | 0:33d4e66780c0 | 349 | _i16 sl_WlanProfileAdd(const _i8* pName,const _i16 NameLen,const _u8 *pMacAddr,const SlSecParams_t* pSecParams ,const SlSecParamsExt_t* pSecExtParams,const _u32 Priority,const _u32 Options) |
IanBenzMaxim | 0:33d4e66780c0 | 350 | { |
IanBenzMaxim | 0:33d4e66780c0 | 351 | _SlProfileAddMsg_u Msg; |
IanBenzMaxim | 0:33d4e66780c0 | 352 | _SlCmdCtrl_t CmdCtrl = {0,0,0}; |
IanBenzMaxim | 0:33d4e66780c0 | 353 | CmdCtrl.TxDescLen = 0;/* init */ |
IanBenzMaxim | 0:33d4e66780c0 | 354 | CmdCtrl.RxDescLen = (_SlArgSize_t)(sizeof(_BasicResponse_t)); |
IanBenzMaxim | 0:33d4e66780c0 | 355 | |
IanBenzMaxim | 0:33d4e66780c0 | 356 | |
IanBenzMaxim | 0:33d4e66780c0 | 357 | /* Options paramater is currently not in use */ |
IanBenzMaxim | 0:33d4e66780c0 | 358 | (void)Options; |
IanBenzMaxim | 0:33d4e66780c0 | 359 | |
IanBenzMaxim | 0:33d4e66780c0 | 360 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 361 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 362 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 363 | |
IanBenzMaxim | 0:33d4e66780c0 | 364 | /* update priority */ |
IanBenzMaxim | 0:33d4e66780c0 | 365 | Msg.Cmd.Args.Common.Priority = (_u8)Priority; |
IanBenzMaxim | 0:33d4e66780c0 | 366 | /* verify SSID is not NULL */ |
IanBenzMaxim | 0:33d4e66780c0 | 367 | if( NULL == pName ) |
IanBenzMaxim | 0:33d4e66780c0 | 368 | { |
IanBenzMaxim | 0:33d4e66780c0 | 369 | return SL_INVALPARAM; |
IanBenzMaxim | 0:33d4e66780c0 | 370 | } |
IanBenzMaxim | 0:33d4e66780c0 | 371 | /* verify SSID length */ |
IanBenzMaxim | 0:33d4e66780c0 | 372 | VERIFY_PROTOCOL(NameLen <= MAX_SSID_LEN); |
IanBenzMaxim | 0:33d4e66780c0 | 373 | /* update SSID length */ |
IanBenzMaxim | 0:33d4e66780c0 | 374 | Msg.Cmd.Args.Common.SsidLen = (_u8)NameLen; |
IanBenzMaxim | 0:33d4e66780c0 | 375 | |
IanBenzMaxim | 0:33d4e66780c0 | 376 | |
IanBenzMaxim | 0:33d4e66780c0 | 377 | /* Enterprise security profile */ |
IanBenzMaxim | 0:33d4e66780c0 | 378 | if (NULL != pSecExtParams) |
IanBenzMaxim | 0:33d4e66780c0 | 379 | { |
IanBenzMaxim | 0:33d4e66780c0 | 380 | /* Update command opcode */ |
IanBenzMaxim | 0:33d4e66780c0 | 381 | CmdCtrl.Opcode = SL_OPCODE_WLAN_EAP_PROFILEADDCOMMAND; |
IanBenzMaxim | 0:33d4e66780c0 | 382 | CmdCtrl.TxDescLen += sizeof(_WlanAddGetEapProfile_t); |
IanBenzMaxim | 0:33d4e66780c0 | 383 | |
IanBenzMaxim | 0:33d4e66780c0 | 384 | /* copy SSID */ |
IanBenzMaxim | 0:33d4e66780c0 | 385 | sl_Memcpy(EAP_PROFILE_SSID_STRING(&Msg), pName, NameLen); |
IanBenzMaxim | 0:33d4e66780c0 | 386 | CmdCtrl.TxDescLen += NameLen; |
IanBenzMaxim | 0:33d4e66780c0 | 387 | |
IanBenzMaxim | 0:33d4e66780c0 | 388 | /* Copy password if supplied */ |
IanBenzMaxim | 0:33d4e66780c0 | 389 | if ((NULL != pSecParams) && (pSecParams->KeyLen > 0)) |
IanBenzMaxim | 0:33d4e66780c0 | 390 | { |
IanBenzMaxim | 0:33d4e66780c0 | 391 | /* update security type */ |
IanBenzMaxim | 0:33d4e66780c0 | 392 | Msg.Cmd.Args.Common.SecType = (_i8)(pSecParams->Type); |
IanBenzMaxim | 0:33d4e66780c0 | 393 | |
IanBenzMaxim | 0:33d4e66780c0 | 394 | if( SL_SEC_TYPE_WEP == Msg.Cmd.Args.Common.SecType ) |
IanBenzMaxim | 0:33d4e66780c0 | 395 | { |
IanBenzMaxim | 0:33d4e66780c0 | 396 | Msg.Cmd.Args.Common.WepKeyId = 0; |
IanBenzMaxim | 0:33d4e66780c0 | 397 | } |
IanBenzMaxim | 0:33d4e66780c0 | 398 | |
IanBenzMaxim | 0:33d4e66780c0 | 399 | /* verify key length */ |
IanBenzMaxim | 0:33d4e66780c0 | 400 | if (pSecParams->KeyLen > MAX_KEY_LEN) |
IanBenzMaxim | 0:33d4e66780c0 | 401 | { |
IanBenzMaxim | 0:33d4e66780c0 | 402 | return SL_INVALPARAM; |
IanBenzMaxim | 0:33d4e66780c0 | 403 | } |
IanBenzMaxim | 0:33d4e66780c0 | 404 | VERIFY_PROTOCOL(pSecParams->KeyLen <= MAX_KEY_LEN); |
IanBenzMaxim | 0:33d4e66780c0 | 405 | /* update key length */ |
IanBenzMaxim | 0:33d4e66780c0 | 406 | Msg.Cmd.Args.Common.PasswordLen = pSecParams->KeyLen; |
IanBenzMaxim | 0:33d4e66780c0 | 407 | CmdCtrl.TxDescLen += pSecParams->KeyLen; |
IanBenzMaxim | 0:33d4e66780c0 | 408 | ARG_CHECK_PTR(pSecParams->Key); |
IanBenzMaxim | 0:33d4e66780c0 | 409 | /* copy key */ |
IanBenzMaxim | 0:33d4e66780c0 | 410 | sl_Memcpy(EAP_PROFILE_PASSWORD_STRING(&Msg), pSecParams->Key, pSecParams->KeyLen); |
IanBenzMaxim | 0:33d4e66780c0 | 411 | } |
IanBenzMaxim | 0:33d4e66780c0 | 412 | else |
IanBenzMaxim | 0:33d4e66780c0 | 413 | { |
IanBenzMaxim | 0:33d4e66780c0 | 414 | Msg.Cmd.Args.Common.PasswordLen = 0; |
IanBenzMaxim | 0:33d4e66780c0 | 415 | } |
IanBenzMaxim | 0:33d4e66780c0 | 416 | |
IanBenzMaxim | 0:33d4e66780c0 | 417 | ARG_CHECK_PTR(pSecExtParams); |
IanBenzMaxim | 0:33d4e66780c0 | 418 | /* Update Eap bitmask */ |
IanBenzMaxim | 0:33d4e66780c0 | 419 | Msg.Cmd.Args.EapBitmask = pSecExtParams->EapMethod; |
IanBenzMaxim | 0:33d4e66780c0 | 420 | /* Update Certificate file ID index - currently not supported */ |
IanBenzMaxim | 0:33d4e66780c0 | 421 | Msg.Cmd.Args.CertIndex = pSecExtParams->CertIndex; |
IanBenzMaxim | 0:33d4e66780c0 | 422 | /* verify user length */ |
IanBenzMaxim | 0:33d4e66780c0 | 423 | if (pSecExtParams->UserLen > MAX_USER_LEN) |
IanBenzMaxim | 0:33d4e66780c0 | 424 | { |
IanBenzMaxim | 0:33d4e66780c0 | 425 | return SL_INVALPARAM; |
IanBenzMaxim | 0:33d4e66780c0 | 426 | } |
IanBenzMaxim | 0:33d4e66780c0 | 427 | Msg.Cmd.Args.UserLen = pSecExtParams->UserLen; |
IanBenzMaxim | 0:33d4e66780c0 | 428 | /* copy user name (identity) */ |
IanBenzMaxim | 0:33d4e66780c0 | 429 | if(pSecExtParams->UserLen > 0) |
IanBenzMaxim | 0:33d4e66780c0 | 430 | { |
IanBenzMaxim | 0:33d4e66780c0 | 431 | sl_Memcpy(EAP_PROFILE_USER_STRING(&Msg), pSecExtParams->User, pSecExtParams->UserLen); |
IanBenzMaxim | 0:33d4e66780c0 | 432 | CmdCtrl.TxDescLen += pSecExtParams->UserLen; |
IanBenzMaxim | 0:33d4e66780c0 | 433 | } |
IanBenzMaxim | 0:33d4e66780c0 | 434 | |
IanBenzMaxim | 0:33d4e66780c0 | 435 | /* verify Anonymous user length (for tunneled) */ |
IanBenzMaxim | 0:33d4e66780c0 | 436 | if (pSecExtParams->AnonUserLen > MAX_ANON_USER_LEN) |
IanBenzMaxim | 0:33d4e66780c0 | 437 | { |
IanBenzMaxim | 0:33d4e66780c0 | 438 | return SL_INVALPARAM; |
IanBenzMaxim | 0:33d4e66780c0 | 439 | } |
IanBenzMaxim | 0:33d4e66780c0 | 440 | Msg.Cmd.Args.AnonUserLen = pSecExtParams->AnonUserLen; |
IanBenzMaxim | 0:33d4e66780c0 | 441 | |
IanBenzMaxim | 0:33d4e66780c0 | 442 | /* copy Anonymous user */ |
IanBenzMaxim | 0:33d4e66780c0 | 443 | if(pSecExtParams->AnonUserLen > 0) |
IanBenzMaxim | 0:33d4e66780c0 | 444 | { |
IanBenzMaxim | 0:33d4e66780c0 | 445 | sl_Memcpy(EAP_PROFILE_ANON_USER_STRING(&Msg), pSecExtParams->AnonUser, pSecExtParams->AnonUserLen); |
IanBenzMaxim | 0:33d4e66780c0 | 446 | CmdCtrl.TxDescLen += pSecExtParams->AnonUserLen; |
IanBenzMaxim | 0:33d4e66780c0 | 447 | } |
IanBenzMaxim | 0:33d4e66780c0 | 448 | |
IanBenzMaxim | 0:33d4e66780c0 | 449 | } |
IanBenzMaxim | 0:33d4e66780c0 | 450 | /* Regular or open security profile */ |
IanBenzMaxim | 0:33d4e66780c0 | 451 | else |
IanBenzMaxim | 0:33d4e66780c0 | 452 | { |
IanBenzMaxim | 0:33d4e66780c0 | 453 | /* Update command opcode */ |
IanBenzMaxim | 0:33d4e66780c0 | 454 | CmdCtrl.Opcode = SL_OPCODE_WLAN_PROFILEADDCOMMAND; |
IanBenzMaxim | 0:33d4e66780c0 | 455 | /* update commnad length */ |
IanBenzMaxim | 0:33d4e66780c0 | 456 | CmdCtrl.TxDescLen += sizeof(_WlanAddGetProfile_t); |
IanBenzMaxim | 0:33d4e66780c0 | 457 | |
IanBenzMaxim | 0:33d4e66780c0 | 458 | if (NULL != pName) |
IanBenzMaxim | 0:33d4e66780c0 | 459 | { |
IanBenzMaxim | 0:33d4e66780c0 | 460 | /* copy SSID */ |
IanBenzMaxim | 0:33d4e66780c0 | 461 | sl_Memcpy(PROFILE_SSID_STRING(&Msg), pName, NameLen); |
IanBenzMaxim | 0:33d4e66780c0 | 462 | CmdCtrl.TxDescLen += NameLen; |
IanBenzMaxim | 0:33d4e66780c0 | 463 | } |
IanBenzMaxim | 0:33d4e66780c0 | 464 | |
IanBenzMaxim | 0:33d4e66780c0 | 465 | /* Copy password if supplied */ |
IanBenzMaxim | 0:33d4e66780c0 | 466 | if( NULL != pSecParams ) |
IanBenzMaxim | 0:33d4e66780c0 | 467 | { |
IanBenzMaxim | 0:33d4e66780c0 | 468 | /* update security type */ |
IanBenzMaxim | 0:33d4e66780c0 | 469 | Msg.Cmd.Args.Common.SecType = (_i8)(pSecParams->Type); |
IanBenzMaxim | 0:33d4e66780c0 | 470 | |
IanBenzMaxim | 0:33d4e66780c0 | 471 | if( SL_SEC_TYPE_WEP == Msg.Cmd.Args.Common.SecType ) |
IanBenzMaxim | 0:33d4e66780c0 | 472 | { |
IanBenzMaxim | 0:33d4e66780c0 | 473 | Msg.Cmd.Args.Common.WepKeyId = 0; |
IanBenzMaxim | 0:33d4e66780c0 | 474 | } |
IanBenzMaxim | 0:33d4e66780c0 | 475 | |
IanBenzMaxim | 0:33d4e66780c0 | 476 | /* verify key length */ |
IanBenzMaxim | 0:33d4e66780c0 | 477 | if (pSecParams->KeyLen > MAX_KEY_LEN) |
IanBenzMaxim | 0:33d4e66780c0 | 478 | { |
IanBenzMaxim | 0:33d4e66780c0 | 479 | return SL_INVALPARAM; |
IanBenzMaxim | 0:33d4e66780c0 | 480 | } |
IanBenzMaxim | 0:33d4e66780c0 | 481 | /* update key length */ |
IanBenzMaxim | 0:33d4e66780c0 | 482 | Msg.Cmd.Args.Common.PasswordLen = pSecParams->KeyLen; |
IanBenzMaxim | 0:33d4e66780c0 | 483 | CmdCtrl.TxDescLen += pSecParams->KeyLen; |
IanBenzMaxim | 0:33d4e66780c0 | 484 | /* copy key (could be no key in case of WPS pin) */ |
IanBenzMaxim | 0:33d4e66780c0 | 485 | if( NULL != pSecParams->Key ) |
IanBenzMaxim | 0:33d4e66780c0 | 486 | { |
IanBenzMaxim | 0:33d4e66780c0 | 487 | sl_Memcpy(PROFILE_PASSWORD_STRING(&Msg), pSecParams->Key, pSecParams->KeyLen); |
IanBenzMaxim | 0:33d4e66780c0 | 488 | } |
IanBenzMaxim | 0:33d4e66780c0 | 489 | } |
IanBenzMaxim | 0:33d4e66780c0 | 490 | else |
IanBenzMaxim | 0:33d4e66780c0 | 491 | { |
IanBenzMaxim | 0:33d4e66780c0 | 492 | Msg.Cmd.Args.Common.SecType = SL_SEC_TYPE_OPEN; |
IanBenzMaxim | 0:33d4e66780c0 | 493 | Msg.Cmd.Args.Common.PasswordLen = 0; |
IanBenzMaxim | 0:33d4e66780c0 | 494 | } |
IanBenzMaxim | 0:33d4e66780c0 | 495 | |
IanBenzMaxim | 0:33d4e66780c0 | 496 | } |
IanBenzMaxim | 0:33d4e66780c0 | 497 | |
IanBenzMaxim | 0:33d4e66780c0 | 498 | |
IanBenzMaxim | 0:33d4e66780c0 | 499 | /* If BSSID is not null, copy to buffer, otherwise set to 0 */ |
IanBenzMaxim | 0:33d4e66780c0 | 500 | if(NULL != pMacAddr) |
IanBenzMaxim | 0:33d4e66780c0 | 501 | { |
IanBenzMaxim | 0:33d4e66780c0 | 502 | sl_Memcpy(Msg.Cmd.Args.Common.Bssid, pMacAddr, sizeof(Msg.Cmd.Args.Common.Bssid)); |
IanBenzMaxim | 0:33d4e66780c0 | 503 | } |
IanBenzMaxim | 0:33d4e66780c0 | 504 | else |
IanBenzMaxim | 0:33d4e66780c0 | 505 | { |
IanBenzMaxim | 0:33d4e66780c0 | 506 | _SlDrvMemZero(Msg.Cmd.Args.Common.Bssid, (_u16)sizeof(Msg.Cmd.Args.Common.Bssid)); |
IanBenzMaxim | 0:33d4e66780c0 | 507 | } |
IanBenzMaxim | 0:33d4e66780c0 | 508 | |
IanBenzMaxim | 0:33d4e66780c0 | 509 | VERIFY_RET_OK(_SlDrvCmdOp(&CmdCtrl, &Msg, NULL)); |
IanBenzMaxim | 0:33d4e66780c0 | 510 | |
IanBenzMaxim | 0:33d4e66780c0 | 511 | return (_i16)Msg.Rsp.status; |
IanBenzMaxim | 0:33d4e66780c0 | 512 | } |
IanBenzMaxim | 0:33d4e66780c0 | 513 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 514 | /*******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 515 | /* sl_ProfileGet */ |
IanBenzMaxim | 0:33d4e66780c0 | 516 | /*******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 517 | typedef union |
IanBenzMaxim | 0:33d4e66780c0 | 518 | { |
IanBenzMaxim | 0:33d4e66780c0 | 519 | _WlanProfileDelGetCommand_t Cmd; |
IanBenzMaxim | 0:33d4e66780c0 | 520 | _SlProfileParams_t Rsp; |
IanBenzMaxim | 0:33d4e66780c0 | 521 | }_SlProfileGetMsg_u; |
IanBenzMaxim | 0:33d4e66780c0 | 522 | |
IanBenzMaxim | 0:33d4e66780c0 | 523 | |
IanBenzMaxim | 0:33d4e66780c0 | 524 | #if _SL_INCLUDE_FUNC(sl_WlanProfileGet) |
IanBenzMaxim | 0:33d4e66780c0 | 525 | |
IanBenzMaxim | 0:33d4e66780c0 | 526 | static const _SlCmdCtrl_t _SlProfileGetCmdCtrl = |
IanBenzMaxim | 0:33d4e66780c0 | 527 | { |
IanBenzMaxim | 0:33d4e66780c0 | 528 | SL_OPCODE_WLAN_PROFILEGETCOMMAND, |
IanBenzMaxim | 0:33d4e66780c0 | 529 | (_SlArgSize_t)sizeof(_WlanProfileDelGetCommand_t), |
IanBenzMaxim | 0:33d4e66780c0 | 530 | (_SlArgSize_t)sizeof(_SlProfileParams_t) |
IanBenzMaxim | 0:33d4e66780c0 | 531 | }; |
IanBenzMaxim | 0:33d4e66780c0 | 532 | |
IanBenzMaxim | 0:33d4e66780c0 | 533 | _i16 sl_WlanProfileGet(const _i16 Index,_i8* pName, _i16 *pNameLen, _u8 *pMacAddr, SlSecParams_t* pSecParams, SlGetSecParamsExt_t* pEntParams, _u32 *pPriority) |
IanBenzMaxim | 0:33d4e66780c0 | 534 | { |
IanBenzMaxim | 0:33d4e66780c0 | 535 | _SlProfileGetMsg_u Msg; |
IanBenzMaxim | 0:33d4e66780c0 | 536 | Msg.Cmd.index = (_u8)Index; |
IanBenzMaxim | 0:33d4e66780c0 | 537 | |
IanBenzMaxim | 0:33d4e66780c0 | 538 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 539 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 540 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 541 | |
IanBenzMaxim | 0:33d4e66780c0 | 542 | VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlProfileGetCmdCtrl, &Msg, NULL)); |
IanBenzMaxim | 0:33d4e66780c0 | 543 | |
IanBenzMaxim | 0:33d4e66780c0 | 544 | pSecParams->Type = (_u8)(Msg.Rsp.Args.Common.SecType); |
IanBenzMaxim | 0:33d4e66780c0 | 545 | /* since password is not transferred in getprofile, password length should always be zero */ |
IanBenzMaxim | 0:33d4e66780c0 | 546 | pSecParams->KeyLen = Msg.Rsp.Args.Common.PasswordLen; |
IanBenzMaxim | 0:33d4e66780c0 | 547 | if (NULL != pEntParams) |
IanBenzMaxim | 0:33d4e66780c0 | 548 | { |
IanBenzMaxim | 0:33d4e66780c0 | 549 | pEntParams->UserLen = Msg.Rsp.Args.UserLen; |
IanBenzMaxim | 0:33d4e66780c0 | 550 | /* copy user name */ |
IanBenzMaxim | 0:33d4e66780c0 | 551 | if (pEntParams->UserLen > 0) |
IanBenzMaxim | 0:33d4e66780c0 | 552 | { |
IanBenzMaxim | 0:33d4e66780c0 | 553 | sl_Memcpy(pEntParams->User, EAP_PROFILE_USER_STRING(&Msg), pEntParams->UserLen); |
IanBenzMaxim | 0:33d4e66780c0 | 554 | } |
IanBenzMaxim | 0:33d4e66780c0 | 555 | pEntParams->AnonUserLen = Msg.Rsp.Args.AnonUserLen; |
IanBenzMaxim | 0:33d4e66780c0 | 556 | /* copy anonymous user name */ |
IanBenzMaxim | 0:33d4e66780c0 | 557 | if (pEntParams->AnonUserLen > 0) |
IanBenzMaxim | 0:33d4e66780c0 | 558 | { |
IanBenzMaxim | 0:33d4e66780c0 | 559 | sl_Memcpy(pEntParams->AnonUser, EAP_PROFILE_ANON_USER_STRING(&Msg), pEntParams->AnonUserLen); |
IanBenzMaxim | 0:33d4e66780c0 | 560 | } |
IanBenzMaxim | 0:33d4e66780c0 | 561 | } |
IanBenzMaxim | 0:33d4e66780c0 | 562 | |
IanBenzMaxim | 0:33d4e66780c0 | 563 | *pNameLen = (_i16)(Msg.Rsp.Args.Common.SsidLen); |
IanBenzMaxim | 0:33d4e66780c0 | 564 | *pPriority = Msg.Rsp.Args.Common.Priority; |
IanBenzMaxim | 0:33d4e66780c0 | 565 | |
IanBenzMaxim | 0:33d4e66780c0 | 566 | if (NULL != Msg.Rsp.Args.Common.Bssid) |
IanBenzMaxim | 0:33d4e66780c0 | 567 | { |
IanBenzMaxim | 0:33d4e66780c0 | 568 | sl_Memcpy(pMacAddr, Msg.Rsp.Args.Common.Bssid, sizeof(Msg.Rsp.Args.Common.Bssid)); |
IanBenzMaxim | 0:33d4e66780c0 | 569 | } |
IanBenzMaxim | 0:33d4e66780c0 | 570 | |
IanBenzMaxim | 0:33d4e66780c0 | 571 | sl_Memcpy(pName, EAP_PROFILE_SSID_STRING(&Msg), *pNameLen); |
IanBenzMaxim | 0:33d4e66780c0 | 572 | |
IanBenzMaxim | 0:33d4e66780c0 | 573 | return (_i16)Msg.Rsp.Args.Common.SecType; |
IanBenzMaxim | 0:33d4e66780c0 | 574 | |
IanBenzMaxim | 0:33d4e66780c0 | 575 | } |
IanBenzMaxim | 0:33d4e66780c0 | 576 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 577 | /*******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 578 | /* sl_ProfileDel */ |
IanBenzMaxim | 0:33d4e66780c0 | 579 | /*******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 580 | typedef union |
IanBenzMaxim | 0:33d4e66780c0 | 581 | { |
IanBenzMaxim | 0:33d4e66780c0 | 582 | _WlanProfileDelGetCommand_t Cmd; |
IanBenzMaxim | 0:33d4e66780c0 | 583 | _BasicResponse_t Rsp; |
IanBenzMaxim | 0:33d4e66780c0 | 584 | }_SlProfileDelMsg_u; |
IanBenzMaxim | 0:33d4e66780c0 | 585 | |
IanBenzMaxim | 0:33d4e66780c0 | 586 | |
IanBenzMaxim | 0:33d4e66780c0 | 587 | #if _SL_INCLUDE_FUNC(sl_WlanProfileDel) |
IanBenzMaxim | 0:33d4e66780c0 | 588 | |
IanBenzMaxim | 0:33d4e66780c0 | 589 | static const _SlCmdCtrl_t _SlProfileDelCmdCtrl = |
IanBenzMaxim | 0:33d4e66780c0 | 590 | { |
IanBenzMaxim | 0:33d4e66780c0 | 591 | SL_OPCODE_WLAN_PROFILEDELCOMMAND, |
IanBenzMaxim | 0:33d4e66780c0 | 592 | (_SlArgSize_t)sizeof(_WlanProfileDelGetCommand_t), |
IanBenzMaxim | 0:33d4e66780c0 | 593 | (_SlArgSize_t)sizeof(_BasicResponse_t) |
IanBenzMaxim | 0:33d4e66780c0 | 594 | }; |
IanBenzMaxim | 0:33d4e66780c0 | 595 | |
IanBenzMaxim | 0:33d4e66780c0 | 596 | _i16 sl_WlanProfileDel(const _i16 Index) |
IanBenzMaxim | 0:33d4e66780c0 | 597 | { |
IanBenzMaxim | 0:33d4e66780c0 | 598 | _SlProfileDelMsg_u Msg; |
IanBenzMaxim | 0:33d4e66780c0 | 599 | |
IanBenzMaxim | 0:33d4e66780c0 | 600 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 601 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 602 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 603 | |
IanBenzMaxim | 0:33d4e66780c0 | 604 | Msg.Cmd.index = (_u8)Index; |
IanBenzMaxim | 0:33d4e66780c0 | 605 | |
IanBenzMaxim | 0:33d4e66780c0 | 606 | VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlProfileDelCmdCtrl, &Msg, NULL)); |
IanBenzMaxim | 0:33d4e66780c0 | 607 | |
IanBenzMaxim | 0:33d4e66780c0 | 608 | return (_i16)Msg.Rsp.status; |
IanBenzMaxim | 0:33d4e66780c0 | 609 | } |
IanBenzMaxim | 0:33d4e66780c0 | 610 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 611 | |
IanBenzMaxim | 0:33d4e66780c0 | 612 | |
IanBenzMaxim | 0:33d4e66780c0 | 613 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 614 | /* sl_WlanGetNetworkList */ |
IanBenzMaxim | 0:33d4e66780c0 | 615 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 616 | typedef union |
IanBenzMaxim | 0:33d4e66780c0 | 617 | { |
IanBenzMaxim | 0:33d4e66780c0 | 618 | _WlanGetNetworkListCommand_t Cmd; |
IanBenzMaxim | 0:33d4e66780c0 | 619 | _WlanGetNetworkListResponse_t Rsp; |
IanBenzMaxim | 0:33d4e66780c0 | 620 | }_SlWlanGetNetworkListMsg_u; |
IanBenzMaxim | 0:33d4e66780c0 | 621 | |
IanBenzMaxim | 0:33d4e66780c0 | 622 | |
IanBenzMaxim | 0:33d4e66780c0 | 623 | #if _SL_INCLUDE_FUNC(sl_WlanGetNetworkList) |
IanBenzMaxim | 0:33d4e66780c0 | 624 | |
IanBenzMaxim | 0:33d4e66780c0 | 625 | static const _SlCmdCtrl_t _SlWlanGetNetworkListCtrl = |
IanBenzMaxim | 0:33d4e66780c0 | 626 | { |
IanBenzMaxim | 0:33d4e66780c0 | 627 | SL_OPCODE_WLAN_SCANRESULTSGETCOMMAND, |
IanBenzMaxim | 0:33d4e66780c0 | 628 | (_SlArgSize_t)sizeof(_WlanGetNetworkListCommand_t), |
IanBenzMaxim | 0:33d4e66780c0 | 629 | (_SlArgSize_t)sizeof(_WlanGetNetworkListResponse_t) |
IanBenzMaxim | 0:33d4e66780c0 | 630 | }; |
IanBenzMaxim | 0:33d4e66780c0 | 631 | |
IanBenzMaxim | 0:33d4e66780c0 | 632 | _i16 sl_WlanGetNetworkList(const _u8 Index,const _u8 Count, Sl_WlanNetworkEntry_t *pEntries) |
IanBenzMaxim | 0:33d4e66780c0 | 633 | { |
IanBenzMaxim | 0:33d4e66780c0 | 634 | _i16 retVal = 0; |
IanBenzMaxim | 0:33d4e66780c0 | 635 | _SlWlanGetNetworkListMsg_u Msg; |
IanBenzMaxim | 0:33d4e66780c0 | 636 | _SlCmdExt_t CmdExt; |
IanBenzMaxim | 0:33d4e66780c0 | 637 | |
IanBenzMaxim | 0:33d4e66780c0 | 638 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 639 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 640 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 641 | |
IanBenzMaxim | 0:33d4e66780c0 | 642 | if (Count == 0) |
IanBenzMaxim | 0:33d4e66780c0 | 643 | { |
IanBenzMaxim | 0:33d4e66780c0 | 644 | return SL_EZEROLEN; |
IanBenzMaxim | 0:33d4e66780c0 | 645 | } |
IanBenzMaxim | 0:33d4e66780c0 | 646 | |
IanBenzMaxim | 0:33d4e66780c0 | 647 | _SlDrvResetCmdExt(&CmdExt); |
IanBenzMaxim | 0:33d4e66780c0 | 648 | CmdExt.RxPayloadLen = (_i16)(sizeof(Sl_WlanNetworkEntry_t)*(Count)); |
IanBenzMaxim | 0:33d4e66780c0 | 649 | CmdExt.pRxPayload = (_u8 *)pEntries; |
IanBenzMaxim | 0:33d4e66780c0 | 650 | |
IanBenzMaxim | 0:33d4e66780c0 | 651 | Msg.Cmd.index = Index; |
IanBenzMaxim | 0:33d4e66780c0 | 652 | Msg.Cmd.count = Count; |
IanBenzMaxim | 0:33d4e66780c0 | 653 | |
IanBenzMaxim | 0:33d4e66780c0 | 654 | VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanGetNetworkListCtrl, &Msg, &CmdExt)); |
IanBenzMaxim | 0:33d4e66780c0 | 655 | retVal = Msg.Rsp.status; |
IanBenzMaxim | 0:33d4e66780c0 | 656 | |
IanBenzMaxim | 0:33d4e66780c0 | 657 | return (_i16)retVal; |
IanBenzMaxim | 0:33d4e66780c0 | 658 | } |
IanBenzMaxim | 0:33d4e66780c0 | 659 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 660 | |
IanBenzMaxim | 0:33d4e66780c0 | 661 | |
IanBenzMaxim | 0:33d4e66780c0 | 662 | |
IanBenzMaxim | 0:33d4e66780c0 | 663 | |
IanBenzMaxim | 0:33d4e66780c0 | 664 | |
IanBenzMaxim | 0:33d4e66780c0 | 665 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 666 | /* RX filters message command response structures */ |
IanBenzMaxim | 0:33d4e66780c0 | 667 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 668 | |
IanBenzMaxim | 0:33d4e66780c0 | 669 | /* Set command */ |
IanBenzMaxim | 0:33d4e66780c0 | 670 | typedef union |
IanBenzMaxim | 0:33d4e66780c0 | 671 | { |
IanBenzMaxim | 0:33d4e66780c0 | 672 | _WlanRxFilterAddCommand_t Cmd; |
IanBenzMaxim | 0:33d4e66780c0 | 673 | _WlanRxFilterAddCommandReponse_t Rsp; |
IanBenzMaxim | 0:33d4e66780c0 | 674 | }_SlrxFilterAddMsg_u; |
IanBenzMaxim | 0:33d4e66780c0 | 675 | |
IanBenzMaxim | 0:33d4e66780c0 | 676 | |
IanBenzMaxim | 0:33d4e66780c0 | 677 | /* Set command */ |
IanBenzMaxim | 0:33d4e66780c0 | 678 | typedef union _SlRxFilterSetMsg_u |
IanBenzMaxim | 0:33d4e66780c0 | 679 | { |
IanBenzMaxim | 0:33d4e66780c0 | 680 | _WlanRxFilterSetCommand_t Cmd; |
IanBenzMaxim | 0:33d4e66780c0 | 681 | _WlanRxFilterSetCommandReponse_t Rsp; |
IanBenzMaxim | 0:33d4e66780c0 | 682 | }_SlRxFilterSetMsg_u; |
IanBenzMaxim | 0:33d4e66780c0 | 683 | |
IanBenzMaxim | 0:33d4e66780c0 | 684 | |
IanBenzMaxim | 0:33d4e66780c0 | 685 | /* Get command */ |
IanBenzMaxim | 0:33d4e66780c0 | 686 | typedef union _SlRxFilterGetMsg_u |
IanBenzMaxim | 0:33d4e66780c0 | 687 | { |
IanBenzMaxim | 0:33d4e66780c0 | 688 | _WlanRxFilterGetCommand_t Cmd; |
IanBenzMaxim | 0:33d4e66780c0 | 689 | _WlanRxFilterGetCommandReponse_t Rsp; |
IanBenzMaxim | 0:33d4e66780c0 | 690 | }_SlRxFilterGetMsg_u; |
IanBenzMaxim | 0:33d4e66780c0 | 691 | |
IanBenzMaxim | 0:33d4e66780c0 | 692 | #if _SL_INCLUDE_FUNC(sl_WlanRxFilterAdd) |
IanBenzMaxim | 0:33d4e66780c0 | 693 | |
IanBenzMaxim | 0:33d4e66780c0 | 694 | static const _SlCmdCtrl_t _SlRxFilterAddtCmdCtrl = |
IanBenzMaxim | 0:33d4e66780c0 | 695 | { |
IanBenzMaxim | 0:33d4e66780c0 | 696 | SL_OPCODE_WLAN_WLANRXFILTERADDCOMMAND, |
IanBenzMaxim | 0:33d4e66780c0 | 697 | (_SlArgSize_t)sizeof(_WlanRxFilterAddCommand_t), |
IanBenzMaxim | 0:33d4e66780c0 | 698 | (_SlArgSize_t)sizeof(_WlanRxFilterAddCommandReponse_t) |
IanBenzMaxim | 0:33d4e66780c0 | 699 | }; |
IanBenzMaxim | 0:33d4e66780c0 | 700 | |
IanBenzMaxim | 0:33d4e66780c0 | 701 | |
IanBenzMaxim | 0:33d4e66780c0 | 702 | /***************************************************************************** |
IanBenzMaxim | 0:33d4e66780c0 | 703 | RX filters |
IanBenzMaxim | 0:33d4e66780c0 | 704 | *****************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 705 | _i16 sl_WlanRxFilterAdd( SlrxFilterRuleType_t RuleType, |
IanBenzMaxim | 0:33d4e66780c0 | 706 | SlrxFilterFlags_t FilterFlags, |
IanBenzMaxim | 0:33d4e66780c0 | 707 | const SlrxFilterRule_t* const Rule, |
IanBenzMaxim | 0:33d4e66780c0 | 708 | const SlrxFilterTrigger_t* const Trigger, |
IanBenzMaxim | 0:33d4e66780c0 | 709 | const SlrxFilterAction_t* const Action, |
IanBenzMaxim | 0:33d4e66780c0 | 710 | SlrxFilterID_t* pFilterId) |
IanBenzMaxim | 0:33d4e66780c0 | 711 | { |
IanBenzMaxim | 0:33d4e66780c0 | 712 | |
IanBenzMaxim | 0:33d4e66780c0 | 713 | |
IanBenzMaxim | 0:33d4e66780c0 | 714 | _SlrxFilterAddMsg_u Msg; |
IanBenzMaxim | 0:33d4e66780c0 | 715 | |
IanBenzMaxim | 0:33d4e66780c0 | 716 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 717 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 718 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 719 | |
IanBenzMaxim | 0:33d4e66780c0 | 720 | Msg.Cmd.RuleType = RuleType; |
IanBenzMaxim | 0:33d4e66780c0 | 721 | /* filterId is zero */ |
IanBenzMaxim | 0:33d4e66780c0 | 722 | Msg.Cmd.FilterId = 0; |
IanBenzMaxim | 0:33d4e66780c0 | 723 | Msg.Cmd.FilterFlags = FilterFlags; |
IanBenzMaxim | 0:33d4e66780c0 | 724 | sl_Memcpy( &(Msg.Cmd.Rule), Rule, sizeof(SlrxFilterRule_t) ); |
IanBenzMaxim | 0:33d4e66780c0 | 725 | sl_Memcpy( &(Msg.Cmd.Trigger), Trigger, sizeof(SlrxFilterTrigger_t) ); |
IanBenzMaxim | 0:33d4e66780c0 | 726 | sl_Memcpy( &(Msg.Cmd.Action), Action, sizeof(SlrxFilterAction_t) ); |
IanBenzMaxim | 0:33d4e66780c0 | 727 | VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlRxFilterAddtCmdCtrl, &Msg, NULL) ); |
IanBenzMaxim | 0:33d4e66780c0 | 728 | *pFilterId = Msg.Rsp.FilterId; |
IanBenzMaxim | 0:33d4e66780c0 | 729 | return (_i16)Msg.Rsp.Status; |
IanBenzMaxim | 0:33d4e66780c0 | 730 | |
IanBenzMaxim | 0:33d4e66780c0 | 731 | } |
IanBenzMaxim | 0:33d4e66780c0 | 732 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 733 | |
IanBenzMaxim | 0:33d4e66780c0 | 734 | |
IanBenzMaxim | 0:33d4e66780c0 | 735 | |
IanBenzMaxim | 0:33d4e66780c0 | 736 | /*******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 737 | /* RX filters */ |
IanBenzMaxim | 0:33d4e66780c0 | 738 | /*******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 739 | #if _SL_INCLUDE_FUNC(sl_WlanRxFilterSet) |
IanBenzMaxim | 0:33d4e66780c0 | 740 | |
IanBenzMaxim | 0:33d4e66780c0 | 741 | static const _SlCmdCtrl_t _SlRxFilterSetCmdCtrl = |
IanBenzMaxim | 0:33d4e66780c0 | 742 | { |
IanBenzMaxim | 0:33d4e66780c0 | 743 | SL_OPCODE_WLAN_WLANRXFILTERSETCOMMAND, |
IanBenzMaxim | 0:33d4e66780c0 | 744 | (_SlArgSize_t)sizeof(_WlanRxFilterSetCommand_t), |
IanBenzMaxim | 0:33d4e66780c0 | 745 | (_SlArgSize_t)sizeof(_WlanRxFilterSetCommandReponse_t) |
IanBenzMaxim | 0:33d4e66780c0 | 746 | }; |
IanBenzMaxim | 0:33d4e66780c0 | 747 | |
IanBenzMaxim | 0:33d4e66780c0 | 748 | _i16 sl_WlanRxFilterSet(const SLrxFilterOperation_t RxFilterOperation, |
IanBenzMaxim | 0:33d4e66780c0 | 749 | const _u8* const pInputBuffer, |
IanBenzMaxim | 0:33d4e66780c0 | 750 | _u16 InputbufferLength) |
IanBenzMaxim | 0:33d4e66780c0 | 751 | { |
IanBenzMaxim | 0:33d4e66780c0 | 752 | _SlRxFilterSetMsg_u Msg; |
IanBenzMaxim | 0:33d4e66780c0 | 753 | _SlCmdExt_t CmdExt; |
IanBenzMaxim | 0:33d4e66780c0 | 754 | |
IanBenzMaxim | 0:33d4e66780c0 | 755 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 756 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 757 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 758 | |
IanBenzMaxim | 0:33d4e66780c0 | 759 | _SlDrvResetCmdExt(&CmdExt); |
IanBenzMaxim | 0:33d4e66780c0 | 760 | CmdExt.TxPayloadLen = InputbufferLength; |
IanBenzMaxim | 0:33d4e66780c0 | 761 | CmdExt.pTxPayload = (_u8 *)pInputBuffer; |
IanBenzMaxim | 0:33d4e66780c0 | 762 | |
IanBenzMaxim | 0:33d4e66780c0 | 763 | Msg.Cmd.RxFilterOperation = RxFilterOperation; |
IanBenzMaxim | 0:33d4e66780c0 | 764 | Msg.Cmd.InputBufferLength = InputbufferLength; |
IanBenzMaxim | 0:33d4e66780c0 | 765 | |
IanBenzMaxim | 0:33d4e66780c0 | 766 | |
IanBenzMaxim | 0:33d4e66780c0 | 767 | VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlRxFilterSetCmdCtrl, &Msg, &CmdExt) ); |
IanBenzMaxim | 0:33d4e66780c0 | 768 | |
IanBenzMaxim | 0:33d4e66780c0 | 769 | |
IanBenzMaxim | 0:33d4e66780c0 | 770 | return (_i16)Msg.Rsp.Status; |
IanBenzMaxim | 0:33d4e66780c0 | 771 | } |
IanBenzMaxim | 0:33d4e66780c0 | 772 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 773 | |
IanBenzMaxim | 0:33d4e66780c0 | 774 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 775 | /* RX filters */ |
IanBenzMaxim | 0:33d4e66780c0 | 776 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 777 | #if _SL_INCLUDE_FUNC(sl_WlanRxFilterGet) |
IanBenzMaxim | 0:33d4e66780c0 | 778 | |
IanBenzMaxim | 0:33d4e66780c0 | 779 | static const _SlCmdCtrl_t _SlRxFilterGetCmdCtrl = |
IanBenzMaxim | 0:33d4e66780c0 | 780 | { |
IanBenzMaxim | 0:33d4e66780c0 | 781 | SL_OPCODE_WLAN_WLANRXFILTERGETCOMMAND, |
IanBenzMaxim | 0:33d4e66780c0 | 782 | (_SlArgSize_t)sizeof(_WlanRxFilterGetCommand_t), |
IanBenzMaxim | 0:33d4e66780c0 | 783 | (_SlArgSize_t)sizeof(_WlanRxFilterGetCommandReponse_t) |
IanBenzMaxim | 0:33d4e66780c0 | 784 | }; |
IanBenzMaxim | 0:33d4e66780c0 | 785 | |
IanBenzMaxim | 0:33d4e66780c0 | 786 | |
IanBenzMaxim | 0:33d4e66780c0 | 787 | _i16 sl_WlanRxFilterGet(const SLrxFilterOperation_t RxFilterOperation, |
IanBenzMaxim | 0:33d4e66780c0 | 788 | _u8* pOutputBuffer, |
IanBenzMaxim | 0:33d4e66780c0 | 789 | _u16 OutputbufferLength) |
IanBenzMaxim | 0:33d4e66780c0 | 790 | { |
IanBenzMaxim | 0:33d4e66780c0 | 791 | _SlRxFilterGetMsg_u Msg; |
IanBenzMaxim | 0:33d4e66780c0 | 792 | _SlCmdExt_t CmdExt; |
IanBenzMaxim | 0:33d4e66780c0 | 793 | |
IanBenzMaxim | 0:33d4e66780c0 | 794 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 795 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 796 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 797 | |
IanBenzMaxim | 0:33d4e66780c0 | 798 | if (OutputbufferLength == 0) |
IanBenzMaxim | 0:33d4e66780c0 | 799 | { |
IanBenzMaxim | 0:33d4e66780c0 | 800 | return SL_EZEROLEN; |
IanBenzMaxim | 0:33d4e66780c0 | 801 | } |
IanBenzMaxim | 0:33d4e66780c0 | 802 | |
IanBenzMaxim | 0:33d4e66780c0 | 803 | _SlDrvResetCmdExt(&CmdExt); |
IanBenzMaxim | 0:33d4e66780c0 | 804 | CmdExt.RxPayloadLen = (_i16)OutputbufferLength; |
IanBenzMaxim | 0:33d4e66780c0 | 805 | CmdExt.pRxPayload = (_u8 *)pOutputBuffer; |
IanBenzMaxim | 0:33d4e66780c0 | 806 | |
IanBenzMaxim | 0:33d4e66780c0 | 807 | Msg.Cmd.RxFilterOperation = RxFilterOperation; |
IanBenzMaxim | 0:33d4e66780c0 | 808 | Msg.Cmd.OutputBufferLength = OutputbufferLength; |
IanBenzMaxim | 0:33d4e66780c0 | 809 | |
IanBenzMaxim | 0:33d4e66780c0 | 810 | |
IanBenzMaxim | 0:33d4e66780c0 | 811 | VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlRxFilterGetCmdCtrl, &Msg, &CmdExt) ); |
IanBenzMaxim | 0:33d4e66780c0 | 812 | |
IanBenzMaxim | 0:33d4e66780c0 | 813 | if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) |
IanBenzMaxim | 0:33d4e66780c0 | 814 | { |
IanBenzMaxim | 0:33d4e66780c0 | 815 | return SL_ESMALLBUF; |
IanBenzMaxim | 0:33d4e66780c0 | 816 | } |
IanBenzMaxim | 0:33d4e66780c0 | 817 | |
IanBenzMaxim | 0:33d4e66780c0 | 818 | return (_i16)Msg.Rsp.Status; |
IanBenzMaxim | 0:33d4e66780c0 | 819 | } |
IanBenzMaxim | 0:33d4e66780c0 | 820 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 821 | |
IanBenzMaxim | 0:33d4e66780c0 | 822 | /*******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 823 | /* sl_WlanRxStatStart */ |
IanBenzMaxim | 0:33d4e66780c0 | 824 | /*******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 825 | #if _SL_INCLUDE_FUNC(sl_WlanRxStatStart) |
IanBenzMaxim | 0:33d4e66780c0 | 826 | _i16 sl_WlanRxStatStart(void) |
IanBenzMaxim | 0:33d4e66780c0 | 827 | { |
IanBenzMaxim | 0:33d4e66780c0 | 828 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 829 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 830 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 831 | |
IanBenzMaxim | 0:33d4e66780c0 | 832 | return _SlDrvBasicCmd(SL_OPCODE_WLAN_STARTRXSTATCOMMAND); |
IanBenzMaxim | 0:33d4e66780c0 | 833 | } |
IanBenzMaxim | 0:33d4e66780c0 | 834 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 835 | |
IanBenzMaxim | 0:33d4e66780c0 | 836 | #if _SL_INCLUDE_FUNC(sl_WlanRxStatStop) |
IanBenzMaxim | 0:33d4e66780c0 | 837 | _i16 sl_WlanRxStatStop(void) |
IanBenzMaxim | 0:33d4e66780c0 | 838 | { |
IanBenzMaxim | 0:33d4e66780c0 | 839 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 840 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 841 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 842 | |
IanBenzMaxim | 0:33d4e66780c0 | 843 | return _SlDrvBasicCmd(SL_OPCODE_WLAN_STOPRXSTATCOMMAND); |
IanBenzMaxim | 0:33d4e66780c0 | 844 | } |
IanBenzMaxim | 0:33d4e66780c0 | 845 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 846 | |
IanBenzMaxim | 0:33d4e66780c0 | 847 | #if _SL_INCLUDE_FUNC(sl_WlanRxStatGet) |
IanBenzMaxim | 0:33d4e66780c0 | 848 | _i16 sl_WlanRxStatGet(SlGetRxStatResponse_t *pRxStat,const _u32 Flags) |
IanBenzMaxim | 0:33d4e66780c0 | 849 | { |
IanBenzMaxim | 0:33d4e66780c0 | 850 | _SlCmdCtrl_t CmdCtrl = {SL_OPCODE_WLAN_GETRXSTATCOMMAND, 0, (_SlArgSize_t)sizeof(SlGetRxStatResponse_t)}; |
IanBenzMaxim | 0:33d4e66780c0 | 851 | |
IanBenzMaxim | 0:33d4e66780c0 | 852 | /* Flags paramater is currently not in use */ |
IanBenzMaxim | 0:33d4e66780c0 | 853 | (void)Flags; |
IanBenzMaxim | 0:33d4e66780c0 | 854 | |
IanBenzMaxim | 0:33d4e66780c0 | 855 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 856 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 857 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 858 | |
IanBenzMaxim | 0:33d4e66780c0 | 859 | _SlDrvMemZero(pRxStat, (_u16)sizeof(SlGetRxStatResponse_t)); |
IanBenzMaxim | 0:33d4e66780c0 | 860 | VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&CmdCtrl, pRxStat, NULL)); |
IanBenzMaxim | 0:33d4e66780c0 | 861 | |
IanBenzMaxim | 0:33d4e66780c0 | 862 | return 0; |
IanBenzMaxim | 0:33d4e66780c0 | 863 | } |
IanBenzMaxim | 0:33d4e66780c0 | 864 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 865 | |
IanBenzMaxim | 0:33d4e66780c0 | 866 | |
IanBenzMaxim | 0:33d4e66780c0 | 867 | |
IanBenzMaxim | 0:33d4e66780c0 | 868 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 869 | /* sl_WlanSmartConfigStop */ |
IanBenzMaxim | 0:33d4e66780c0 | 870 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 871 | #if _SL_INCLUDE_FUNC(sl_WlanSmartConfigStop) |
IanBenzMaxim | 0:33d4e66780c0 | 872 | _i16 sl_WlanSmartConfigStop(void) |
IanBenzMaxim | 0:33d4e66780c0 | 873 | { |
IanBenzMaxim | 0:33d4e66780c0 | 874 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 875 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 876 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 877 | |
IanBenzMaxim | 0:33d4e66780c0 | 878 | return _SlDrvBasicCmd(SL_OPCODE_WLAN_SMART_CONFIG_STOP_COMMAND); |
IanBenzMaxim | 0:33d4e66780c0 | 879 | } |
IanBenzMaxim | 0:33d4e66780c0 | 880 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 881 | |
IanBenzMaxim | 0:33d4e66780c0 | 882 | |
IanBenzMaxim | 0:33d4e66780c0 | 883 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 884 | /* sl_WlanSmartConfigStart */ |
IanBenzMaxim | 0:33d4e66780c0 | 885 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 886 | |
IanBenzMaxim | 0:33d4e66780c0 | 887 | |
IanBenzMaxim | 0:33d4e66780c0 | 888 | typedef struct |
IanBenzMaxim | 0:33d4e66780c0 | 889 | { |
IanBenzMaxim | 0:33d4e66780c0 | 890 | _WlanSmartConfigStartCommand_t Args; |
IanBenzMaxim | 0:33d4e66780c0 | 891 | _i8 Strings[3 * MAX_SMART_CONFIG_KEY]; /* public key + groupId1 key + groupId2 key */ |
IanBenzMaxim | 0:33d4e66780c0 | 892 | }_SlSmartConfigStart_t; |
IanBenzMaxim | 0:33d4e66780c0 | 893 | |
IanBenzMaxim | 0:33d4e66780c0 | 894 | typedef union |
IanBenzMaxim | 0:33d4e66780c0 | 895 | { |
IanBenzMaxim | 0:33d4e66780c0 | 896 | _SlSmartConfigStart_t Cmd; |
IanBenzMaxim | 0:33d4e66780c0 | 897 | _BasicResponse_t Rsp; |
IanBenzMaxim | 0:33d4e66780c0 | 898 | }_SlSmartConfigStartMsg_u; |
IanBenzMaxim | 0:33d4e66780c0 | 899 | |
IanBenzMaxim | 0:33d4e66780c0 | 900 | #if _SL_INCLUDE_FUNC(sl_WlanSmartConfigStart) |
IanBenzMaxim | 0:33d4e66780c0 | 901 | |
IanBenzMaxim | 0:33d4e66780c0 | 902 | static const _SlCmdCtrl_t _SlSmartConfigStartCmdCtrl = |
IanBenzMaxim | 0:33d4e66780c0 | 903 | { |
IanBenzMaxim | 0:33d4e66780c0 | 904 | SL_OPCODE_WLAN_SMART_CONFIG_START_COMMAND, |
IanBenzMaxim | 0:33d4e66780c0 | 905 | (_SlArgSize_t)sizeof(_SlSmartConfigStart_t), |
IanBenzMaxim | 0:33d4e66780c0 | 906 | (_SlArgSize_t)sizeof(_BasicResponse_t) |
IanBenzMaxim | 0:33d4e66780c0 | 907 | }; |
IanBenzMaxim | 0:33d4e66780c0 | 908 | |
IanBenzMaxim | 0:33d4e66780c0 | 909 | _i16 sl_WlanSmartConfigStart( const _u32 groupIdBitmask, |
IanBenzMaxim | 0:33d4e66780c0 | 910 | const _u8 cipher, |
IanBenzMaxim | 0:33d4e66780c0 | 911 | const _u8 publicKeyLen, |
IanBenzMaxim | 0:33d4e66780c0 | 912 | const _u8 group1KeyLen, |
IanBenzMaxim | 0:33d4e66780c0 | 913 | const _u8 group2KeyLen, |
IanBenzMaxim | 0:33d4e66780c0 | 914 | const _u8* pPublicKey, |
IanBenzMaxim | 0:33d4e66780c0 | 915 | const _u8* pGroup1Key, |
IanBenzMaxim | 0:33d4e66780c0 | 916 | const _u8* pGroup2Key) |
IanBenzMaxim | 0:33d4e66780c0 | 917 | { |
IanBenzMaxim | 0:33d4e66780c0 | 918 | _SlSmartConfigStartMsg_u Msg; |
IanBenzMaxim | 0:33d4e66780c0 | 919 | |
IanBenzMaxim | 0:33d4e66780c0 | 920 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 921 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 922 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 923 | |
IanBenzMaxim | 0:33d4e66780c0 | 924 | Msg.Cmd.Args.groupIdBitmask = (_u8)groupIdBitmask; |
IanBenzMaxim | 0:33d4e66780c0 | 925 | Msg.Cmd.Args.cipher = (_u8)cipher; |
IanBenzMaxim | 0:33d4e66780c0 | 926 | Msg.Cmd.Args.publicKeyLen = (_u8)publicKeyLen; |
IanBenzMaxim | 0:33d4e66780c0 | 927 | Msg.Cmd.Args.group1KeyLen = (_u8)group1KeyLen; |
IanBenzMaxim | 0:33d4e66780c0 | 928 | Msg.Cmd.Args.group2KeyLen = (_u8)group2KeyLen; |
IanBenzMaxim | 0:33d4e66780c0 | 929 | |
IanBenzMaxim | 0:33d4e66780c0 | 930 | /* copy keys (if exist) after command (one after another) */ |
IanBenzMaxim | 0:33d4e66780c0 | 931 | sl_Memcpy(SMART_CONFIG_START_PUBLIC_KEY_STRING(&Msg), pPublicKey, publicKeyLen); |
IanBenzMaxim | 0:33d4e66780c0 | 932 | sl_Memcpy(SMART_CONFIG_START_GROUP1_KEY_STRING(&Msg), pGroup1Key, group1KeyLen); |
IanBenzMaxim | 0:33d4e66780c0 | 933 | sl_Memcpy(SMART_CONFIG_START_GROUP2_KEY_STRING(&Msg), pGroup2Key, group2KeyLen); |
IanBenzMaxim | 0:33d4e66780c0 | 934 | |
IanBenzMaxim | 0:33d4e66780c0 | 935 | VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlSmartConfigStartCmdCtrl , &Msg, NULL)); |
IanBenzMaxim | 0:33d4e66780c0 | 936 | |
IanBenzMaxim | 0:33d4e66780c0 | 937 | return (_i16)Msg.Rsp.status; |
IanBenzMaxim | 0:33d4e66780c0 | 938 | |
IanBenzMaxim | 0:33d4e66780c0 | 939 | |
IanBenzMaxim | 0:33d4e66780c0 | 940 | } |
IanBenzMaxim | 0:33d4e66780c0 | 941 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 942 | |
IanBenzMaxim | 0:33d4e66780c0 | 943 | |
IanBenzMaxim | 0:33d4e66780c0 | 944 | /*******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 945 | /* sl_WlanSetMode */ |
IanBenzMaxim | 0:33d4e66780c0 | 946 | /*******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 947 | typedef union |
IanBenzMaxim | 0:33d4e66780c0 | 948 | { |
IanBenzMaxim | 0:33d4e66780c0 | 949 | _WlanSetMode_t Cmd; |
IanBenzMaxim | 0:33d4e66780c0 | 950 | _BasicResponse_t Rsp; |
IanBenzMaxim | 0:33d4e66780c0 | 951 | }_SlwlanSetModeMsg_u; |
IanBenzMaxim | 0:33d4e66780c0 | 952 | |
IanBenzMaxim | 0:33d4e66780c0 | 953 | #if _SL_INCLUDE_FUNC(sl_WlanSetMode) |
IanBenzMaxim | 0:33d4e66780c0 | 954 | |
IanBenzMaxim | 0:33d4e66780c0 | 955 | static const _SlCmdCtrl_t _SlWlanSetModeCmdCtrl = |
IanBenzMaxim | 0:33d4e66780c0 | 956 | { |
IanBenzMaxim | 0:33d4e66780c0 | 957 | SL_OPCODE_WLAN_SET_MODE, |
IanBenzMaxim | 0:33d4e66780c0 | 958 | (_SlArgSize_t)sizeof(_WlanSetMode_t), |
IanBenzMaxim | 0:33d4e66780c0 | 959 | (_SlArgSize_t)sizeof(_BasicResponse_t) |
IanBenzMaxim | 0:33d4e66780c0 | 960 | }; |
IanBenzMaxim | 0:33d4e66780c0 | 961 | |
IanBenzMaxim | 0:33d4e66780c0 | 962 | /* possible values are: |
IanBenzMaxim | 0:33d4e66780c0 | 963 | WLAN_SET_STA_MODE = 1 |
IanBenzMaxim | 0:33d4e66780c0 | 964 | WLAN_SET_AP_MODE = 2 |
IanBenzMaxim | 0:33d4e66780c0 | 965 | WLAN_SET_P2P_MODE = 3 */ |
IanBenzMaxim | 0:33d4e66780c0 | 966 | _i16 sl_WlanSetMode(const _u8 mode) |
IanBenzMaxim | 0:33d4e66780c0 | 967 | { |
IanBenzMaxim | 0:33d4e66780c0 | 968 | _SlwlanSetModeMsg_u Msg; |
IanBenzMaxim | 0:33d4e66780c0 | 969 | |
IanBenzMaxim | 0:33d4e66780c0 | 970 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 971 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 972 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 973 | |
IanBenzMaxim | 0:33d4e66780c0 | 974 | Msg.Cmd.mode = mode; |
IanBenzMaxim | 0:33d4e66780c0 | 975 | |
IanBenzMaxim | 0:33d4e66780c0 | 976 | VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanSetModeCmdCtrl , &Msg, NULL)); |
IanBenzMaxim | 0:33d4e66780c0 | 977 | |
IanBenzMaxim | 0:33d4e66780c0 | 978 | return (_i16)Msg.Rsp.status; |
IanBenzMaxim | 0:33d4e66780c0 | 979 | } |
IanBenzMaxim | 0:33d4e66780c0 | 980 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 981 | |
IanBenzMaxim | 0:33d4e66780c0 | 982 | |
IanBenzMaxim | 0:33d4e66780c0 | 983 | |
IanBenzMaxim | 0:33d4e66780c0 | 984 | |
IanBenzMaxim | 0:33d4e66780c0 | 985 | /*******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 986 | /* sl_WlanSet */ |
IanBenzMaxim | 0:33d4e66780c0 | 987 | /* ******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 988 | typedef union |
IanBenzMaxim | 0:33d4e66780c0 | 989 | { |
IanBenzMaxim | 0:33d4e66780c0 | 990 | _WlanCfgSetGet_t Cmd; |
IanBenzMaxim | 0:33d4e66780c0 | 991 | _BasicResponse_t Rsp; |
IanBenzMaxim | 0:33d4e66780c0 | 992 | }_SlWlanCfgSetMsg_u; |
IanBenzMaxim | 0:33d4e66780c0 | 993 | |
IanBenzMaxim | 0:33d4e66780c0 | 994 | |
IanBenzMaxim | 0:33d4e66780c0 | 995 | #if _SL_INCLUDE_FUNC(sl_WlanSet) |
IanBenzMaxim | 0:33d4e66780c0 | 996 | |
IanBenzMaxim | 0:33d4e66780c0 | 997 | static const _SlCmdCtrl_t _SlWlanCfgSetCmdCtrl = |
IanBenzMaxim | 0:33d4e66780c0 | 998 | { |
IanBenzMaxim | 0:33d4e66780c0 | 999 | SL_OPCODE_WLAN_CFG_SET, |
IanBenzMaxim | 0:33d4e66780c0 | 1000 | (_SlArgSize_t)sizeof(_WlanCfgSetGet_t), |
IanBenzMaxim | 0:33d4e66780c0 | 1001 | (_SlArgSize_t)sizeof(_BasicResponse_t) |
IanBenzMaxim | 0:33d4e66780c0 | 1002 | }; |
IanBenzMaxim | 0:33d4e66780c0 | 1003 | |
IanBenzMaxim | 0:33d4e66780c0 | 1004 | _i16 sl_WlanSet(const _u16 ConfigId ,const _u16 ConfigOpt,const _u16 ConfigLen,const _u8 *pValues) |
IanBenzMaxim | 0:33d4e66780c0 | 1005 | { |
IanBenzMaxim | 0:33d4e66780c0 | 1006 | _SlWlanCfgSetMsg_u Msg; |
IanBenzMaxim | 0:33d4e66780c0 | 1007 | _SlCmdExt_t CmdExt; |
IanBenzMaxim | 0:33d4e66780c0 | 1008 | |
IanBenzMaxim | 0:33d4e66780c0 | 1009 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 1010 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 1011 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 1012 | |
IanBenzMaxim | 0:33d4e66780c0 | 1013 | _SlDrvResetCmdExt(&CmdExt); |
IanBenzMaxim | 0:33d4e66780c0 | 1014 | CmdExt.TxPayloadLen = (_u16)((ConfigLen+3) & (~3)); |
IanBenzMaxim | 0:33d4e66780c0 | 1015 | CmdExt.pTxPayload = (_u8 *)pValues; |
IanBenzMaxim | 0:33d4e66780c0 | 1016 | |
IanBenzMaxim | 0:33d4e66780c0 | 1017 | Msg.Cmd.ConfigId = ConfigId; |
IanBenzMaxim | 0:33d4e66780c0 | 1018 | Msg.Cmd.ConfigLen = ConfigLen; |
IanBenzMaxim | 0:33d4e66780c0 | 1019 | Msg.Cmd.ConfigOpt = ConfigOpt; |
IanBenzMaxim | 0:33d4e66780c0 | 1020 | |
IanBenzMaxim | 0:33d4e66780c0 | 1021 | VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanCfgSetCmdCtrl, &Msg, &CmdExt)); |
IanBenzMaxim | 0:33d4e66780c0 | 1022 | |
IanBenzMaxim | 0:33d4e66780c0 | 1023 | return (_i16)Msg.Rsp.status; |
IanBenzMaxim | 0:33d4e66780c0 | 1024 | } |
IanBenzMaxim | 0:33d4e66780c0 | 1025 | #endif |
IanBenzMaxim | 0:33d4e66780c0 | 1026 | |
IanBenzMaxim | 0:33d4e66780c0 | 1027 | |
IanBenzMaxim | 0:33d4e66780c0 | 1028 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 1029 | /* sl_WlanGet */ |
IanBenzMaxim | 0:33d4e66780c0 | 1030 | /******************************************************************************/ |
IanBenzMaxim | 0:33d4e66780c0 | 1031 | typedef union |
IanBenzMaxim | 0:33d4e66780c0 | 1032 | { |
IanBenzMaxim | 0:33d4e66780c0 | 1033 | _WlanCfgSetGet_t Cmd; |
IanBenzMaxim | 0:33d4e66780c0 | 1034 | _WlanCfgSetGet_t Rsp; |
IanBenzMaxim | 0:33d4e66780c0 | 1035 | }_SlWlanCfgMsgGet_u; |
IanBenzMaxim | 0:33d4e66780c0 | 1036 | |
IanBenzMaxim | 0:33d4e66780c0 | 1037 | #if _SL_INCLUDE_FUNC(sl_WlanGet) |
IanBenzMaxim | 0:33d4e66780c0 | 1038 | |
IanBenzMaxim | 0:33d4e66780c0 | 1039 | static const _SlCmdCtrl_t _SlWlanCfgGetCmdCtrl = |
IanBenzMaxim | 0:33d4e66780c0 | 1040 | { |
IanBenzMaxim | 0:33d4e66780c0 | 1041 | SL_OPCODE_WLAN_CFG_GET, |
IanBenzMaxim | 0:33d4e66780c0 | 1042 | (_SlArgSize_t)sizeof(_WlanCfgSetGet_t), |
IanBenzMaxim | 0:33d4e66780c0 | 1043 | (_SlArgSize_t)sizeof(_WlanCfgSetGet_t) |
IanBenzMaxim | 0:33d4e66780c0 | 1044 | }; |
IanBenzMaxim | 0:33d4e66780c0 | 1045 | |
IanBenzMaxim | 0:33d4e66780c0 | 1046 | _i16 sl_WlanGet(const _u16 ConfigId, _u16 *pConfigOpt,_u16 *pConfigLen, _u8 *pValues) |
IanBenzMaxim | 0:33d4e66780c0 | 1047 | { |
IanBenzMaxim | 0:33d4e66780c0 | 1048 | _SlWlanCfgMsgGet_u Msg; |
IanBenzMaxim | 0:33d4e66780c0 | 1049 | _SlCmdExt_t CmdExt; |
IanBenzMaxim | 0:33d4e66780c0 | 1050 | |
IanBenzMaxim | 0:33d4e66780c0 | 1051 | /* verify no erorr handling in progress. if in progress than |
IanBenzMaxim | 0:33d4e66780c0 | 1052 | ignore the API execution and return immediately with an error */ |
IanBenzMaxim | 0:33d4e66780c0 | 1053 | VERIFY_NO_ERROR_HANDLING_IN_PROGRESS(); |
IanBenzMaxim | 0:33d4e66780c0 | 1054 | |
IanBenzMaxim | 0:33d4e66780c0 | 1055 | if (*pConfigLen == 0) |
IanBenzMaxim | 0:33d4e66780c0 | 1056 | { |
IanBenzMaxim | 0:33d4e66780c0 | 1057 | return SL_EZEROLEN; |
IanBenzMaxim | 0:33d4e66780c0 | 1058 | } |
IanBenzMaxim | 0:33d4e66780c0 | 1059 | |
IanBenzMaxim | 0:33d4e66780c0 | 1060 | _SlDrvResetCmdExt(&CmdExt); |
IanBenzMaxim | 0:33d4e66780c0 | 1061 | CmdExt.RxPayloadLen = (_i16)*pConfigLen; |
IanBenzMaxim | 0:33d4e66780c0 | 1062 | CmdExt.pRxPayload = (_u8 *)pValues; |
IanBenzMaxim | 0:33d4e66780c0 | 1063 | |
IanBenzMaxim | 0:33d4e66780c0 | 1064 | Msg.Cmd.ConfigId = ConfigId; |
IanBenzMaxim | 0:33d4e66780c0 | 1065 | Msg.Cmd.ConfigLen = *pConfigLen; |
IanBenzMaxim | 0:33d4e66780c0 | 1066 | |
IanBenzMaxim | 0:33d4e66780c0 | 1067 | if( pConfigOpt ) |
IanBenzMaxim | 0:33d4e66780c0 | 1068 | { |
IanBenzMaxim | 0:33d4e66780c0 | 1069 | Msg.Cmd.ConfigOpt = (_u16)*pConfigOpt; |
IanBenzMaxim | 0:33d4e66780c0 | 1070 | } |
IanBenzMaxim | 0:33d4e66780c0 | 1071 | VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlWlanCfgGetCmdCtrl, &Msg, &CmdExt)); |
IanBenzMaxim | 0:33d4e66780c0 | 1072 | |
IanBenzMaxim | 0:33d4e66780c0 | 1073 | if( pConfigOpt ) |
IanBenzMaxim | 0:33d4e66780c0 | 1074 | { |
IanBenzMaxim | 0:33d4e66780c0 | 1075 | *pConfigOpt = (_u8)Msg.Rsp.ConfigOpt; |
IanBenzMaxim | 0:33d4e66780c0 | 1076 | } |
IanBenzMaxim | 0:33d4e66780c0 | 1077 | if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen) |
IanBenzMaxim | 0:33d4e66780c0 | 1078 | { |
IanBenzMaxim | 0:33d4e66780c0 | 1079 | *pConfigLen = (_u8)CmdExt.RxPayloadLen; |
IanBenzMaxim | 0:33d4e66780c0 | 1080 | return SL_ESMALLBUF; |
IanBenzMaxim | 0:33d4e66780c0 | 1081 | } |
IanBenzMaxim | 0:33d4e66780c0 | 1082 | else |
IanBenzMaxim | 0:33d4e66780c0 | 1083 | { |
IanBenzMaxim | 0:33d4e66780c0 | 1084 | *pConfigLen = (_u8)CmdExt.ActualRxPayloadLen; |
IanBenzMaxim | 0:33d4e66780c0 | 1085 | } |
IanBenzMaxim | 0:33d4e66780c0 | 1086 | |
IanBenzMaxim | 0:33d4e66780c0 | 1087 | |
IanBenzMaxim | 0:33d4e66780c0 | 1088 | return (_i16)Msg.Rsp.Status; |
IanBenzMaxim | 0:33d4e66780c0 | 1089 | } |
IanBenzMaxim | 0:33d4e66780c0 | 1090 | #endif |