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.

Committer:
IanBenzMaxim
Date:
Thu Oct 03 11:40:13 2019 -0500
Revision:
16:a004191a79ab
Parent:
simplelink/include/netcfg.h@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?

UserRevisionLine numberNew contents of line
IanBenzMaxim 0:33d4e66780c0 1 /*
IanBenzMaxim 0:33d4e66780c0 2 * netcfg.h - 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 /* Include files */
IanBenzMaxim 0:33d4e66780c0 39 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 40 #include "simplelink.h"
IanBenzMaxim 0:33d4e66780c0 41
IanBenzMaxim 0:33d4e66780c0 42
IanBenzMaxim 0:33d4e66780c0 43 #ifndef __NETCFG_H__
IanBenzMaxim 0:33d4e66780c0 44 #define __NETCFG_H__
IanBenzMaxim 0:33d4e66780c0 45
IanBenzMaxim 0:33d4e66780c0 46
IanBenzMaxim 0:33d4e66780c0 47 #ifdef __cplusplus
IanBenzMaxim 0:33d4e66780c0 48 extern "C" {
IanBenzMaxim 0:33d4e66780c0 49 #endif
IanBenzMaxim 0:33d4e66780c0 50
IanBenzMaxim 0:33d4e66780c0 51
IanBenzMaxim 0:33d4e66780c0 52
IanBenzMaxim 0:33d4e66780c0 53 /*!
IanBenzMaxim 0:33d4e66780c0 54
IanBenzMaxim 0:33d4e66780c0 55 \addtogroup netcfg
IanBenzMaxim 0:33d4e66780c0 56 @{
IanBenzMaxim 0:33d4e66780c0 57
IanBenzMaxim 0:33d4e66780c0 58 */
IanBenzMaxim 0:33d4e66780c0 59
IanBenzMaxim 0:33d4e66780c0 60
IanBenzMaxim 0:33d4e66780c0 61 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 62 /* Macro declarations */
IanBenzMaxim 0:33d4e66780c0 63 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 64
IanBenzMaxim 0:33d4e66780c0 65 #define SL_MAC_ADDR_LEN (6)
IanBenzMaxim 0:33d4e66780c0 66 #define SL_IPV4_VAL(add_3,add_2,add_1,add_0) ((((_u32)add_3 << 24) & 0xFF000000) | (((_u32)add_2 << 16) & 0xFF0000) | (((_u32)add_1 << 8) & 0xFF00) | ((_u32)add_0 & 0xFF) )
IanBenzMaxim 0:33d4e66780c0 67 #define SL_IPV4_BYTE(val,index) ( (val >> (index*8)) & 0xFF )
IanBenzMaxim 0:33d4e66780c0 68
IanBenzMaxim 0:33d4e66780c0 69 #define IPCONFIG_MODE_DISABLE_IPV4 (0)
IanBenzMaxim 0:33d4e66780c0 70 #define IPCONFIG_MODE_ENABLE_IPV4 (1)
IanBenzMaxim 0:33d4e66780c0 71
IanBenzMaxim 0:33d4e66780c0 72 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 73 /* Structure/Enum declarations */
IanBenzMaxim 0:33d4e66780c0 74 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 75 typedef enum
IanBenzMaxim 0:33d4e66780c0 76 {
IanBenzMaxim 0:33d4e66780c0 77 SL_MAC_ADDRESS_SET = 1,
IanBenzMaxim 0:33d4e66780c0 78 SL_MAC_ADDRESS_GET = 2,
IanBenzMaxim 0:33d4e66780c0 79 SL_IPV4_STA_P2P_CL_GET_INFO = 3,
IanBenzMaxim 0:33d4e66780c0 80 SL_IPV4_STA_P2P_CL_DHCP_ENABLE = 4,
IanBenzMaxim 0:33d4e66780c0 81 SL_IPV4_STA_P2P_CL_STATIC_ENABLE = 5,
IanBenzMaxim 0:33d4e66780c0 82 SL_IPV4_AP_P2P_GO_GET_INFO = 6,
IanBenzMaxim 0:33d4e66780c0 83 SL_IPV4_AP_P2P_GO_STATIC_ENABLE = 7,
IanBenzMaxim 0:33d4e66780c0 84 SL_SET_HOST_RX_AGGR = 8,
IanBenzMaxim 0:33d4e66780c0 85 SL_IPV4_DHCP_CLIENT = 9,
IanBenzMaxim 0:33d4e66780c0 86 SL_IPV4_DNS_CLIENT = 10,
IanBenzMaxim 0:33d4e66780c0 87 SL_IPV4_ARP_FLUSH = 11,
IanBenzMaxim 0:33d4e66780c0 88 MAX_SETTINGS = 0xFF
IanBenzMaxim 0:33d4e66780c0 89 }Sl_NetCfg_e;
IanBenzMaxim 0:33d4e66780c0 90
IanBenzMaxim 0:33d4e66780c0 91
IanBenzMaxim 0:33d4e66780c0 92 typedef struct
IanBenzMaxim 0:33d4e66780c0 93 {
IanBenzMaxim 0:33d4e66780c0 94 _u32 ipV4;
IanBenzMaxim 0:33d4e66780c0 95 _u32 ipV4Mask;
IanBenzMaxim 0:33d4e66780c0 96 _u32 ipV4Gateway;
IanBenzMaxim 0:33d4e66780c0 97 _u32 ipV4DnsServer;
IanBenzMaxim 0:33d4e66780c0 98 }SlNetCfgIpV4Args_t;
IanBenzMaxim 0:33d4e66780c0 99
IanBenzMaxim 0:33d4e66780c0 100 typedef struct
IanBenzMaxim 0:33d4e66780c0 101 {
IanBenzMaxim 0:33d4e66780c0 102 _u32 Ip;
IanBenzMaxim 0:33d4e66780c0 103 _u32 Gateway;
IanBenzMaxim 0:33d4e66780c0 104 _u32 Mask;
IanBenzMaxim 0:33d4e66780c0 105 _u32 Dns[2];
IanBenzMaxim 0:33d4e66780c0 106 _u32 DhcpServer;
IanBenzMaxim 0:33d4e66780c0 107 _u32 LeaseTime;
IanBenzMaxim 0:33d4e66780c0 108 _u8 DhcpState;
IanBenzMaxim 0:33d4e66780c0 109 _u8 Reserved[3];
IanBenzMaxim 0:33d4e66780c0 110 }SlNetCfgIpV4DhcpClientArgs_t;
IanBenzMaxim 0:33d4e66780c0 111
IanBenzMaxim 0:33d4e66780c0 112 typedef enum
IanBenzMaxim 0:33d4e66780c0 113 {
IanBenzMaxim 0:33d4e66780c0 114 SL_NETCFG_DHCP_CLIENT_UNKNOWN = 0,
IanBenzMaxim 0:33d4e66780c0 115 SL_NETCFG_DHCP_CLIENT_DISABLED,
IanBenzMaxim 0:33d4e66780c0 116 SL_NETCFG_DHCP_CLIENT_ENABLED,
IanBenzMaxim 0:33d4e66780c0 117 SL_NETCFG_DHCP_CLIENT_BOUND,
IanBenzMaxim 0:33d4e66780c0 118 SL_NETCFG_DHCP_CLIENT_RENEW,
IanBenzMaxim 0:33d4e66780c0 119 SL_NETCFG_DHCP_CLIENT_REBIND
IanBenzMaxim 0:33d4e66780c0 120 }SlNetCfgIpv4DhcpClientState_e;
IanBenzMaxim 0:33d4e66780c0 121
IanBenzMaxim 0:33d4e66780c0 122 typedef struct
IanBenzMaxim 0:33d4e66780c0 123 {
IanBenzMaxim 0:33d4e66780c0 124 _u32 DnsSecondServerAddr;
IanBenzMaxim 0:33d4e66780c0 125 _u32 DnsMaxRetries;
IanBenzMaxim 0:33d4e66780c0 126 }SlNetCfgIpV4DnsClientArgs_t;
IanBenzMaxim 0:33d4e66780c0 127
IanBenzMaxim 0:33d4e66780c0 128 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 129 /* Function prototypes */
IanBenzMaxim 0:33d4e66780c0 130 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 131
IanBenzMaxim 0:33d4e66780c0 132 /*!
IanBenzMaxim 0:33d4e66780c0 133 \brief Internal function for setting network configurations
IanBenzMaxim 0:33d4e66780c0 134
IanBenzMaxim 0:33d4e66780c0 135 \return On success, zero is returned. On error, -1 is
IanBenzMaxim 0:33d4e66780c0 136 returned
IanBenzMaxim 0:33d4e66780c0 137
IanBenzMaxim 0:33d4e66780c0 138 \param[in] ConfigId configuration id
IanBenzMaxim 0:33d4e66780c0 139 \param[in] ConfigOpt configurations option
IanBenzMaxim 0:33d4e66780c0 140 \param[in] ConfigLen configurations len
IanBenzMaxim 0:33d4e66780c0 141 \param[in] pValues configurations values
IanBenzMaxim 0:33d4e66780c0 142
IanBenzMaxim 0:33d4e66780c0 143 \sa
IanBenzMaxim 0:33d4e66780c0 144 \note
IanBenzMaxim 0:33d4e66780c0 145 \warning
IanBenzMaxim 0:33d4e66780c0 146
IanBenzMaxim 0:33d4e66780c0 147 \par Examples:
IanBenzMaxim 0:33d4e66780c0 148 \code
IanBenzMaxim 0:33d4e66780c0 149 SL_MAC_ADDRESS_SET:
IanBenzMaxim 0:33d4e66780c0 150
IanBenzMaxim 0:33d4e66780c0 151 Setting MAC address to the Device.
IanBenzMaxim 0:33d4e66780c0 152 The new MAC address will override the default MAC address and it be saved in the FileSystem.
IanBenzMaxim 0:33d4e66780c0 153 Requires restarting the device for updating this setting.
IanBenzMaxim 0:33d4e66780c0 154
IanBenzMaxim 0:33d4e66780c0 155 _u8 MAC_Address[6];
IanBenzMaxim 0:33d4e66780c0 156 MAC_Address[0] = 0x8;
IanBenzMaxim 0:33d4e66780c0 157 MAC_Address[1] = 0x0;
IanBenzMaxim 0:33d4e66780c0 158 MAC_Address[2] = 0x28;
IanBenzMaxim 0:33d4e66780c0 159 MAC_Address[3] = 0x22;
IanBenzMaxim 0:33d4e66780c0 160 MAC_Address[4] = 0x69;
IanBenzMaxim 0:33d4e66780c0 161 MAC_Address[5] = 0x31;
IanBenzMaxim 0:33d4e66780c0 162 sl_NetCfgSet(SL_MAC_ADDRESS_SET,1,SL_MAC_ADDR_LEN,(_u8 *)newMacAddress);
IanBenzMaxim 0:33d4e66780c0 163 sl_Stop(0);
IanBenzMaxim 0:33d4e66780c0 164 sl_Start(NULL,NULL,NULL);
IanBenzMaxim 0:33d4e66780c0 165 \endcode
IanBenzMaxim 0:33d4e66780c0 166
IanBenzMaxim 0:33d4e66780c0 167 \code
IanBenzMaxim 0:33d4e66780c0 168 SL_IPV4_STA_P2P_CL_STATIC_ENABLE:
IanBenzMaxim 0:33d4e66780c0 169
IanBenzMaxim 0:33d4e66780c0 170 Setting a static IP address to the device working in STA mode or P2P client.
IanBenzMaxim 0:33d4e66780c0 171 The IP address will be stored in the FileSystem.
IanBenzMaxim 0:33d4e66780c0 172 In order to disable the static IP and get the address assigned from DHCP one should use SL_STA_P2P_CL_IPV4_DHCP_SET
IanBenzMaxim 0:33d4e66780c0 173
IanBenzMaxim 0:33d4e66780c0 174 SlNetCfgIpV4Args_t ipV4;
IanBenzMaxim 0:33d4e66780c0 175 ipV4.ipV4 = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address
IanBenzMaxim 0:33d4e66780c0 176 ipV4.ipV4Mask = (_u32)SL_IPV4_VAL(255,255,255,0); // _u32 Subnet mask for this STA/P2P
IanBenzMaxim 0:33d4e66780c0 177 ipV4.ipV4Gateway = (_u32)SL_IPV4_VAL(10,1,1,1); // _u32 Default gateway address
IanBenzMaxim 0:33d4e66780c0 178 ipV4.ipV4DnsServer = (_u32)SL_IPV4_VAL(8,16,32,64); // _u32 DNS server address
IanBenzMaxim 0:33d4e66780c0 179
IanBenzMaxim 0:33d4e66780c0 180 sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,sizeof(SlNetCfgIpV4Args_t),(_u8 *)&ipV4);
IanBenzMaxim 0:33d4e66780c0 181 sl_Stop(0);
IanBenzMaxim 0:33d4e66780c0 182 sl_Start(NULL,NULL,NULL);
IanBenzMaxim 0:33d4e66780c0 183 \endcode
IanBenzMaxim 0:33d4e66780c0 184
IanBenzMaxim 0:33d4e66780c0 185 \code
IanBenzMaxim 0:33d4e66780c0 186 SL_IPV4_STA_P2P_CL_DHCP_ENABLE:
IanBenzMaxim 0:33d4e66780c0 187
IanBenzMaxim 0:33d4e66780c0 188 Setting IP address by DHCP to FileSystem using WLAN sta mode or P2P client.
IanBenzMaxim 0:33d4e66780c0 189 This should be done once if using Serial Flash.
IanBenzMaxim 0:33d4e66780c0 190 This is the system's default mode for acquiring an IP address after WLAN connection.
IanBenzMaxim 0:33d4e66780c0 191 _u8 val = 1;
IanBenzMaxim 0:33d4e66780c0 192 sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,1,&val);
IanBenzMaxim 0:33d4e66780c0 193 sl_Stop(0);
IanBenzMaxim 0:33d4e66780c0 194 sl_Start(NULL,NULL,NULL);
IanBenzMaxim 0:33d4e66780c0 195 \endcode
IanBenzMaxim 0:33d4e66780c0 196
IanBenzMaxim 0:33d4e66780c0 197 \code
IanBenzMaxim 0:33d4e66780c0 198 SL_IPV4_AP_P2P_GO_STATIC_ENABLE:
IanBenzMaxim 0:33d4e66780c0 199
IanBenzMaxim 0:33d4e66780c0 200 Setting a static IP address to the device working in AP mode or P2P go.
IanBenzMaxim 0:33d4e66780c0 201 The IP address will be stored in the FileSystem. Requires restart.
IanBenzMaxim 0:33d4e66780c0 202
IanBenzMaxim 0:33d4e66780c0 203 SlNetCfgIpV4Args_t ipV4;
IanBenzMaxim 0:33d4e66780c0 204 ipV4.ipV4 = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address
IanBenzMaxim 0:33d4e66780c0 205 ipV4.ipV4Mask = (_u32)SL_IPV4_VAL(255,255,255,0); // _u32 Subnet mask for this AP/P2P
IanBenzMaxim 0:33d4e66780c0 206 ipV4.ipV4Gateway = (_u32)SL_IPV4_VAL(10,1,1,1); // _u32 Default gateway address
IanBenzMaxim 0:33d4e66780c0 207 ipV4.ipV4DnsServer = (_u32)SL_IPV4_VAL(8,16,32,64); // _u32 DNS server address
IanBenzMaxim 0:33d4e66780c0 208
IanBenzMaxim 0:33d4e66780c0 209 sl_NetCfgSet(SL_IPV4_AP_P2P_GO_STATIC_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,sizeof(SlNetCfgIpV4Args_t),(_u8 *)&ipV4);
IanBenzMaxim 0:33d4e66780c0 210 sl_Stop(0);
IanBenzMaxim 0:33d4e66780c0 211 sl_Start(NULL,NULL,NULL);
IanBenzMaxim 0:33d4e66780c0 212 \endcode
IanBenzMaxim 0:33d4e66780c0 213
IanBenzMaxim 0:33d4e66780c0 214 \code
IanBenzMaxim 0:33d4e66780c0 215 SL_IPV4_DNS_CLIENT:
IanBenzMaxim 0:33d4e66780c0 216
IanBenzMaxim 0:33d4e66780c0 217 Set DNS max retries (range 5-32, default 32 retries) and secondary DNS address (DHCP and static configuration)
IanBenzMaxim 0:33d4e66780c0 218 changes not saved on the internal flash.
IanBenzMaxim 0:33d4e66780c0 219
IanBenzMaxim 0:33d4e66780c0 220 _i32 Status;
IanBenzMaxim 0:33d4e66780c0 221 SlNetCfgIpV4DnsClientArgs_t DnsOpt;
IanBenzMaxim 0:33d4e66780c0 222 DnsOpt.DnsSecondServerAddr = SL_IPV4_VAL(8,8,8,8); ;
IanBenzMaxim 0:33d4e66780c0 223 DnsOpt.DnsMaxRetries = 12;
IanBenzMaxim 0:33d4e66780c0 224 Status = sl_NetCfgSet(SL_IPV4_DNS_CLIENT,0,sizeof(SlNetCfgIpV4DnsClientArgs_t),(unsigned char *)&DnsOpt);
IanBenzMaxim 0:33d4e66780c0 225 if( Status )
IanBenzMaxim 0:33d4e66780c0 226 {
IanBenzMaxim 0:33d4e66780c0 227 // error
IanBenzMaxim 0:33d4e66780c0 228 }
IanBenzMaxim 0:33d4e66780c0 229 \endcode
IanBenzMaxim 0:33d4e66780c0 230 \code
IanBenzMaxim 0:33d4e66780c0 231 SL_IPV4_ARP_FLUSH:
IanBenzMaxim 0:33d4e66780c0 232
IanBenzMaxim 0:33d4e66780c0 233 Flush ARP table
IanBenzMaxim 0:33d4e66780c0 234
IanBenzMaxim 0:33d4e66780c0 235 _i32 Status;
IanBenzMaxim 0:33d4e66780c0 236 Status = sl_NetCfgSet(SL_IPV4_ARP_FLUSH,0,0,NULL);
IanBenzMaxim 0:33d4e66780c0 237 if( Status )
IanBenzMaxim 0:33d4e66780c0 238 {
IanBenzMaxim 0:33d4e66780c0 239 //
IanBenzMaxim 0:33d4e66780c0 240 }
IanBenzMaxim 0:33d4e66780c0 241 \endcode
IanBenzMaxim 0:33d4e66780c0 242
IanBenzMaxim 0:33d4e66780c0 243 */
IanBenzMaxim 0:33d4e66780c0 244 #if _SL_INCLUDE_FUNC(sl_NetCfgSet)
IanBenzMaxim 0:33d4e66780c0 245 _i32 sl_NetCfgSet(const _u8 ConfigId,const _u8 ConfigOpt,const _u8 ConfigLen,const _u8 *pValues);
IanBenzMaxim 0:33d4e66780c0 246 #endif
IanBenzMaxim 0:33d4e66780c0 247
IanBenzMaxim 0:33d4e66780c0 248
IanBenzMaxim 0:33d4e66780c0 249 /*!
IanBenzMaxim 0:33d4e66780c0 250 \brief Internal function for getting network configurations
IanBenzMaxim 0:33d4e66780c0 251
IanBenzMaxim 0:33d4e66780c0 252 \return On success, zero is returned. On error, -1 is
IanBenzMaxim 0:33d4e66780c0 253 returned
IanBenzMaxim 0:33d4e66780c0 254
IanBenzMaxim 0:33d4e66780c0 255 \param[in] ConfigId configuration id
IanBenzMaxim 0:33d4e66780c0 256
IanBenzMaxim 0:33d4e66780c0 257 \param[out] pConfigOpt Get configurations option
IanBenzMaxim 0:33d4e66780c0 258
IanBenzMaxim 0:33d4e66780c0 259 \param[out] pConfigLen The length of the allocated memory as input, when the
IanBenzMaxim 0:33d4e66780c0 260 function complete, the value of this parameter would be
IanBenzMaxim 0:33d4e66780c0 261 the len that actually read from the device.\n
IanBenzMaxim 0:33d4e66780c0 262 If the device return length that is longer from the input
IanBenzMaxim 0:33d4e66780c0 263 value, the function will cut the end of the returned structure
IanBenzMaxim 0:33d4e66780c0 264 and will return ESMALLBUF
IanBenzMaxim 0:33d4e66780c0 265
IanBenzMaxim 0:33d4e66780c0 266 \param[out] pValues - get configurations values
IanBenzMaxim 0:33d4e66780c0 267
IanBenzMaxim 0:33d4e66780c0 268 \sa
IanBenzMaxim 0:33d4e66780c0 269 \note
IanBenzMaxim 0:33d4e66780c0 270 \warning
IanBenzMaxim 0:33d4e66780c0 271 \par Examples:
IanBenzMaxim 0:33d4e66780c0 272 \code
IanBenzMaxim 0:33d4e66780c0 273 SL_MAC_ADDRESS_GET:
IanBenzMaxim 0:33d4e66780c0 274
IanBenzMaxim 0:33d4e66780c0 275 Get the device MAC address.
IanBenzMaxim 0:33d4e66780c0 276 The returned MAC address is taken from FileSystem first. If the MAC address was not set by SL_MAC_ADDRESS_SET, the default MAC address
IanBenzMaxim 0:33d4e66780c0 277 is retrieved from HW.
IanBenzMaxim 0:33d4e66780c0 278
IanBenzMaxim 0:33d4e66780c0 279 _u8 macAddressVal[SL_MAC_ADDR_LEN];
IanBenzMaxim 0:33d4e66780c0 280 _u8 macAddressLen = SL_MAC_ADDR_LEN;
IanBenzMaxim 0:33d4e66780c0 281 sl_NetCfgGet(SL_MAC_ADDRESS_GET,NULL,&macAddressLen,(_u8 *)macAddressVal);
IanBenzMaxim 0:33d4e66780c0 282
IanBenzMaxim 0:33d4e66780c0 283 \endcode
IanBenzMaxim 0:33d4e66780c0 284
IanBenzMaxim 0:33d4e66780c0 285 \code
IanBenzMaxim 0:33d4e66780c0 286 SL_IPV4_STA_P2P_CL_GET_INFO:
IanBenzMaxim 0:33d4e66780c0 287
IanBenzMaxim 0:33d4e66780c0 288 Get IP address from WLAN station or P2P client. A DHCP flag is returned to indicate if the IP address is static or from DHCP.
IanBenzMaxim 0:33d4e66780c0 289
IanBenzMaxim 0:33d4e66780c0 290 _u8 len = sizeof(SlNetCfgIpV4Args_t);
IanBenzMaxim 0:33d4e66780c0 291 _u8 dhcpIsOn = 0;
IanBenzMaxim 0:33d4e66780c0 292 SlNetCfgIpV4Args_t ipV4 = {0};
IanBenzMaxim 0:33d4e66780c0 293 sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&dhcpIsOn,&len,(_u8 *)&ipV4);
IanBenzMaxim 0:33d4e66780c0 294
IanBenzMaxim 0:33d4e66780c0 295 printf("DHCP is %s IP %d.%d.%d.%d MASK %d.%d.%d.%d GW %d.%d.%d.%d DNS %d.%d.%d.%d\n",
IanBenzMaxim 0:33d4e66780c0 296 (dhcpIsOn > 0) ? "ON" : "OFF",
IanBenzMaxim 0:33d4e66780c0 297 SL_IPV4_BYTE(ipV4.ipV4,3),SL_IPV4_BYTE(ipV4.ipV4,2),SL_IPV4_BYTE(ipV4.ipV4,1),SL_IPV4_BYTE(ipV4.ipV4,0),
IanBenzMaxim 0:33d4e66780c0 298 SL_IPV4_BYTE(ipV4.ipV4Mask,3),SL_IPV4_BYTE(ipV4.ipV4Mask,2),SL_IPV4_BYTE(ipV4.ipV4Mask,1),SL_IPV4_BYTE(ipV4.ipV4Mask,0),
IanBenzMaxim 0:33d4e66780c0 299 SL_IPV4_BYTE(ipV4.ipV4Gateway,3),SL_IPV4_BYTE(ipV4.ipV4Gateway,2),SL_IPV4_BYTE(ipV4.ipV4Gateway,1),SL_IPV4_BYTE(ipV4.ipV4Gateway,0),
IanBenzMaxim 0:33d4e66780c0 300 SL_IPV4_BYTE(ipV4.ipV4DnsServer,3),SL_IPV4_BYTE(ipV4.ipV4DnsServer,2),SL_IPV4_BYTE(ipV4.ipV4DnsServer,1),SL_IPV4_BYTE(ipV4.ipV4DnsServer,0));
IanBenzMaxim 0:33d4e66780c0 301
IanBenzMaxim 0:33d4e66780c0 302 \endcode
IanBenzMaxim 0:33d4e66780c0 303
IanBenzMaxim 0:33d4e66780c0 304 \code
IanBenzMaxim 0:33d4e66780c0 305 SL_IPV4_AP_P2P_GO_GET_INFO:
IanBenzMaxim 0:33d4e66780c0 306
IanBenzMaxim 0:33d4e66780c0 307 Get static IP address for AP or P2P go.
IanBenzMaxim 0:33d4e66780c0 308
IanBenzMaxim 0:33d4e66780c0 309 _u8 len = sizeof(SlNetCfgIpV4Args_t);
IanBenzMaxim 0:33d4e66780c0 310 _u8 dhcpIsOn = 0; // this flag is meaningless on AP/P2P go.
IanBenzMaxim 0:33d4e66780c0 311 SlNetCfgIpV4Args_t ipV4 = {0};
IanBenzMaxim 0:33d4e66780c0 312 sl_NetCfgGet(SL_IPV4_AP_P2P_GO_GET_INFO,&dhcpIsOn,&len,(_u8 *)&ipV4);
IanBenzMaxim 0:33d4e66780c0 313
IanBenzMaxim 0:33d4e66780c0 314 printf("IP %d.%d.%d.%d MASK %d.%d.%d.%d GW %d.%d.%d.%d DNS %d.%d.%d.%d\n",
IanBenzMaxim 0:33d4e66780c0 315 SL_IPV4_BYTE(ipV4.ipV4,3),SL_IPV4_BYTE(ipV4.ipV4,2),SL_IPV4_BYTE(ipV4.ipV4,1),SL_IPV4_BYTE(ipV4.ipV4,0),
IanBenzMaxim 0:33d4e66780c0 316 SL_IPV4_BYTE(ipV4.ipV4Mask,3),SL_IPV4_BYTE(ipV4.ipV4Mask,2),SL_IPV4_BYTE(ipV4.ipV4Mask,1),SL_IPV4_BYTE(ipV4.ipV4Mask,0),
IanBenzMaxim 0:33d4e66780c0 317 SL_IPV4_BYTE(ipV4.ipV4Gateway,3),SL_IPV4_BYTE(ipV4.ipV4Gateway,2),SL_IPV4_BYTE(ipV4.ipV4Gateway,1),SL_IPV4_BYTE(ipV4.ipV4Gateway,0),
IanBenzMaxim 0:33d4e66780c0 318 SL_IPV4_BYTE(ipV4.ipV4DnsServer,3),SL_IPV4_BYTE(ipV4.ipV4DnsServer,2),SL_IPV4_BYTE(ipV4.ipV4DnsServer,1),SL_IPV4_BYTE(ipV4.ipV4DnsServer,0));
IanBenzMaxim 0:33d4e66780c0 319
IanBenzMaxim 0:33d4e66780c0 320 \endcode
IanBenzMaxim 0:33d4e66780c0 321
IanBenzMaxim 0:33d4e66780c0 322 \code
IanBenzMaxim 0:33d4e66780c0 323
IanBenzMaxim 0:33d4e66780c0 324 SL_IPV4_DHCP_CLIENT:
IanBenzMaxim 0:33d4e66780c0 325
IanBenzMaxim 0:33d4e66780c0 326 Get DHCP client inforamtion, when DhcpState is SL_NETCFG_DHCP_CLIENT_BOUND, SL_NETCFG_DHCP_CLIENT_RENEW or SL_NETCFG_DHCP_CLIENT_REBIND, dhcp inforamtion is not zeroed
IanBenzMaxim 0:33d4e66780c0 327
IanBenzMaxim 0:33d4e66780c0 328 _u8 ConfigOpt = 0, ConfigLen = sizeof(SlNetCfgIpV4DhcpClientArgs_t);
IanBenzMaxim 0:33d4e66780c0 329 _i32 Status;
IanBenzMaxim 0:33d4e66780c0 330 SlNetCfgIpV4DhcpClientArgs_t Dhcp;
IanBenzMaxim 0:33d4e66780c0 331 Status = sl_NetCfgGet(SL_IPV4_DHCP_CLIENT,&ConfigOpt,&ConfigLen,(_u8 *)&Dhcp);
IanBenzMaxim 0:33d4e66780c0 332 if( Status )
IanBenzMaxim 0:33d4e66780c0 333 {
IanBenzMaxim 0:33d4e66780c0 334 // error
IanBenzMaxim 0:33d4e66780c0 335 }
IanBenzMaxim 0:33d4e66780c0 336 \endcode
IanBenzMaxim 0:33d4e66780c0 337
IanBenzMaxim 0:33d4e66780c0 338 \code
IanBenzMaxim 0:33d4e66780c0 339 SL_IPV4_DNS_CLIENT:
IanBenzMaxim 0:33d4e66780c0 340
IanBenzMaxim 0:33d4e66780c0 341 Get DNS max retries and secondary DNS address (DHCP and static configuration)
IanBenzMaxim 0:33d4e66780c0 342
IanBenzMaxim 0:33d4e66780c0 343 _u8 ConfigOpt;
IanBenzMaxim 0:33d4e66780c0 344 _i32 Status;
IanBenzMaxim 0:33d4e66780c0 345 _u8 pConfigLen = sizeof(SlNetCfgIpV4DnsClientArgs_t);
IanBenzMaxim 0:33d4e66780c0 346 SlNetCfgIpV4DnsClientArgs_t DnsOpt;
IanBenzMaxim 0:33d4e66780c0 347 Status = sl_NetCfgGet(SL_IPV4_DNS_CLIENT,&ConfigOpt,&pConfigLen,&DnsOpt);
IanBenzMaxim 0:33d4e66780c0 348 if( Status )
IanBenzMaxim 0:33d4e66780c0 349 {
IanBenzMaxim 0:33d4e66780c0 350 // error
IanBenzMaxim 0:33d4e66780c0 351 }
IanBenzMaxim 0:33d4e66780c0 352 \endcode
IanBenzMaxim 0:33d4e66780c0 353
IanBenzMaxim 0:33d4e66780c0 354
IanBenzMaxim 0:33d4e66780c0 355 */
IanBenzMaxim 0:33d4e66780c0 356 #if _SL_INCLUDE_FUNC(sl_NetCfgGet)
IanBenzMaxim 0:33d4e66780c0 357 _i32 sl_NetCfgGet(const _u8 ConfigId ,_u8 *pConfigOpt, _u8 *pConfigLen, _u8 *pValues);
IanBenzMaxim 0:33d4e66780c0 358 #endif
IanBenzMaxim 0:33d4e66780c0 359
IanBenzMaxim 0:33d4e66780c0 360 /*!
IanBenzMaxim 0:33d4e66780c0 361
IanBenzMaxim 0:33d4e66780c0 362 Close the Doxygen group.
IanBenzMaxim 0:33d4e66780c0 363 @}
IanBenzMaxim 0:33d4e66780c0 364
IanBenzMaxim 0:33d4e66780c0 365 */
IanBenzMaxim 0:33d4e66780c0 366
IanBenzMaxim 0:33d4e66780c0 367
IanBenzMaxim 0:33d4e66780c0 368 #ifdef __cplusplus
IanBenzMaxim 0:33d4e66780c0 369 }
IanBenzMaxim 0:33d4e66780c0 370 #endif /* __cplusplus */
IanBenzMaxim 0:33d4e66780c0 371
IanBenzMaxim 0:33d4e66780c0 372 #endif /* __NETCFG_H__ */
IanBenzMaxim 0:33d4e66780c0 373