Update revision to use TI's mqtt and Freertos.

Dependencies:   mbed client server

Fork of cc3100_Test_mqtt_CM3 by David Fletcher

Committer:
dflet
Date:
Thu Sep 03 14:02:37 2015 +0000
Revision:
3:a8c249046181
SPI Mode change 1 to 0

Who changed what in which revision?

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