Updated to use external spawn.

Fork of simplelink_V2 by David Fletcher

Committer:
dflet
Date:
Sat Jun 06 13:31:01 2015 +0000
Revision:
0:1a07906111ec
Changes made to use external spawn Freertos

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:1a07906111ec 1 /*
dflet 0:1a07906111ec 2 * netapp.h - CC31xx/CC32xx Host Driver Implementation
dflet 0:1a07906111ec 3 *
dflet 0:1a07906111ec 4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 0:1a07906111ec 5 *
dflet 0:1a07906111ec 6 *
dflet 0:1a07906111ec 7 * Redistribution and use in source and binary forms, with or without
dflet 0:1a07906111ec 8 * modification, are permitted provided that the following conditions
dflet 0:1a07906111ec 9 * are met:
dflet 0:1a07906111ec 10 *
dflet 0:1a07906111ec 11 * Redistributions of source code must retain the above copyright
dflet 0:1a07906111ec 12 * notice, this list of conditions and the following disclaimer.
dflet 0:1a07906111ec 13 *
dflet 0:1a07906111ec 14 * Redistributions in binary form must reproduce the above copyright
dflet 0:1a07906111ec 15 * notice, this list of conditions and the following disclaimer in the
dflet 0:1a07906111ec 16 * documentation and/or other materials provided with the
dflet 0:1a07906111ec 17 * distribution.
dflet 0:1a07906111ec 18 *
dflet 0:1a07906111ec 19 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 0:1a07906111ec 20 * its contributors may be used to endorse or promote products derived
dflet 0:1a07906111ec 21 * from this software without specific prior written permission.
dflet 0:1a07906111ec 22 *
dflet 0:1a07906111ec 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 0:1a07906111ec 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 0:1a07906111ec 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 0:1a07906111ec 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 0:1a07906111ec 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 0:1a07906111ec 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 0:1a07906111ec 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 0:1a07906111ec 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 0:1a07906111ec 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 0:1a07906111ec 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 0:1a07906111ec 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 0:1a07906111ec 34 *
dflet 0:1a07906111ec 35 */
dflet 0:1a07906111ec 36
dflet 0:1a07906111ec 37 /*****************************************************************************/
dflet 0:1a07906111ec 38 /* Include files */
dflet 0:1a07906111ec 39 /*****************************************************************************/
dflet 0:1a07906111ec 40
dflet 0:1a07906111ec 41 #include "cc3100_simplelink.h"
dflet 0:1a07906111ec 42
dflet 0:1a07906111ec 43 #ifndef NETAPP_H_
dflet 0:1a07906111ec 44 #define NETAPP_H_
dflet 0:1a07906111ec 45
dflet 0:1a07906111ec 46 #include "cc3100_protocol.h"
dflet 0:1a07906111ec 47 #include "cc3100_nonos.h"
dflet 0:1a07906111ec 48
dflet 0:1a07906111ec 49 namespace mbed_cc3100 {
dflet 0:1a07906111ec 50
dflet 0:1a07906111ec 51 /*!
dflet 0:1a07906111ec 52
dflet 0:1a07906111ec 53 \addtogroup netapp
dflet 0:1a07906111ec 54 @{
dflet 0:1a07906111ec 55
dflet 0:1a07906111ec 56 */
dflet 0:1a07906111ec 57
dflet 0:1a07906111ec 58 /*****************************************************************************/
dflet 0:1a07906111ec 59 /* Macro declarations */
dflet 0:1a07906111ec 60 /*****************************************************************************/
dflet 0:1a07906111ec 61
dflet 0:1a07906111ec 62 /*ERROR code*/
dflet 0:1a07906111ec 63 const int16_t SL_ERROR_NETAPP_RX_BUFFER_LENGTH_ERROR = (-230);
dflet 0:1a07906111ec 64
dflet 0:1a07906111ec 65 /* Http Server interface */
dflet 0:1a07906111ec 66 const uint8_t MAX_INPUT_STRING = (64); /* because of WPA */
dflet 0:1a07906111ec 67
dflet 0:1a07906111ec 68 const uint8_t MAX_AUTH_NAME_LEN = (20);
dflet 0:1a07906111ec 69 const uint8_t MAX_AUTH_PASSWORD_LEN = (20);
dflet 0:1a07906111ec 70 const uint8_t MAX_AUTH_REALM_LEN = (20);
dflet 0:1a07906111ec 71
dflet 0:1a07906111ec 72 const uint8_t MAX_DEVICE_URN_LEN = (15+1);
dflet 0:1a07906111ec 73 const uint8_t MAX_DOMAIN_NAME_LEN = (24+1);
dflet 0:1a07906111ec 74
dflet 0:1a07906111ec 75 const uint8_t MAX_ACTION_LEN = (30);
dflet 0:1a07906111ec 76 /* Important: in case the max len is changed, make sure the struct sl_NetAppHttpServerSendToken_t in protocol.h is padded correctly! */
dflet 0:1a07906111ec 77 const uint8_t MAX_TOKEN_NAME_LEN = (20);
dflet 0:1a07906111ec 78 const uint8_t MAX_TOKEN_VALUE_LEN = MAX_INPUT_STRING;
dflet 0:1a07906111ec 79
dflet 0:1a07906111ec 80 const int16_t NETAPP_MAX_SERVICE_TEXT_SIZE = (256);
dflet 0:1a07906111ec 81 const uint8_t NETAPP_MAX_SERVICE_NAME_SIZE = (60);
dflet 0:1a07906111ec 82 const uint8_t NETAPP_MAX_SERVICE_HOST_NAME_SIZE = (64);
dflet 0:1a07906111ec 83
dflet 0:1a07906111ec 84
dflet 0:1a07906111ec 85 /* Server Responses */
dflet 0:1a07906111ec 86 const uint8_t SL_NETAPP_RESPONSE_NONE = (0);
dflet 0:1a07906111ec 87 const uint8_t SL_NETAPP_HTTPSETTOKENVALUE = (1);
dflet 0:1a07906111ec 88
dflet 0:1a07906111ec 89 const uint8_t SL_NETAPP_FAMILY_MASK = (0x80);
dflet 0:1a07906111ec 90
dflet 0:1a07906111ec 91 /* mDNS types */
dflet 0:1a07906111ec 92 const uint32_t SL_NET_APP_MASK_IPP_TYPE_OF_SERVICE = (0x00000001);
dflet 0:1a07906111ec 93 const uint32_t SL_NET_APP_MASK_DEVICE_INFO_TYPE_OF_SERVICE = (0x00000002);
dflet 0:1a07906111ec 94 const uint32_t SL_NET_APP_MASK_HTTP_TYPE_OF_SERVICE = (0x00000004);
dflet 0:1a07906111ec 95 const uint32_t SL_NET_APP_MASK_HTTPS_TYPE_OF_SERVICE = (0x00000008);
dflet 0:1a07906111ec 96 const uint32_t SL_NET_APP_MASK_WORKSATION_TYPE_OF_SERVICE = (0x00000010);
dflet 0:1a07906111ec 97 const uint32_t SL_NET_APP_MASK_GUID_TYPE_OF_SERVICE = (0x00000020);
dflet 0:1a07906111ec 98 const uint32_t SL_NET_APP_MASK_H323_TYPE_OF_SERVICE = (0x00000040);
dflet 0:1a07906111ec 99 const uint32_t SL_NET_APP_MASK_NTP_TYPE_OF_SERVICE = (0x00000080);
dflet 0:1a07906111ec 100 const uint32_t SL_NET_APP_MASK_OBJECITVE_TYPE_OF_SERVICE = (0x00000100);
dflet 0:1a07906111ec 101 const uint32_t SL_NET_APP_MASK_RDP_TYPE_OF_SERVICE = (0x00000200);
dflet 0:1a07906111ec 102 const uint32_t SL_NET_APP_MASK_REMOTE_TYPE_OF_SERVICE = (0x00000400);
dflet 0:1a07906111ec 103 const uint32_t SL_NET_APP_MASK_RTSP_TYPE_OF_SERVICE = (0x00000800);
dflet 0:1a07906111ec 104 const uint32_t SL_NET_APP_MASK_SIP_TYPE_OF_SERVICE = (0x00001000);
dflet 0:1a07906111ec 105 const uint32_t SL_NET_APP_MASK_SMB_TYPE_OF_SERVICE = (0x00002000);
dflet 0:1a07906111ec 106 const uint32_t SL_NET_APP_MASK_SOAP_TYPE_OF_SERVICE = (0x00004000);
dflet 0:1a07906111ec 107 const uint32_t SL_NET_APP_MASK_SSH_TYPE_OF_SERVICE = (0x00008000);
dflet 0:1a07906111ec 108 const uint32_t SL_NET_APP_MASK_TELNET_TYPE_OF_SERVICE = (0x00010000);
dflet 0:1a07906111ec 109 const uint32_t SL_NET_APP_MASK_TFTP_TYPE_OF_SERVICE = (0x00020000);
dflet 0:1a07906111ec 110 const uint32_t SL_NET_APP_MASK_XMPP_CLIENT_TYPE_OF_SERVICE = (0x00040000);
dflet 0:1a07906111ec 111 const uint32_t SL_NET_APP_MASK_RAOP_TYPE_OF_SERVICE = (0x00080000);
dflet 0:1a07906111ec 112 const uint32_t SL_NET_APP_MASK_ALL_TYPE_OF_SERVICE = (0xFFFFFFFF);
dflet 0:1a07906111ec 113
dflet 0:1a07906111ec 114 /********************************************************************************************************/
dflet 0:1a07906111ec 115 /* sl_NetAppDnsGetHostByName error codes */
dflet 0:1a07906111ec 116
dflet 0:1a07906111ec 117 const int16_t SL_NET_APP_DNS_QUERY_NO_RESPONSE = (-159); /* DNS query failed, no response */
dflet 0:1a07906111ec 118 const int16_t SL_NET_APP_DNS_NO_SERVER = (-161); /* No DNS server was specified */
dflet 0:1a07906111ec 119 const int16_t SL_NET_APP_DNS_PARAM_ERROR = (-162); /* mDNS parameters error */
dflet 0:1a07906111ec 120 const int16_t SL_NET_APP_DNS_QUERY_FAILED = (-163); /* DNS query failed; no DNS server sent an 'answer' */
dflet 0:1a07906111ec 121 const int16_t SL_NET_APP_DNS_INTERNAL_1 = (-164);
dflet 0:1a07906111ec 122 const int16_t SL_NET_APP_DNS_INTERNAL_2 = (-165);
dflet 0:1a07906111ec 123 const int16_t SL_NET_APP_DNS_MALFORMED_PACKET = (-166); /* Improperly formed or corrupted DNS packet received */
dflet 0:1a07906111ec 124 const int16_t SL_NET_APP_DNS_INTERNAL_3 = (-167);
dflet 0:1a07906111ec 125 const int16_t SL_NET_APP_DNS_INTERNAL_4 = (-168);
dflet 0:1a07906111ec 126 const int16_t SL_NET_APP_DNS_INTERNAL_5 = (-169);
dflet 0:1a07906111ec 127 const int16_t SL_NET_APP_DNS_INTERNAL_6 = (-170);
dflet 0:1a07906111ec 128 const int16_t SL_NET_APP_DNS_INTERNAL_7 = (-171);
dflet 0:1a07906111ec 129 const int16_t SL_NET_APP_DNS_INTERNAL_8 = (-172);
dflet 0:1a07906111ec 130 const int16_t SL_NET_APP_DNS_INTERNAL_9 = (-173);
dflet 0:1a07906111ec 131 const int16_t SL_NET_APP_DNS_MISMATCHED_RESPONSE = (-174); /* Server response type does not match the query request*/
dflet 0:1a07906111ec 132 const int16_t SL_NET_APP_DNS_INTERNAL_10 = (-175);
dflet 0:1a07906111ec 133 const int16_t SL_NET_APP_DNS_INTERNAL_11 = (-176);
dflet 0:1a07906111ec 134 const int16_t SL_NET_APP_DNS_NO_ANSWER = (-177); /* No response for one-shot query */
dflet 0:1a07906111ec 135 const int16_t SL_NET_APP_DNS_NO_KNOWN_ANSWER = (-178); /* No known answer for query */
dflet 0:1a07906111ec 136 const int16_t SL_NET_APP_DNS_NAME_MISMATCH = (-179); /* Illegal service name according to the RFC */
dflet 0:1a07906111ec 137 const int16_t SL_NET_APP_DNS_NOT_STARTED = (-180); /* mDNS is not running */
dflet 0:1a07906111ec 138 const int16_t SL_NET_APP_DNS_HOST_NAME_ERROR = (-181); /* Host name error. Host name format is not allowed according to RFC 1033,1034,1035, 6763 */
dflet 0:1a07906111ec 139 const int16_t SL_NET_APP_DNS_NO_MORE_ENTRIES = (-182); /* No more entries be found. */
dflet 0:1a07906111ec 140
dflet 0:1a07906111ec 141 const int16_t SL_NET_APP_DNS_MAX_SERVICES_ERROR = (-200); /* Maximum advertise services are already configured */
dflet 0:1a07906111ec 142 const int16_t SL_NET_APP_DNS_IDENTICAL_SERVICES_ERROR = (-201); /* Trying to register a service that is already exists */
dflet 0:1a07906111ec 143 const int16_t SL_NET_APP_DNS_NOT_EXISTED_SERVICE_ERROR = (-203); /* Trying to delete service that does not existed */
dflet 0:1a07906111ec 144 const int16_t SL_NET_APP_DNS_ERROR_SERVICE_NAME_ERROR = (-204); /* Illegal service name according to the RFC */
dflet 0:1a07906111ec 145 const int16_t SL_NET_APP_DNS_RX_PACKET_ALLOCATION_ERROR = (-205); /* Retry request */
dflet 0:1a07906111ec 146 const int16_t SL_NET_APP_DNS_BUFFER_SIZE_ERROR = (-206); /* List size buffer is bigger than internally allowed in the NWP */
dflet 0:1a07906111ec 147 const int16_t SL_NET_APP_DNS_NET_APP_SET_ERROR = (-207); /* Illegal length of one of the mDNS Set functions */
dflet 0:1a07906111ec 148 const int16_t SL_NET_APP_DNS_GET_SERVICE_LIST_FLAG_ERROR = (-208);
dflet 0:1a07906111ec 149 const int16_t SL_NET_APP_DNS_NO_CONFIGURATION_ERROR = (-209);
dflet 0:1a07906111ec 150
dflet 0:1a07906111ec 151 /* Set Dev name error codes (NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN) */
dflet 0:1a07906111ec 152 const int16_t SL_ERROR_DEVICE_NAME_LEN_ERR = (-117);
dflet 0:1a07906111ec 153 const int16_t SL_ERROR_DEVICE_NAME_INVALID = (-118);
dflet 0:1a07906111ec 154 /* Set domain name error codes (NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME) */
dflet 0:1a07906111ec 155 const int16_t SL_ERROR_DOMAIN_NAME_LEN_ERR = (-119);
dflet 0:1a07906111ec 156 const int16_t SL_ERROR_DOMAIN_NAME_INVALID = (-120);
dflet 0:1a07906111ec 157
dflet 0:1a07906111ec 158 /********************************************************************************************************/
dflet 0:1a07906111ec 159
dflet 0:1a07906111ec 160 /* NetApp application IDs */
dflet 0:1a07906111ec 161 const uint8_t SL_NET_APP_HTTP_SERVER_ID = (1);
dflet 0:1a07906111ec 162 const uint8_t SL_NET_APP_DHCP_SERVER_ID = (2);
dflet 0:1a07906111ec 163 const uint8_t SL_NET_APP_MDNS_ID = (4);
dflet 0:1a07906111ec 164 const uint8_t SL_NET_APP_DNS_SERVER_ID = (8);
dflet 0:1a07906111ec 165 const uint8_t SL_NET_APP_DEVICE_CONFIG_ID = (16);
dflet 0:1a07906111ec 166 /* NetApp application set/get options */
dflet 0:1a07906111ec 167 const uint8_t NETAPP_SET_DHCP_SRV_BASIC_OPT = (0);
dflet 0:1a07906111ec 168 /* HTTP server set/get options */
dflet 0:1a07906111ec 169 const uint8_t NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER = (0);
dflet 0:1a07906111ec 170 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK = (1);
dflet 0:1a07906111ec 171 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_NAME = (2);
dflet 0:1a07906111ec 172 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD = (3);
dflet 0:1a07906111ec 173 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_REALM = (4);
dflet 0:1a07906111ec 174 const uint8_t NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS = (5);
dflet 0:1a07906111ec 175
dflet 0:1a07906111ec 176 const uint8_t NETAPP_SET_GET_MDNS_CONT_QUERY_OPT = (1);
dflet 0:1a07906111ec 177 const uint8_t NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT = (2);
dflet 0:1a07906111ec 178 const uint8_t NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT = (3);
dflet 0:1a07906111ec 179
dflet 0:1a07906111ec 180 /* DNS server set/get options */
dflet 0:1a07906111ec 181 const uint8_t NETAPP_SET_GET_DNS_OPT_DOMAIN_NAME = (0);
dflet 0:1a07906111ec 182
dflet 0:1a07906111ec 183 /* Device Config set/get options */
dflet 0:1a07906111ec 184 const uint8_t NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN = (0);
dflet 0:1a07906111ec 185 const uint8_t NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME = (1);
dflet 0:1a07906111ec 186
dflet 0:1a07906111ec 187
dflet 0:1a07906111ec 188 /*****************************************************************************/
dflet 0:1a07906111ec 189 /* Structure/Enum declarations */
dflet 0:1a07906111ec 190 /*****************************************************************************/
dflet 0:1a07906111ec 191 /*
dflet 0:1a07906111ec 192 * The below structure depict the constant parameters that are returned in the Async event answer
dflet 0:1a07906111ec 193 * according to command/API sl_DnsGetHostByService for IPv4 and IPv6.
dflet 0:1a07906111ec 194 *
dflet 0:1a07906111ec 195 1Status - The status of the response.
dflet 0:1a07906111ec 196 2.Address - Contains the IP address of the service.
dflet 0:1a07906111ec 197 3.Port - Contains the port of the service.
dflet 0:1a07906111ec 198 4.TextLen - Contains the max length of the text that the user wants to get.
dflet 0:1a07906111ec 199 it means that if the test of service is bigger that its value than
dflet 0:1a07906111ec 200 the text is cut to inout_TextLen value.
dflet 0:1a07906111ec 201 Output: Contain the length of the text that is returned. Can be full text or part
dflet 0:1a07906111ec 202 of the text (see above).
dflet 0:1a07906111ec 203
dflet 0:1a07906111ec 204 *
dflet 0:1a07906111ec 205 */
dflet 0:1a07906111ec 206 typedef struct {
dflet 0:1a07906111ec 207 uint16_t Status;
dflet 0:1a07906111ec 208 uint16_t TextLen;
dflet 0:1a07906111ec 209 uint32_t Port;
dflet 0:1a07906111ec 210 uint32_t Address;
dflet 0:1a07906111ec 211 } _GetHostByServiceIPv4AsyncResponse_t;
dflet 0:1a07906111ec 212
dflet 0:1a07906111ec 213 /*
dflet 0:1a07906111ec 214 * The below struct contains pointers to the output parameters that the user gives
dflet 0:1a07906111ec 215 *
dflet 0:1a07906111ec 216 */
dflet 0:1a07906111ec 217 typedef struct {
dflet 0:1a07906111ec 218 int16_t Status;
dflet 0:1a07906111ec 219 uint32_t *out_pAddr;
dflet 0:1a07906111ec 220 uint32_t *out_pPort;
dflet 0:1a07906111ec 221 uint16_t *inout_TextLen; // in: max len , out: actual len
dflet 0:1a07906111ec 222 unsigned char *out_pText;
dflet 0:1a07906111ec 223 } _GetHostByServiceAsyncResponse_t;
dflet 0:1a07906111ec 224
dflet 0:1a07906111ec 225 typedef struct {
dflet 0:1a07906111ec 226 uint32_t PacketsSent;
dflet 0:1a07906111ec 227 uint32_t PacketsReceived;
dflet 0:1a07906111ec 228 uint16_t MinRoundTime;
dflet 0:1a07906111ec 229 uint16_t MaxRoundTime;
dflet 0:1a07906111ec 230 uint16_t AvgRoundTime;
dflet 0:1a07906111ec 231 uint32_t TestTime;
dflet 0:1a07906111ec 232 } SlPingReport_t;
dflet 0:1a07906111ec 233
dflet 0:1a07906111ec 234 typedef struct {
dflet 0:1a07906111ec 235 uint32_t PingIntervalTime; /* delay between pings, in milliseconds */
dflet 0:1a07906111ec 236 uint16_t PingSize; /* ping packet size in bytes */
dflet 0:1a07906111ec 237 uint16_t PingRequestTimeout; /* timeout time for every ping in milliseconds */
dflet 0:1a07906111ec 238 uint32_t TotalNumberOfAttempts; /* max number of ping requests. 0 - forever */
dflet 0:1a07906111ec 239 uint32_t Flags; /* flag - 0 report only when finished, 1 - return response for every ping, 2 - stop after 1 successful ping. */
dflet 0:1a07906111ec 240 uint32_t Ip; /* IPv4 address or IPv6 first 4 bytes */
dflet 0:1a07906111ec 241 uint32_t Ip1OrPaadding;
dflet 0:1a07906111ec 242 uint32_t Ip2OrPaadding;
dflet 0:1a07906111ec 243 uint32_t Ip3OrPaadding;
dflet 0:1a07906111ec 244 } SlPingStartCommand_t;
dflet 0:1a07906111ec 245
dflet 0:1a07906111ec 246 typedef struct _slHttpServerString_t {
dflet 0:1a07906111ec 247 uint8_t len;
dflet 0:1a07906111ec 248 uint8_t *data;
dflet 0:1a07906111ec 249 } slHttpServerString_t;
dflet 0:1a07906111ec 250
dflet 0:1a07906111ec 251 typedef struct _slHttpServerData_t {
dflet 0:1a07906111ec 252 uint8_t value_len;
dflet 0:1a07906111ec 253 uint8_t name_len;
dflet 0:1a07906111ec 254 uint8_t *token_value;
dflet 0:1a07906111ec 255 uint8_t *token_name;
dflet 0:1a07906111ec 256 } slHttpServerData_t;
dflet 0:1a07906111ec 257
dflet 0:1a07906111ec 258 typedef struct _slHttpServerPostData_t {
dflet 0:1a07906111ec 259 slHttpServerString_t action;
dflet 0:1a07906111ec 260 slHttpServerString_t token_name;
dflet 0:1a07906111ec 261 slHttpServerString_t token_value;
dflet 0:1a07906111ec 262 } slHttpServerPostData_t;
dflet 0:1a07906111ec 263
dflet 0:1a07906111ec 264 typedef union {
dflet 0:1a07906111ec 265 slHttpServerString_t httpTokenName; /* SL_NETAPP_HTTPGETTOKENVALUE */
dflet 0:1a07906111ec 266 slHttpServerPostData_t httpPostData; /* SL_NETAPP_HTTPPOSTTOKENVALUE */
dflet 0:1a07906111ec 267 } SlHttpServerEventData_u;
dflet 0:1a07906111ec 268
dflet 0:1a07906111ec 269 typedef union {
dflet 0:1a07906111ec 270 slHttpServerString_t token_value;
dflet 0:1a07906111ec 271 } SlHttpServerResponsedata_u;
dflet 0:1a07906111ec 272
dflet 0:1a07906111ec 273 typedef struct {
dflet 0:1a07906111ec 274 uint32_t Event;
dflet 0:1a07906111ec 275 SlHttpServerEventData_u EventData;
dflet 0:1a07906111ec 276 } SlHttpServerEvent_t;
dflet 0:1a07906111ec 277
dflet 0:1a07906111ec 278 typedef struct {
dflet 0:1a07906111ec 279 uint32_t Response;
dflet 0:1a07906111ec 280 SlHttpServerResponsedata_u ResponseData;
dflet 0:1a07906111ec 281 } SlHttpServerResponse_t;
dflet 0:1a07906111ec 282
dflet 0:1a07906111ec 283
dflet 0:1a07906111ec 284 typedef struct {
dflet 0:1a07906111ec 285 uint32_t lease_time;
dflet 0:1a07906111ec 286 uint32_t ipv4_addr_start;
dflet 0:1a07906111ec 287 uint32_t ipv4_addr_last;
dflet 0:1a07906111ec 288 } SlNetAppDhcpServerBasicOpt_t;
dflet 0:1a07906111ec 289
dflet 0:1a07906111ec 290 /*mDNS parameters*/
dflet 0:1a07906111ec 291 typedef enum {
dflet 0:1a07906111ec 292 SL_NET_APP_FULL_SERVICE_WITH_TEXT_IPV4_TYPE = 1,
dflet 0:1a07906111ec 293 SL_NET_APP_FULL_SERVICE_IPV4_TYPE,
dflet 0:1a07906111ec 294 SL_NET_APP_SHORT_SERVICE_IPV4_TYPE
dflet 0:1a07906111ec 295
dflet 0:1a07906111ec 296 } SlNetAppGetServiceListType_e;
dflet 0:1a07906111ec 297
dflet 0:1a07906111ec 298 typedef struct {
dflet 0:1a07906111ec 299 uint32_t service_ipv4;
dflet 0:1a07906111ec 300 uint16_t service_port;
dflet 0:1a07906111ec 301 uint16_t Reserved;
dflet 0:1a07906111ec 302 } SlNetAppGetShortServiceIpv4List_t;
dflet 0:1a07906111ec 303
dflet 0:1a07906111ec 304 typedef struct {
dflet 0:1a07906111ec 305 uint32_t service_ipv4;
dflet 0:1a07906111ec 306 uint16_t service_port;
dflet 0:1a07906111ec 307 uint16_t Reserved;
dflet 0:1a07906111ec 308 uint8_t service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
dflet 0:1a07906111ec 309 uint8_t service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
dflet 0:1a07906111ec 310 } SlNetAppGetFullServiceIpv4List_t;
dflet 0:1a07906111ec 311
dflet 0:1a07906111ec 312 typedef struct {
dflet 0:1a07906111ec 313 uint32_t service_ipv4;
dflet 0:1a07906111ec 314 uint16_t service_port;
dflet 0:1a07906111ec 315 uint16_t Reserved;
dflet 0:1a07906111ec 316 uint8_t service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
dflet 0:1a07906111ec 317 uint8_t service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
dflet 0:1a07906111ec 318 uint8_t service_text[NETAPP_MAX_SERVICE_TEXT_SIZE];
dflet 0:1a07906111ec 319 } SlNetAppGetFullServiceWithTextIpv4List_t;
dflet 0:1a07906111ec 320
dflet 0:1a07906111ec 321 typedef struct {
dflet 0:1a07906111ec 322 /*The below parameters are used to configure the advertise times and interval
dflet 0:1a07906111ec 323 For example:
dflet 0:1a07906111ec 324 If:
dflet 0:1a07906111ec 325 Period is set to T
dflet 0:1a07906111ec 326 Repetitions are set to P
dflet 0:1a07906111ec 327 Telescopic factor is K=2
dflet 0:1a07906111ec 328 The transmission shall be:
dflet 0:1a07906111ec 329 advertise P times
dflet 0:1a07906111ec 330 wait T
dflet 0:1a07906111ec 331 advertise P times
dflet 0:1a07906111ec 332 wait 4 * T
dflet 0:1a07906111ec 333 advertise P time
dflet 0:1a07906111ec 334 wait 16 * T ... (till max time reached / configuration changed / query issued)
dflet 0:1a07906111ec 335 */
dflet 0:1a07906111ec 336 uint32_t t; /* Number of ticks for the initial period. Default is 100 ticks for 1 second. */
dflet 0:1a07906111ec 337 uint32_t p; /* Number of repetitions. Default value is 1 */
dflet 0:1a07906111ec 338 uint32_t k; /* Telescopic factor. Default value is 2. */
dflet 0:1a07906111ec 339 uint32_t RetransInterval;/* Announcing retransmission interval */
dflet 0:1a07906111ec 340 uint32_t Maxinterval; /* Announcing max period interval */
dflet 0:1a07906111ec 341 uint32_t max_time; /* Announcing max time */
dflet 0:1a07906111ec 342 } SlNetAppServiceAdvertiseTimingParameters_t;
dflet 0:1a07906111ec 343
dflet 0:1a07906111ec 344 /*****************************************************************************/
dflet 0:1a07906111ec 345 /* Types declarations */
dflet 0:1a07906111ec 346 /*****************************************************************************/
dflet 0:1a07906111ec 347 typedef void (*P_SL_DEV_PING_CALLBACK)(SlPingReport_t*);
dflet 0:1a07906111ec 348 extern P_SL_DEV_PING_CALLBACK pPingCallBackFunc;
dflet 0:1a07906111ec 349
dflet 0:1a07906111ec 350 /*****************************************************************************************
dflet 0:1a07906111ec 351 * NETAPP structs
dflet 0:1a07906111ec 352 ******************************************************************************************/
dflet 0:1a07906111ec 353
dflet 0:1a07906111ec 354
dflet 0:1a07906111ec 355 typedef _BasicResponse_t _NetAppStartStopResponse_t;
dflet 0:1a07906111ec 356
dflet 0:1a07906111ec 357 typedef struct {
dflet 0:1a07906111ec 358 uint32_t appId;
dflet 0:1a07906111ec 359 } _NetAppStartStopCommand_t;
dflet 0:1a07906111ec 360
dflet 0:1a07906111ec 361 typedef struct {
dflet 0:1a07906111ec 362 uint16_t Status;
dflet 0:1a07906111ec 363 uint16_t AppId;
dflet 0:1a07906111ec 364 uint16_t ConfigOpt;
dflet 0:1a07906111ec 365 uint16_t ConfigLen;
dflet 0:1a07906111ec 366 } _NetAppSetGet_t;
dflet 0:1a07906111ec 367 typedef struct {
dflet 0:1a07906111ec 368 uint16_t port_number;
dflet 0:1a07906111ec 369 } _NetAppHttpServerGetSet_port_num_t;
dflet 0:1a07906111ec 370
dflet 0:1a07906111ec 371 typedef struct {
dflet 0:1a07906111ec 372 uint8_t auth_enable;
dflet 0:1a07906111ec 373 } _NetAppHttpServerGetSet_auth_enable_t;
dflet 0:1a07906111ec 374
dflet 0:1a07906111ec 375 typedef struct _sl_NetAppHttpServerGetToken_t {
dflet 0:1a07906111ec 376 uint8_t token_name_len;
dflet 0:1a07906111ec 377 uint8_t padd1;
dflet 0:1a07906111ec 378 uint16_t padd2;
dflet 0:1a07906111ec 379 } sl_NetAppHttpServerGetToken_t;
dflet 0:1a07906111ec 380
dflet 0:1a07906111ec 381 typedef struct _sl_NetAppHttpServerSendToken_t {
dflet 0:1a07906111ec 382 uint8_t token_value_len;
dflet 0:1a07906111ec 383 uint8_t token_name_len;
dflet 0:1a07906111ec 384 uint8_t token_name[MAX_TOKEN_NAME_LEN];
dflet 0:1a07906111ec 385 uint16_t padd;
dflet 0:1a07906111ec 386 } sl_NetAppHttpServerSendToken_t;
dflet 0:1a07906111ec 387
dflet 0:1a07906111ec 388 typedef struct _sl_NetAppHttpServerPostToken_t {
dflet 0:1a07906111ec 389 uint8_t post_action_len;
dflet 0:1a07906111ec 390 uint8_t token_name_len;
dflet 0:1a07906111ec 391 uint8_t token_value_len;
dflet 0:1a07906111ec 392 uint8_t padding;
dflet 0:1a07906111ec 393 } sl_NetAppHttpServerPostToken_t;
dflet 0:1a07906111ec 394
dflet 0:1a07906111ec 395
dflet 0:1a07906111ec 396 typedef struct {
dflet 0:1a07906111ec 397 uint16_t Len;
dflet 0:1a07906111ec 398 uint8_t family;
dflet 0:1a07906111ec 399 uint8_t padding;
dflet 0:1a07906111ec 400 } _GetHostByNameCommand_t;
dflet 0:1a07906111ec 401
dflet 0:1a07906111ec 402 typedef struct {
dflet 0:1a07906111ec 403 uint16_t status;
dflet 0:1a07906111ec 404 uint16_t padding;
dflet 0:1a07906111ec 405 uint32_t ip0;
dflet 0:1a07906111ec 406 uint32_t ip1;
dflet 0:1a07906111ec 407 uint32_t ip2;
dflet 0:1a07906111ec 408 uint32_t ip3;
dflet 0:1a07906111ec 409 } _GetHostByNameIPv6AsyncResponse_t;
dflet 0:1a07906111ec 410
dflet 0:1a07906111ec 411 typedef struct {
dflet 0:1a07906111ec 412 uint16_t status;
dflet 0:1a07906111ec 413 uint8_t padding1;
dflet 0:1a07906111ec 414 uint8_t padding2;
dflet 0:1a07906111ec 415 uint32_t ip0;
dflet 0:1a07906111ec 416 } _GetHostByNameIPv4AsyncResponse_t;
dflet 0:1a07906111ec 417
dflet 0:1a07906111ec 418 typedef enum {
dflet 0:1a07906111ec 419 CTST_BSD_UDP_TX,
dflet 0:1a07906111ec 420 CTST_BSD_UDP_RX,
dflet 0:1a07906111ec 421 CTST_BSD_TCP_TX,
dflet 0:1a07906111ec 422 CTST_BSD_TCP_RX,
dflet 0:1a07906111ec 423 CTST_BSD_TCP_SERVER_BI_DIR,
dflet 0:1a07906111ec 424 CTST_BSD_TCP_CLIENT_BI_DIR,
dflet 0:1a07906111ec 425 CTST_BSD_UDP_BI_DIR,
dflet 0:1a07906111ec 426 CTST_BSD_RAW_TX,
dflet 0:1a07906111ec 427 CTST_BSD_RAW_RX,
dflet 0:1a07906111ec 428 CTST_BSD_RAW_BI_DIR,
dflet 0:1a07906111ec 429 CTST_BSD_SECURED_TCP_TX,
dflet 0:1a07906111ec 430 CTST_BSD_SECURED_TCP_RX,
dflet 0:1a07906111ec 431 CTST_BSD_SECURED_TCP_SERVER_BI_DIR,
dflet 0:1a07906111ec 432 CTST_BSD_SECURED_TCP_CLIENT_BI_DIR
dflet 0:1a07906111ec 433 } CommTest_e;
dflet 0:1a07906111ec 434
dflet 0:1a07906111ec 435 typedef struct _sl_protocol_CtestStartCommand_t {
dflet 0:1a07906111ec 436 uint32_t Test;
dflet 0:1a07906111ec 437 uint16_t DestPort;
dflet 0:1a07906111ec 438 uint16_t SrcPort;
dflet 0:1a07906111ec 439 uint32_t DestAddr[4];
dflet 0:1a07906111ec 440 uint32_t PayloadSize;
dflet 0:1a07906111ec 441 uint32_t timeout;
dflet 0:1a07906111ec 442 uint32_t csEnabled;
dflet 0:1a07906111ec 443 uint32_t secure;
dflet 0:1a07906111ec 444 uint32_t rawProtocol;
dflet 0:1a07906111ec 445 uint8_t reserved1[4];
dflet 0:1a07906111ec 446 } _CtestStartCommand_t;
dflet 0:1a07906111ec 447
dflet 0:1a07906111ec 448 typedef struct {
dflet 0:1a07906111ec 449 uint8_t test;
dflet 0:1a07906111ec 450 uint8_t socket;
dflet 0:1a07906111ec 451 int16_t status;
dflet 0:1a07906111ec 452 uint32_t startTime;
dflet 0:1a07906111ec 453 uint32_t endTime;
dflet 0:1a07906111ec 454 uint16_t txKbitsSec;
dflet 0:1a07906111ec 455 uint16_t rxKbitsSec;
dflet 0:1a07906111ec 456 uint32_t outOfOrderPackets;
dflet 0:1a07906111ec 457 uint32_t missedPackets;
dflet 0:1a07906111ec 458 int16_t token;
dflet 0:1a07906111ec 459 } _CtestAsyncResponse_t;
dflet 0:1a07906111ec 460
dflet 0:1a07906111ec 461 typedef struct {
dflet 0:1a07906111ec 462 uint32_t pingIntervalTime;
dflet 0:1a07906111ec 463 uint16_t PingSize;
dflet 0:1a07906111ec 464 uint16_t pingRequestTimeout;
dflet 0:1a07906111ec 465 uint32_t totalNumberOfAttempts;
dflet 0:1a07906111ec 466 uint32_t flags;
dflet 0:1a07906111ec 467 uint32_t ip0;
dflet 0:1a07906111ec 468 uint32_t ip1OrPaadding;
dflet 0:1a07906111ec 469 uint32_t ip2OrPaadding;
dflet 0:1a07906111ec 470 uint32_t ip3OrPaadding;
dflet 0:1a07906111ec 471 } _PingStartCommand_t;
dflet 0:1a07906111ec 472
dflet 0:1a07906111ec 473 typedef struct {
dflet 0:1a07906111ec 474 uint16_t status;
dflet 0:1a07906111ec 475 uint16_t rttMin;
dflet 0:1a07906111ec 476 uint16_t rttMax;
dflet 0:1a07906111ec 477 uint16_t rttAvg;
dflet 0:1a07906111ec 478 uint32_t numSuccsessPings;
dflet 0:1a07906111ec 479 uint32_t numSendsPings;
dflet 0:1a07906111ec 480 uint32_t testTime;
dflet 0:1a07906111ec 481 } _PingReportResponse_t;
dflet 0:1a07906111ec 482
dflet 0:1a07906111ec 483
dflet 0:1a07906111ec 484 typedef struct {
dflet 0:1a07906111ec 485 uint32_t ip;
dflet 0:1a07906111ec 486 uint32_t gateway;
dflet 0:1a07906111ec 487 uint32_t dns;
dflet 0:1a07906111ec 488 } _IpV4AcquiredAsync_t;
dflet 0:1a07906111ec 489
dflet 0:1a07906111ec 490
dflet 0:1a07906111ec 491 typedef enum {
dflet 0:1a07906111ec 492 ACQUIRED_IPV6_LOCAL = 1,
dflet 0:1a07906111ec 493 ACQUIRED_IPV6_GLOBAL
dflet 0:1a07906111ec 494 } IpV6AcquiredType_e;
dflet 0:1a07906111ec 495
dflet 0:1a07906111ec 496
dflet 0:1a07906111ec 497 typedef struct {
dflet 0:1a07906111ec 498 uint32_t type;
dflet 0:1a07906111ec 499 uint32_t ip[4];
dflet 0:1a07906111ec 500 uint32_t gateway[4];
dflet 0:1a07906111ec 501 uint32_t dns[4];
dflet 0:1a07906111ec 502 } _IpV6AcquiredAsync_t;
dflet 0:1a07906111ec 503
dflet 0:1a07906111ec 504
dflet 0:1a07906111ec 505 typedef union {
dflet 0:1a07906111ec 506 _SocketCommand_t EventMask;
dflet 0:1a07906111ec 507 _sendRecvCommand_t DeviceInit;
dflet 0:1a07906111ec 508 } _device_commands_t;
dflet 0:1a07906111ec 509
dflet 0:1a07906111ec 510
dflet 0:1a07906111ec 511 class cc3100_netapp
dflet 0:1a07906111ec 512 {
dflet 0:1a07906111ec 513
dflet 0:1a07906111ec 514 public:
dflet 0:1a07906111ec 515
dflet 0:1a07906111ec 516 cc3100_netapp(cc3100_driver &driver, cc3100_nonos &nonos);
dflet 0:1a07906111ec 517
dflet 0:1a07906111ec 518 ~cc3100_netapp();
dflet 0:1a07906111ec 519
dflet 0:1a07906111ec 520 /*****************************************************************************/
dflet 0:1a07906111ec 521 /* Functions prototypes */
dflet 0:1a07906111ec 522 /*****************************************************************************/
dflet 0:1a07906111ec 523 int16_t sl_NetAppMDNSRegisterUnregisterService(const char* pServiceName,
dflet 0:1a07906111ec 524 const uint8_t ServiceNameLen,
dflet 0:1a07906111ec 525 const char* pText,
dflet 0:1a07906111ec 526 const uint8_t TextLen,
dflet 0:1a07906111ec 527 const uint16_t Port,
dflet 0:1a07906111ec 528 const uint32_t TTL,
dflet 0:1a07906111ec 529 const uint32_t Options);
dflet 0:1a07906111ec 530
dflet 0:1a07906111ec 531 void _sl_HandleAsync_DnsGetHostByAddr(void *pVoidBuf);
dflet 0:1a07906111ec 532
dflet 0:1a07906111ec 533 void CopyPingResultsToReport(_PingReportResponse_t *pResults,SlPingReport_t *pReport);
dflet 0:1a07906111ec 534
dflet 0:1a07906111ec 535 #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
dflet 0:1a07906111ec 536 uint16_t sl_NetAppSendTokenValue(slHttpServerData_t * Token);
dflet 0:1a07906111ec 537 #endif
dflet 0:1a07906111ec 538
dflet 0:1a07906111ec 539 // uint16_t sl_NetAppSendTokenValue(slHttpServerData_t * Token);
dflet 0:1a07906111ec 540
dflet 0:1a07906111ec 541
dflet 0:1a07906111ec 542 /*****************************************************************************/
dflet 0:1a07906111ec 543 /* Function prototypes */
dflet 0:1a07906111ec 544 /*****************************************************************************/
dflet 0:1a07906111ec 545
dflet 0:1a07906111ec 546
dflet 0:1a07906111ec 547 /*!
dflet 0:1a07906111ec 548 \brief Starts a network application
dflet 0:1a07906111ec 549
dflet 0:1a07906111ec 550 Gets and starts network application for the current WLAN mode
dflet 0:1a07906111ec 551
dflet 0:1a07906111ec 552 \param[in] AppBitMap application bitmap, could be one or combination of the following: \n
dflet 0:1a07906111ec 553 - SL_NET_APP_HTTP_SERVER_ID
dflet 0:1a07906111ec 554 - SL_NET_APP_DHCP_SERVER_ID
dflet 0:1a07906111ec 555 - SL_NET_APP_MDNS_ID
dflet 0:1a07906111ec 556
dflet 0:1a07906111ec 557 \return On error, negative number is returned
dflet 0:1a07906111ec 558
dflet 0:1a07906111ec 559 \sa Stop one or more the above started applications using sl_NetAppStop
dflet 0:1a07906111ec 560 \note This command activates the application for the current WLAN mode (AP or STA)
dflet 0:1a07906111ec 561 \warning
dflet 0:1a07906111ec 562 \par Example:
dflet 0:1a07906111ec 563 \code
dflet 0:1a07906111ec 564 For example: Starting internal HTTP server + DHCP server:
dflet 0:1a07906111ec 565 sl_NetAppStart(SL_NET_APP_HTTP_SERVER_ID | SL_NET_APP_DHCP_SERVER_ID)
dflet 0:1a07906111ec 566
dflet 0:1a07906111ec 567 \endcode
dflet 0:1a07906111ec 568 */
dflet 0:1a07906111ec 569 #if _SL_INCLUDE_FUNC(sl_NetAppStart)
dflet 0:1a07906111ec 570 int16_t sl_NetAppStart(const uint32_t AppBitMap);
dflet 0:1a07906111ec 571 #endif
dflet 0:1a07906111ec 572 /*!
dflet 0:1a07906111ec 573 \brief Stops a network application
dflet 0:1a07906111ec 574
dflet 0:1a07906111ec 575 Gets and stops network application for the current WLAN mode
dflet 0:1a07906111ec 576
dflet 0:1a07906111ec 577 \param[in] AppBitMap application id, could be one of the following: \n
dflet 0:1a07906111ec 578 - SL_NET_APP_HTTP_SERVER_ID
dflet 0:1a07906111ec 579 - SL_NET_APP_DHCP_SERVER_ID
dflet 0:1a07906111ec 580 - SL_NET_APP_MDNS_ID
dflet 0:1a07906111ec 581
dflet 0:1a07906111ec 582 \return On error, negative number is returned
dflet 0:1a07906111ec 583
dflet 0:1a07906111ec 584 \sa
dflet 0:1a07906111ec 585 \note This command disables the application for the current active WLAN mode (AP or STA)
dflet 0:1a07906111ec 586 \warning
dflet 0:1a07906111ec 587 \par Example:
dflet 0:1a07906111ec 588 \code
dflet 0:1a07906111ec 589
dflet 0:1a07906111ec 590 For example: Stopping internal HTTP server:
dflet 0:1a07906111ec 591 sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID);
dflet 0:1a07906111ec 592
dflet 0:1a07906111ec 593 \endcode
dflet 0:1a07906111ec 594 */
dflet 0:1a07906111ec 595 #if _SL_INCLUDE_FUNC(sl_NetAppStop)
dflet 0:1a07906111ec 596 int16_t sl_NetAppStop(const uint32_t AppBitMap);
dflet 0:1a07906111ec 597 #endif
dflet 0:1a07906111ec 598
dflet 0:1a07906111ec 599 /*!
dflet 0:1a07906111ec 600 \brief Get host IP by name
dflet 0:1a07906111ec 601
dflet 0:1a07906111ec 602 Obtain the IP Address of machine on network, by machine name.
dflet 0:1a07906111ec 603
dflet 0:1a07906111ec 604 \param[in] hostname host name
dflet 0:1a07906111ec 605 \param[in] usNameLen name length
dflet 0:1a07906111ec 606 \param[out] out_ip_addr This parameter is filled in with
dflet 0:1a07906111ec 607 host IP address. In case that host name is not
dflet 0:1a07906111ec 608 resolved, out_ip_addr is zero.
dflet 0:1a07906111ec 609 \param[in] family protocol family
dflet 0:1a07906111ec 610
dflet 0:1a07906111ec 611 \return On success, 0 is returned.
dflet 0:1a07906111ec 612 On error, negative is returned
dflet 0:1a07906111ec 613 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
dflet 0:1a07906111ec 614 In this case try again later or increase MAX_CONCURRENT_ACTIONS
dflet 0:1a07906111ec 615 Possible DNS error codes:
dflet 0:1a07906111ec 616 - SL_NET_APP_DNS_QUERY_NO_RESPONSE
dflet 0:1a07906111ec 617 - SL_NET_APP_DNS_NO_SERVER
dflet 0:1a07906111ec 618 - SL_NET_APP_DNS_QUERY_FAILED
dflet 0:1a07906111ec 619 - SL_NET_APP_DNS_MALFORMED_PACKET
dflet 0:1a07906111ec 620 - SL_NET_APP_DNS_MISMATCHED_RESPONSE
dflet 0:1a07906111ec 621
dflet 0:1a07906111ec 622 \sa
dflet 0:1a07906111ec 623 \note Only one sl_NetAppDnsGetHostByName can be handled at a time.
dflet 0:1a07906111ec 624 Calling this API while the same command is called from another thread, may result
dflet 0:1a07906111ec 625 in one of the two scenarios:
dflet 0:1a07906111ec 626 1. The command will wait (internal) until the previous command finish, and then be executed.
dflet 0:1a07906111ec 627 2. There are not enough resources and POOL_IS_EMPTY error will return.
dflet 0:1a07906111ec 628 In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
dflet 0:1a07906111ec 629 again later to issue the command.
dflet 0:1a07906111ec 630 \warning
dflet 0:1a07906111ec 631 In case an IP address in a string format is set as input, without any prefix (e.g. "1.2.3.4") the device will not
dflet 0:1a07906111ec 632 try to access the DNS and it will return the input address on the 'out_ip_addr' field
dflet 0:1a07906111ec 633 \par Example:
dflet 0:1a07906111ec 634 \code
dflet 0:1a07906111ec 635 uint32_t DestinationIP;
dflet 0:1a07906111ec 636 sl_NetAppDnsGetHostByName("www.google.com", strlen("www.google.com"), &DestinationIP,SL_AF_INET);
dflet 0:1a07906111ec 637
dflet 0:1a07906111ec 638 Addr.sin_family = SL_AF_INET;
dflet 0:1a07906111ec 639 Addr.sin_port = sl_Htons(80);
dflet 0:1a07906111ec 640 Addr.sin_addr.s_addr = sl_Htonl(DestinationIP);
dflet 0:1a07906111ec 641 AddrSize = sizeof(SlSockAddrIn_t);
dflet 0:1a07906111ec 642 SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
dflet 0:1a07906111ec 643 \endcode
dflet 0:1a07906111ec 644 */
dflet 0:1a07906111ec 645 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByName)
dflet 0:1a07906111ec 646 int16_t sl_NetAppDnsGetHostByName(unsigned char * hostname, const uint16_t usNameLen, uint32_t* out_ip_addr, const uint8_t family );
dflet 0:1a07906111ec 647 #endif
dflet 0:1a07906111ec 648
dflet 0:1a07906111ec 649 /*!
dflet 0:1a07906111ec 650 \brief Return service attributes like IP address, port and text according to service name
dflet 0:1a07906111ec 651 \par
dflet 0:1a07906111ec 652 The user sets a service name Full/Part (see example below), and should get:
dflet 0:1a07906111ec 653 - IP of service
dflet 0:1a07906111ec 654 - The port of service
dflet 0:1a07906111ec 655 - The text of service
dflet 0:1a07906111ec 656
dflet 0:1a07906111ec 657 Hence it can make a connection to the specific service and use it.
dflet 0:1a07906111ec 658 It is similar to get host by name method.
dflet 0:1a07906111ec 659 It is done by a single shot query with PTR type on the service name.
dflet 0:1a07906111ec 660 The command that is sent is from constant parameters and variables parameters.
dflet 0:1a07906111ec 661
dflet 0:1a07906111ec 662 \param[in] pService Service name can be full or partial. \n
dflet 0:1a07906111ec 663 Example for full service name:
dflet 0:1a07906111ec 664 1. PC1._ipp._tcp.local
dflet 0:1a07906111ec 665 2. PC2_server._ftp._tcp.local \n
dflet 0:1a07906111ec 666 .
dflet 0:1a07906111ec 667 Example for partial service name:
dflet 0:1a07906111ec 668 1. _ipp._tcp.local
dflet 0:1a07906111ec 669 2. _ftp._tcp.local
dflet 0:1a07906111ec 670
dflet 0:1a07906111ec 671 \param[in] ServiceLen The length of the service name (in_pService).
dflet 0:1a07906111ec 672 \param[in] Family IPv4 or IPv6 (SL_AF_INET , SL_AF_INET6).
dflet 0:1a07906111ec 673 \param[out] pAddr Contains the IP address of the service.
dflet 0:1a07906111ec 674 \param[out] pPort Contains the port of the service.
dflet 0:1a07906111ec 675 \param[out] pTextLen Has 2 options. One as Input field and the other one as output:
dflet 0:1a07906111ec 676 - Input: \n
dflet 0:1a07906111ec 677 Contains the max length of the text that the user wants to get.\n
dflet 0:1a07906111ec 678 It means that if the text len of service is bigger that its value than
dflet 0:1a07906111ec 679 the text is cut to inout_TextLen value.
dflet 0:1a07906111ec 680 - Output: \n
dflet 0:1a07906111ec 681 Contain the length of the text that is returned. Can be full text or part of the text (see above).
dflet 0:1a07906111ec 682
dflet 0:1a07906111ec 683 \param[out] pOut_pText Contains the text of the service full or partial
dflet 0:1a07906111ec 684
dflet 0:1a07906111ec 685 \return On success, zero is returned
dflet 0:1a07906111ec 686 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
dflet 0:1a07906111ec 687 In this case try again later or increase MAX_CONCURRENT_ACTIONS
dflet 0:1a07906111ec 688 In case No service is found error SL_NET_APP_DNS_NO_ANSWER will be returned
dflet 0:1a07906111ec 689
dflet 0:1a07906111ec 690 \note The returns attributes belongs to the first service found.
dflet 0:1a07906111ec 691 There may be other services with the same service name that will response to the query.
dflet 0:1a07906111ec 692 The results of these responses are saved in the peer cache of the Device and should be read by another API.
dflet 0:1a07906111ec 693
dflet 0:1a07906111ec 694 Only one sl_NetAppDnsGetHostByService can be handled at a time.
dflet 0:1a07906111ec 695 Calling this API while the same command is called from another thread, may result
dflet 0:1a07906111ec 696 in one of the two scenarios:
dflet 0:1a07906111ec 697 1. The command will wait (internal) until the previous command finish, and then be executed.
dflet 0:1a07906111ec 698 2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
dflet 0:1a07906111ec 699 In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
dflet 0:1a07906111ec 700 again later to issue the command.
dflet 0:1a07906111ec 701
dflet 0:1a07906111ec 702 \warning Text length can be 120 bytes only
dflet 0:1a07906111ec 703 */
dflet 0:1a07906111ec 704 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByService)
dflet 0:1a07906111ec 705 int32_t sl_NetAppDnsGetHostByService(unsigned char *pServiceName, /* string containing all (or only part): name + subtype + service */
dflet 0:1a07906111ec 706 const uint8_t ServiceLen,
dflet 0:1a07906111ec 707 const uint8_t Family, /* 4-IPv4 , 16-IPv6 */
dflet 0:1a07906111ec 708 uint32_t pAddr[],
dflet 0:1a07906111ec 709 uint32_t *pPort,
dflet 0:1a07906111ec 710 uint16_t *pTextLen, /* in: max len , out: actual len */
dflet 0:1a07906111ec 711 unsigned char *pText
dflet 0:1a07906111ec 712 );
dflet 0:1a07906111ec 713
dflet 0:1a07906111ec 714 #endif
dflet 0:1a07906111ec 715
dflet 0:1a07906111ec 716 /*!
dflet 0:1a07906111ec 717 \brief Get service List
dflet 0:1a07906111ec 718 Insert into out pBuffer a list of peer's services that are the NWP.
dflet 0:1a07906111ec 719 The list is in a form of service struct. The user should chose the type
dflet 0:1a07906111ec 720 of the service struct like:
dflet 0:1a07906111ec 721 - Full service parameters with text.
dflet 0:1a07906111ec 722 - Full service parameters.
dflet 0:1a07906111ec 723 - Short service parameters (port and IP only) especially for tiny hosts.
dflet 0:1a07906111ec 724
dflet 0:1a07906111ec 725 The different types of struct are made to give the
dflet 0:1a07906111ec 726 Possibility to save memory in the host
dflet 0:1a07906111ec 727
dflet 0:1a07906111ec 728
dflet 0:1a07906111ec 729 The user also chose how many max services to get and start point index
dflet 0:1a07906111ec 730 NWP peer cache.
dflet 0:1a07906111ec 731 For example:
dflet 0:1a07906111ec 732 1. Get max of 3 full services from index 0.Up to 3 full services
dflet 0:1a07906111ec 733 from index 0 are inserted into pBuffer (services that are in indexes 0,1,2).
dflet 0:1a07906111ec 734 2. Get max of 4 full services from index 3.Up to 4 full services
dflet 0:1a07906111ec 735 from index 3 are inserted into pBuffer (services that are in indexes 3,4,5,6).
dflet 0:1a07906111ec 736 3. Get max of 2 int services from index 6.Up to 2 int services
dflet 0:1a07906111ec 737 from index 6 are inserted into pBuffer (services that are in indexes 6,7).
dflet 0:1a07906111ec 738
dflet 0:1a07906111ec 739 See below - command parameters.
dflet 0:1a07906111ec 740
dflet 0:1a07906111ec 741 \param[in] indexOffset - The start index in the peer cache that from it the first service is returned.
dflet 0:1a07906111ec 742 \param[in] MaxServiceCount - The Max services that can be returned if existed or if not exceed the max index
dflet 0:1a07906111ec 743 in the peer cache
dflet 0:1a07906111ec 744 \param[in] Flags - an ENUM number that means which service struct to use (means which types of service to fill)
dflet 0:1a07906111ec 745 - use SlNetAppGetFullServiceWithTextIpv4List_t
dflet 0:1a07906111ec 746 - use SlNetAppGetFullServiceIpv4List_t
dflet 0:1a07906111ec 747 - use SlNetAppGetShortServiceIpv4List_t
dflet 0:1a07906111ec 748
dflet 0:1a07906111ec 749 \param[out] Buffer - The Services are inserted into this buffer. In the struct form according to the bit that is set in the Flags
dflet 0:1a07906111ec 750 input parameter.
dflet 0:1a07906111ec 751
dflet 0:1a07906111ec 752 \return ServiceFoundCount - The number of the services that were inserted into the buffer. zero means no service is found
dflet 0:1a07906111ec 753 negative number means an error
dflet 0:1a07906111ec 754 \sa sl_NetAppMDNSRegisterService
dflet 0:1a07906111ec 755 \note
dflet 0:1a07906111ec 756 \warning
dflet 0:1a07906111ec 757 if the out pBuffer size is bigger than an RX packet(1480), than
dflet 0:1a07906111ec 758 an error is returned because there
dflet 0:1a07906111ec 759 is no place in the RX packet.
dflet 0:1a07906111ec 760 The size is a multiply of MaxServiceCount and size of service struct(that is set
dflet 0:1a07906111ec 761 according to flag value).
dflet 0:1a07906111ec 762 */
dflet 0:1a07906111ec 763
dflet 0:1a07906111ec 764 #if _SL_INCLUDE_FUNC(sl_NetAppGetServiceList)
dflet 0:1a07906111ec 765 int16_t sl_NetAppGetServiceList(const uint8_t IndexOffest,
dflet 0:1a07906111ec 766 const uint8_t MaxServiceCount,
dflet 0:1a07906111ec 767 const uint8_t Flags,
dflet 0:1a07906111ec 768 int8_t *pBuffer,
dflet 0:1a07906111ec 769 const uint32_t RxBufferLength
dflet 0:1a07906111ec 770 );
dflet 0:1a07906111ec 771
dflet 0:1a07906111ec 772 #endif
dflet 0:1a07906111ec 773
dflet 0:1a07906111ec 774 /*!
dflet 0:1a07906111ec 775 \brief Unregister mDNS service
dflet 0:1a07906111ec 776 This function deletes the mDNS service from the mDNS package and the database.
dflet 0:1a07906111ec 777
dflet 0:1a07906111ec 778 The mDNS service that is to be unregistered is a service that the application no longer wishes to provide. \n
dflet 0:1a07906111ec 779 The service name should be the full service name according to RFC
dflet 0:1a07906111ec 780 of the DNS-SD - meaning the value in name field in the SRV answer.
dflet 0:1a07906111ec 781
dflet 0:1a07906111ec 782 Examples for service names:
dflet 0:1a07906111ec 783 1. PC1._ipp._tcp.local
dflet 0:1a07906111ec 784 2. PC2_server._ftp._tcp.local
dflet 0:1a07906111ec 785
dflet 0:1a07906111ec 786 \param[in] pServiceName Full service name. \n
dflet 0:1a07906111ec 787 Example for service name:
dflet 0:1a07906111ec 788 1. PC1._ipp._tcp.local
dflet 0:1a07906111ec 789 2. PC2_server._ftp._tcp.local
dflet 0:1a07906111ec 790 \param[in] ServiceLen The length of the service.
dflet 0:1a07906111ec 791 \return On success, zero is returned
dflet 0:1a07906111ec 792 \sa sl_NetAppMDNSRegisterService
dflet 0:1a07906111ec 793 \note
dflet 0:1a07906111ec 794 \warning
dflet 0:1a07906111ec 795 The size of the service length should be smaller than 255.
dflet 0:1a07906111ec 796 */
dflet 0:1a07906111ec 797 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSUnRegisterService)
dflet 0:1a07906111ec 798 int16_t sl_NetAppMDNSUnRegisterService(const char *pServiceName, const uint8_t ServiceNameLen);
dflet 0:1a07906111ec 799 #endif
dflet 0:1a07906111ec 800
dflet 0:1a07906111ec 801 /*!
dflet 0:1a07906111ec 802 \brief Register a new mDNS service
dflet 0:1a07906111ec 803 \par
dflet 0:1a07906111ec 804 This function registers a new mDNS service to the mDNS package and the DB.
dflet 0:1a07906111ec 805
dflet 0:1a07906111ec 806 This registered service is a service offered by the application.
dflet 0:1a07906111ec 807 The service name should be full service name according to RFC
dflet 0:1a07906111ec 808 of the DNS-SD - meaning the value in name field in the SRV answer.
dflet 0:1a07906111ec 809 Example for service name:
dflet 0:1a07906111ec 810 1. PC1._ipp._tcp.local
dflet 0:1a07906111ec 811 2. PC2_server._ftp._tcp.local
dflet 0:1a07906111ec 812
dflet 0:1a07906111ec 813 If the option is_unique is set, mDNS probes the service name to make sure
dflet 0:1a07906111ec 814 it is unique before starting to announce the service on the network.
dflet 0:1a07906111ec 815 Instance is the instance portion of the service name.
dflet 0:1a07906111ec 816
dflet 0:1a07906111ec 817 \param[in] ServiceLen The length of the service.
dflet 0:1a07906111ec 818 \param[in] TextLen The length of the service should be smaller than 64.
dflet 0:1a07906111ec 819 \param[in] port The port on this target host port.
dflet 0:1a07906111ec 820 \param[in] TTL The TTL of the service
dflet 0:1a07906111ec 821 \param[in] Options bitwise parameters: \n
dflet 0:1a07906111ec 822 - bit 0 - service is unique (means that the service needs to be unique)
dflet 0:1a07906111ec 823 - bit 31 - for internal use if the service should be added or deleted (set means ADD).
dflet 0:1a07906111ec 824 - bit 1-30 for future.
dflet 0:1a07906111ec 825
dflet 0:1a07906111ec 826 \param[in] pServiceName The service name.
dflet 0:1a07906111ec 827 Example for service name: \n
dflet 0:1a07906111ec 828 1. PC1._ipp._tcp.local
dflet 0:1a07906111ec 829 2. PC2_server._ftp._tcp.local
dflet 0:1a07906111ec 830
dflet 0:1a07906111ec 831 \param[in] pText The description of the service.
dflet 0:1a07906111ec 832 should be as mentioned in the RFC
dflet 0:1a07906111ec 833 (according to type of the service IPP,FTP...)
dflet 0:1a07906111ec 834
dflet 0:1a07906111ec 835 \return On success, zero is returned
dflet 0:1a07906111ec 836 Possible error codes:
dflet 0:1a07906111ec 837 - Maximum advertise services are already configured.
dflet 0:1a07906111ec 838 Delete another existed service that is registered and then register again the new service
dflet 0:1a07906111ec 839 - Trying to register a service that is already exists
dflet 0:1a07906111ec 840 - Trying to delete service that does not existed
dflet 0:1a07906111ec 841 - Illegal service name according to the RFC
dflet 0:1a07906111ec 842 - Retry request
dflet 0:1a07906111ec 843 - Illegal length of one of the mDNS Set functions
dflet 0:1a07906111ec 844 - mDNS is not operational as the device has no IP.Connect the device to an AP to get an IP address.
dflet 0:1a07906111ec 845 - mDNS parameters error
dflet 0:1a07906111ec 846 - mDNS internal cache error
dflet 0:1a07906111ec 847 - mDNS internal error
dflet 0:1a07906111ec 848 - Adding a service is not allowed as it is already exist (duplicate service)
dflet 0:1a07906111ec 849 - mDNS is not running
dflet 0:1a07906111ec 850 - Host name error. Host name format is not allowed according to RFC 1033,1034,1035, 6763
dflet 0:1a07906111ec 851 - List size buffer is bigger than internally allowed in the NWP (API get service list),
dflet 0:1a07906111ec 852 change the APIs� parameters to decrease the size of the list
dflet 0:1a07906111ec 853
dflet 0:1a07906111ec 854
dflet 0:1a07906111ec 855 \sa sl_NetAppMDNSUnRegisterService
dflet 0:1a07906111ec 856
dflet 0:1a07906111ec 857 \warning 1) Temporary - there is an allocation on stack of internal buffer.
dflet 0:1a07906111ec 858 Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. \n
dflet 0:1a07906111ec 859 It means that the sum of the text length and service name length cannot be bigger than
dflet 0:1a07906111ec 860 NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.\n
dflet 0:1a07906111ec 861 If it is - An error is returned. \n
dflet 0:1a07906111ec 862 2) According to now from certain constraints the variables parameters are set in the
dflet 0:1a07906111ec 863 attribute part (contain constant parameters)
dflet 0:1a07906111ec 864 */
dflet 0:1a07906111ec 865 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterService)
dflet 0:1a07906111ec 866 int16_t sl_NetAppMDNSRegisterService( const char* pServiceName,
dflet 0:1a07906111ec 867 const uint8_t ServiceNameLen,
dflet 0:1a07906111ec 868 const char* pText,
dflet 0:1a07906111ec 869 const uint8_t TextLen,
dflet 0:1a07906111ec 870 const uint16_t Port,
dflet 0:1a07906111ec 871 const uint32_t TTL,
dflet 0:1a07906111ec 872 uint32_t Options);
dflet 0:1a07906111ec 873 #endif
dflet 0:1a07906111ec 874
dflet 0:1a07906111ec 875 /*!
dflet 0:1a07906111ec 876 \brief send ICMP ECHO_REQUEST to network hosts
dflet 0:1a07906111ec 877
dflet 0:1a07906111ec 878 Ping uses the ICMP protocol's mandatory ECHO_REQUEST
dflet 0:1a07906111ec 879
dflet 0:1a07906111ec 880 \param[in] pPingParams Pointer to the ping request structure: \n
dflet 0:1a07906111ec 881 - if flags parameter is set to 0, ping will report back once all requested pings are done (as defined by TotalNumberOfAttempts). \n
dflet 0:1a07906111ec 882 - if flags parameter is set to 1, ping will report back after every ping, for TotalNumberOfAttempts.
dflet 0:1a07906111ec 883 - if flags parameter is set to 2, ping will stop after the first successful ping, and report back for the successful ping, as well as any preceding failed ones.
dflet 0:1a07906111ec 884 For stopping an ongoing ping activity, set parameters IP address to 0
dflet 0:1a07906111ec 885
dflet 0:1a07906111ec 886 \param[in] family SL_AF_INET or SL_AF_INET6
dflet 0:1a07906111ec 887 \param[out] pReport Ping pReport
dflet 0:1a07906111ec 888 \param[out] pCallback Callback function upon completion.
dflet 0:1a07906111ec 889 If callback is NULL, the API is blocked until data arrives
dflet 0:1a07906111ec 890
dflet 0:1a07906111ec 891
dflet 0:1a07906111ec 892 \return On success, zero is returned. On error, -1 is returned
dflet 0:1a07906111ec 893 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
dflet 0:1a07906111ec 894 In this case try again later or increase MAX_CONCURRENT_ACTIONS
dflet 0:1a07906111ec 895
dflet 0:1a07906111ec 896 \sa sl_NetAppPingReport
dflet 0:1a07906111ec 897 \note Only one sl_NetAppPingStart can be handled at a time.
dflet 0:1a07906111ec 898 Calling this API while the same command is called from another thread, may result
dflet 0:1a07906111ec 899 in one of the two scenarios:
dflet 0:1a07906111ec 900 1. The command will wait (internal) until the previous command finish, and then be executed.
dflet 0:1a07906111ec 901 2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
dflet 0:1a07906111ec 902 In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
dflet 0:1a07906111ec 903 again later to issue the command.
dflet 0:1a07906111ec 904 \warning
dflet 0:1a07906111ec 905 \par Example:
dflet 0:1a07906111ec 906 \code
dflet 0:1a07906111ec 907
dflet 0:1a07906111ec 908 An example of sending 20 ping requests and reporting results to a callback routine when
dflet 0:1a07906111ec 909 all requests are sent:
dflet 0:1a07906111ec 910
dflet 0:1a07906111ec 911 // callback routine
dflet 0:1a07906111ec 912 void pingRes(SlPingReport_t* pReport)
dflet 0:1a07906111ec 913 {
dflet 0:1a07906111ec 914 // handle ping results
dflet 0:1a07906111ec 915 }
dflet 0:1a07906111ec 916
dflet 0:1a07906111ec 917 // ping activation
dflet 0:1a07906111ec 918 void PingTest()
dflet 0:1a07906111ec 919 {
dflet 0:1a07906111ec 920 SlPingReport_t report;
dflet 0:1a07906111ec 921 SlPingStartCommand_t pingCommand;
dflet 0:1a07906111ec 922
dflet 0:1a07906111ec 923 pingCommand.Ip = SL_IPV4_VAL(10,1,1,200); // destination IP address is 10.1.1.200
dflet 0:1a07906111ec 924 pingCommand.PingSize = 150; // size of ping, in bytes
dflet 0:1a07906111ec 925 pingCommand.PingIntervalTime = 100; // delay between pings, in milliseconds
dflet 0:1a07906111ec 926 pingCommand.PingRequestTimeout = 1000; // timeout for every ping in milliseconds
dflet 0:1a07906111ec 927 pingCommand.TotalNumberOfAttempts = 20; // max number of ping requests. 0 - forever
dflet 0:1a07906111ec 928 pingCommand.Flags = 0; // report only when finished
dflet 0:1a07906111ec 929
dflet 0:1a07906111ec 930 sl_NetAppPingStart( &pingCommand, SL_AF_INET, &report, pingRes ) ;
dflet 0:1a07906111ec 931 }
dflet 0:1a07906111ec 932
dflet 0:1a07906111ec 933 \endcode
dflet 0:1a07906111ec 934 */
dflet 0:1a07906111ec 935 #if _SL_INCLUDE_FUNC(sl_NetAppPingStart)
dflet 0:1a07906111ec 936 int16_t sl_NetAppPingStart(const SlPingStartCommand_t* pPingParams, const uint8_t family,SlPingReport_t *pReport, const P_SL_DEV_PING_CALLBACK pPingCallback);
dflet 0:1a07906111ec 937 #endif
dflet 0:1a07906111ec 938
dflet 0:1a07906111ec 939 /*!
dflet 0:1a07906111ec 940 \brief Internal function for setting network application configurations
dflet 0:1a07906111ec 941
dflet 0:1a07906111ec 942 \return On success, zero is returned. On error, -1 is
dflet 0:1a07906111ec 943 returned
dflet 0:1a07906111ec 944
dflet 0:1a07906111ec 945 \param[in] AppId Application id, could be one of the following: \n
dflet 0:1a07906111ec 946 - SL_NET_APP_HTTP_SERVER_ID
dflet 0:1a07906111ec 947 - SL_NET_APP_DHCP_SERVER_ID
dflet 0:1a07906111ec 948 - SL_NET_APP_MDNS_ID
dflet 0:1a07906111ec 949 - SL_NET_APP_DEVICE_CONFIG_ID
dflet 0:1a07906111ec 950
dflet 0:1a07906111ec 951 \param[in] SetOptions set option, could be one of the following: \n
dflet 0:1a07906111ec 952 - SL_NET_APP_DHCP_SERVER_ID
dflet 0:1a07906111ec 953 - NETAPP_SET_DHCP_SRV_BASIC_OPT
dflet 0:1a07906111ec 954 - SL_NET_APP_HTTP_SERVER_ID
dflet 0:1a07906111ec 955 - NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER
dflet 0:1a07906111ec 956 - NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK
dflet 0:1a07906111ec 957 - NETAPP_SET_GET_HTTP_OPT_AUTH_NAME
dflet 0:1a07906111ec 958 - NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD
dflet 0:1a07906111ec 959 - NETAPP_SET_GET_HTTP_OPT_AUTH_REALM
dflet 0:1a07906111ec 960 - NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS
dflet 0:1a07906111ec 961 - SL_NET_APP_MDNS_ID
dflet 0:1a07906111ec 962 - NETAPP_SET_GET_MDNS_CONT_QUERY_OPT
dflet 0:1a07906111ec 963 - NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT
dflet 0:1a07906111ec 964 - NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT
dflet 0:1a07906111ec 965 - SL_NET_APP_DEVICE_CONFIG_ID
dflet 0:1a07906111ec 966 - NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN
dflet 0:1a07906111ec 967 - NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME
dflet 0:1a07906111ec 968
dflet 0:1a07906111ec 969
dflet 0:1a07906111ec 970 \param[in] OptionLen option structure length
dflet 0:1a07906111ec 971
dflet 0:1a07906111ec 972 \param[in] pOptionValues pointer to the option structure
dflet 0:1a07906111ec 973 \sa
dflet 0:1a07906111ec 974 \note
dflet 0:1a07906111ec 975 \warning
dflet 0:1a07906111ec 976 \par
dflet 0:1a07906111ec 977 \code
dflet 0:1a07906111ec 978 Set DHCP Server (AP mode) parameters example:
dflet 0:1a07906111ec 979
dflet 0:1a07906111ec 980 SlNetAppDhcpServerBasicOpt_t dhcpParams;
dflet 0:1a07906111ec 981 uint8_t outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
dflet 0:1a07906111ec 982 dhcpParams.lease_time = 4096; // lease time (in seconds) of the IP Address
dflet 0:1a07906111ec 983 dhcpParams.ipv4_addr_start = SL_IPV4_VAL(192,168,1,10); // first IP Address for allocation. IP Address should be set as Hex number - i.e. 0A0B0C01 for (10.11.12.1)
dflet 0:1a07906111ec 984 dhcpParams.ipv4_addr_last = SL_IPV4_VAL(192,168,1,16); // last IP Address for allocation. IP Address should be set as Hex number - i.e. 0A0B0C01 for (10.11.12.1)
dflet 0:1a07906111ec 985 sl_NetAppStop(SL_NET_APP_DHCP_SERVER_ID); // Stop DHCP server before settings
dflet 0:1a07906111ec 986 sl_NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, outLen, (uint8_t* )&dhcpParams); // set parameters
dflet 0:1a07906111ec 987 sl_NetAppStart(SL_NET_APP_DHCP_SERVER_ID); // Start DHCP server with new settings
dflet 0:1a07906111ec 988 \endcode
dflet 0:1a07906111ec 989 \code
dflet 0:1a07906111ec 990 Set Device URN name example:
dflet 0:1a07906111ec 991
dflet 0:1a07906111ec 992 Device name, maximum length of 33 characters
dflet 0:1a07906111ec 993 Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P)
dflet 0:1a07906111ec 994 In case no device URN name set, the default name is "mysimplelink"
dflet 0:1a07906111ec 995 Allowed characters in device name are: 'a - z' , 'A - Z' , '0-9' and '-'
dflet 0:1a07906111ec 996
dflet 0:1a07906111ec 997 uint8_t *my_device = "MY-SIMPLELINK-DEV";
dflet 0:1a07906111ec 998 sl_NetAppSet (SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen(my_device), (uint8_t *) my_device);
dflet 0:1a07906111ec 999 \endcode
dflet 0:1a07906111ec 1000
dflet 0:1a07906111ec 1001 */
dflet 0:1a07906111ec 1002 #if _SL_INCLUDE_FUNC(sl_NetAppSet)
dflet 0:1a07906111ec 1003 int32_t sl_NetAppSet(const uint8_t AppId, const uint8_t Option, const uint8_t OptionLen, const uint8_t *pOptionValue);
dflet 0:1a07906111ec 1004 #endif
dflet 0:1a07906111ec 1005
dflet 0:1a07906111ec 1006 /*!
dflet 0:1a07906111ec 1007 \brief Internal function for getting network applications configurations
dflet 0:1a07906111ec 1008
dflet 0:1a07906111ec 1009 \return On success, zero is returned. On error, -1 is
dflet 0:1a07906111ec 1010 returned
dflet 0:1a07906111ec 1011
dflet 0:1a07906111ec 1012 \param[in] AppId Application id, could be one of the following: \n
dflet 0:1a07906111ec 1013 - SL_NET_APP_HTTP_SERVER_ID
dflet 0:1a07906111ec 1014 - SL_NET_APP_DHCP_SERVER_ID
dflet 0:1a07906111ec 1015 - SL_NET_APP_MDNS_ID
dflet 0:1a07906111ec 1016 - SL_NET_APP_DEVICE_CONFIG_ID
dflet 0:1a07906111ec 1017
dflet 0:1a07906111ec 1018 \param[in] SetOptions set option, could be one of the following: \n
dflet 0:1a07906111ec 1019 - SL_NET_APP_DHCP_SERVER_ID
dflet 0:1a07906111ec 1020 - NETAPP_SET_DHCP_SRV_BASIC_OPT
dflet 0:1a07906111ec 1021 - SL_NET_APP_HTTP_SERVER_ID
dflet 0:1a07906111ec 1022 - NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER
dflet 0:1a07906111ec 1023 - NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK
dflet 0:1a07906111ec 1024 - NETAPP_SET_GET_HTTP_OPT_AUTH_NAME
dflet 0:1a07906111ec 1025 - NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD
dflet 0:1a07906111ec 1026 - NETAPP_SET_GET_HTTP_OPT_AUTH_REALM
dflet 0:1a07906111ec 1027 - NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS
dflet 0:1a07906111ec 1028 - SL_NET_APP_MDNS_ID
dflet 0:1a07906111ec 1029 - NETAPP_SET_GET_MDNS_CONT_QUERY_OPT
dflet 0:1a07906111ec 1030 - NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT
dflet 0:1a07906111ec 1031 - NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT
dflet 0:1a07906111ec 1032 - SL_NET_APP_DEVICE_CONFIG_ID
dflet 0:1a07906111ec 1033 - NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN
dflet 0:1a07906111ec 1034 - NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME
dflet 0:1a07906111ec 1035
dflet 0:1a07906111ec 1036 \param[in] OptionLen The length of the allocated memory as input, when the
dflet 0:1a07906111ec 1037 function complete, the value of this parameter would be
dflet 0:1a07906111ec 1038 the len that actually read from the device.
dflet 0:1a07906111ec 1039 If the device return length that is longer from the input
dflet 0:1a07906111ec 1040 value, the function will cut the end of the returned structure
dflet 0:1a07906111ec 1041 and will return ESMALLBUF
dflet 0:1a07906111ec 1042
dflet 0:1a07906111ec 1043 \param[out] pValues pointer to the option structure which will be filled with the response from the device
dflet 0:1a07906111ec 1044
dflet 0:1a07906111ec 1045 \sa
dflet 0:1a07906111ec 1046 \note
dflet 0:1a07906111ec 1047 \warning
dflet 0:1a07906111ec 1048 \par
dflet 0:1a07906111ec 1049 \code
dflet 0:1a07906111ec 1050 Get DHCP Server parameters example:
dflet 0:1a07906111ec 1051
dflet 0:1a07906111ec 1052 SlNetAppDhcpServerBasicOpt_t dhcpParams;
dflet 0:1a07906111ec 1053 uint8_t outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
dflet 0:1a07906111ec 1054 sl_NetAppGet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, &outLen, (uint8_t* )&dhcpParams);
dflet 0:1a07906111ec 1055
dflet 0:1a07906111ec 1056 printf("DHCP Start IP %d.%d.%d.%d End IP %d.%d.%d.%d Lease time seconds %d\n",
dflet 0:1a07906111ec 1057 SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,2),
dflet 0:1a07906111ec 1058 SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,0),
dflet 0:1a07906111ec 1059 SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,2),
dflet 0:1a07906111ec 1060 SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,0),
dflet 0:1a07906111ec 1061 dhcpParams.lease_time);
dflet 0:1a07906111ec 1062 \endcode
dflet 0:1a07906111ec 1063 \code
dflet 0:1a07906111ec 1064 Get Device URN name example:
dflet 0:1a07906111ec 1065 Maximum length of 33 characters of device name.
dflet 0:1a07906111ec 1066 Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P)
dflet 0:1a07906111ec 1067 in case no device URN name set, the default name is "mysimplelink"
dflet 0:1a07906111ec 1068
dflet 0:1a07906111ec 1069 uint8_t my_device_name[35];
dflet 0:1a07906111ec 1070 sl_NetAppGet (SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen(my_device_name), (uint8_t *)my_device_name);
dflet 0:1a07906111ec 1071 \endcode
dflet 0:1a07906111ec 1072 */
dflet 0:1a07906111ec 1073 #if _SL_INCLUDE_FUNC(sl_NetAppGet)
dflet 0:1a07906111ec 1074 int32_t sl_NetAppGet(const uint8_t AppId, const uint8_t Option,uint8_t *pOptionLen, uint8_t *pOptionValue);
dflet 0:1a07906111ec 1075 #endif
dflet 0:1a07906111ec 1076
dflet 0:1a07906111ec 1077 private:
dflet 0:1a07906111ec 1078
dflet 0:1a07906111ec 1079 cc3100_driver &_driver;
dflet 0:1a07906111ec 1080 cc3100_nonos &_nonos;
dflet 0:1a07906111ec 1081
dflet 0:1a07906111ec 1082
dflet 0:1a07906111ec 1083 };//class
dflet 0:1a07906111ec 1084
dflet 0:1a07906111ec 1085 /*****************************************************************************/
dflet 0:1a07906111ec 1086 /* Macro declarations */
dflet 0:1a07906111ec 1087 /*****************************************************************************/
dflet 0:1a07906111ec 1088 const uint8_t FLOW_CONT_MIN = 1;
dflet 0:1a07906111ec 1089
dflet 0:1a07906111ec 1090
dflet 0:1a07906111ec 1091 class cc3100_flowcont
dflet 0:1a07906111ec 1092 {
dflet 0:1a07906111ec 1093
dflet 0:1a07906111ec 1094 public:
dflet 0:1a07906111ec 1095
dflet 0:1a07906111ec 1096 cc3100_flowcont(cc3100_driver &driver, cc3100_nonos &nonos);
dflet 0:1a07906111ec 1097
dflet 0:1a07906111ec 1098
dflet 0:1a07906111ec 1099 ~cc3100_flowcont();
dflet 0:1a07906111ec 1100
dflet 0:1a07906111ec 1101 #if 0
dflet 0:1a07906111ec 1102 /*****************************************************************************/
dflet 0:1a07906111ec 1103 /* Function prototypes */
dflet 0:1a07906111ec 1104 /*****************************************************************************/
dflet 0:1a07906111ec 1105 void _SlDrvFlowContInit(void);
dflet 0:1a07906111ec 1106 void _SlDrvFlowContDeinit(void);
dflet 0:1a07906111ec 1107 #endif
dflet 0:1a07906111ec 1108
dflet 0:1a07906111ec 1109 private:
dflet 0:1a07906111ec 1110
dflet 0:1a07906111ec 1111 cc3100_driver &_driver;
dflet 0:1a07906111ec 1112 cc3100_nonos &_nonos;
dflet 0:1a07906111ec 1113
dflet 0:1a07906111ec 1114 };//class
dflet 0:1a07906111ec 1115 }//namespace mbed_cc3100
dflet 0:1a07906111ec 1116
dflet 0:1a07906111ec 1117 /*!
dflet 0:1a07906111ec 1118
dflet 0:1a07906111ec 1119 Close the Doxygen group.
dflet 0:1a07906111ec 1120 @}
dflet 0:1a07906111ec 1121
dflet 0:1a07906111ec 1122 */
dflet 0:1a07906111ec 1123
dflet 0:1a07906111ec 1124 #endif /* __NETAPP_H__ */
dflet 0:1a07906111ec 1125
dflet 0:1a07906111ec 1126