Port of TI's CC3100 Websock camera demo. Using FreeRTOS, mbedTLS, also parts of Arducam for cams ov5642 and 0v2640. Can also use MT9D111. Work in progress. Be warned some parts maybe a bit flacky. This is for Seeed Arch max only, for an M3, see the demo for CM3 using the 0v5642 aducam mini.

Dependencies:   mbed

Committer:
dflet
Date:
Tue Sep 15 16:45:04 2015 +0000
Revision:
22:f9b5e0b80bf2
Parent:
19:3dd3e7f30f8b
Removed some debug.

Who changed what in which revision?

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