TI's CC3100. A test demo with very little testing done!

Dependencies:   mbed

Fork of cc3100_Test_Demo2 by 高 杨

Committer:
dflet
Date:
Tue Feb 10 12:09:29 2015 +0000
Revision:
0:e89ba455dbcf
For test only! Not much has been tested, but the 2 demo apps run ok. Alot more work needs to be done!

Who changed what in which revision?

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