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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cc3100_netapp.h Source File

cc3100_netapp.h

00001 /*
00002  * netapp.h - CC31xx/CC32xx Host Driver Implementation
00003  *
00004  * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
00005  *
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *    Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  *
00014  *    Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in the
00016  *    documentation and/or other materials provided with the
00017  *    distribution.
00018  *
00019  *    Neither the name of Texas Instruments Incorporated nor the names of
00020  *    its contributors may be used to endorse or promote products derived
00021  *    from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00026  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00027  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00028  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00029  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00030  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00031  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00032  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00033  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034  *
00035 */
00036 
00037 /*****************************************************************************/
00038 /* Include files                                                             */
00039 /*****************************************************************************/
00040 
00041 #include "cc3100_simplelink.h"
00042 
00043 #ifndef NETAPP_H_
00044 #define    NETAPP_H_
00045 
00046 #include "cc3100_protocol.h"
00047 #include "cc3100_nonos.h"
00048 
00049 namespace mbed_cc3100 {
00050 
00051 /*!
00052 
00053     \addtogroup netapp
00054     @{
00055 
00056 */
00057 
00058 /*****************************************************************************/
00059 /* Macro declarations                                                        */
00060 /*****************************************************************************/
00061 
00062 /*ERROR code*/
00063 const int16_t SL_ERROR_NETAPP_RX_BUFFER_LENGTH_ERROR      = (-230);
00064 
00065 /*  Http Server interface */
00066 const uint8_t MAX_INPUT_STRING                            =  (64); /*  because of WPA */
00067 
00068 const uint8_t MAX_AUTH_NAME_LEN                           =  (20);
00069 const uint8_t MAX_AUTH_PASSWORD_LEN                       =  (20);
00070 const uint8_t MAX_AUTH_REALM_LEN                          =  (20);
00071 
00072 const uint8_t MAX_DEVICE_URN_LEN                          =  (15+1);
00073 const uint8_t MAX_DOMAIN_NAME_LEN                         =  (24+1);
00074 
00075 const uint8_t MAX_ACTION_LEN                              =  (30);
00076 /* Important: in case the max len is changed, make sure the struct sl_NetAppHttpServerSendToken_t in protocol.h is padded correctly! */
00077 const uint8_t MAX_TOKEN_NAME_LEN                          =  (20);
00078 const uint8_t MAX_TOKEN_VALUE_LEN                         =  MAX_INPUT_STRING;
00079 
00080 const int16_t NETAPP_MAX_SERVICE_TEXT_SIZE                =  (256);
00081 const uint8_t NETAPP_MAX_SERVICE_NAME_SIZE                =  (60);
00082 const uint8_t NETAPP_MAX_SERVICE_HOST_NAME_SIZE           =  (64);
00083 
00084 
00085 /* Server Responses */
00086 const uint8_t SL_NETAPP_RESPONSE_NONE                     =  (0);
00087 const uint8_t SL_NETAPP_HTTPSETTOKENVALUE                 =  (1);
00088 
00089 const uint8_t SL_NETAPP_FAMILY_MASK                       =  (0x80);
00090 
00091 /* mDNS types */
00092 const uint32_t SL_NET_APP_MASK_IPP_TYPE_OF_SERVICE        =   (0x00000001);
00093 const uint32_t SL_NET_APP_MASK_DEVICE_INFO_TYPE_OF_SERVICE =  (0x00000002);
00094 const uint32_t SL_NET_APP_MASK_HTTP_TYPE_OF_SERVICE       =   (0x00000004);
00095 const uint32_t SL_NET_APP_MASK_HTTPS_TYPE_OF_SERVICE      =   (0x00000008);
00096 const uint32_t SL_NET_APP_MASK_WORKSATION_TYPE_OF_SERVICE =   (0x00000010);
00097 const uint32_t SL_NET_APP_MASK_GUID_TYPE_OF_SERVICE       =   (0x00000020);
00098 const uint32_t SL_NET_APP_MASK_H323_TYPE_OF_SERVICE       =   (0x00000040);
00099 const uint32_t SL_NET_APP_MASK_NTP_TYPE_OF_SERVICE        =   (0x00000080);
00100 const uint32_t SL_NET_APP_MASK_OBJECITVE_TYPE_OF_SERVICE  =   (0x00000100);
00101 const uint32_t SL_NET_APP_MASK_RDP_TYPE_OF_SERVICE        =   (0x00000200);
00102 const uint32_t SL_NET_APP_MASK_REMOTE_TYPE_OF_SERVICE     =   (0x00000400);
00103 const uint32_t SL_NET_APP_MASK_RTSP_TYPE_OF_SERVICE       =   (0x00000800);
00104 const uint32_t SL_NET_APP_MASK_SIP_TYPE_OF_SERVICE        =   (0x00001000);
00105 const uint32_t SL_NET_APP_MASK_SMB_TYPE_OF_SERVICE        =   (0x00002000);
00106 const uint32_t SL_NET_APP_MASK_SOAP_TYPE_OF_SERVICE       =   (0x00004000);
00107 const uint32_t SL_NET_APP_MASK_SSH_TYPE_OF_SERVICE        =   (0x00008000);
00108 const uint32_t SL_NET_APP_MASK_TELNET_TYPE_OF_SERVICE     =   (0x00010000);
00109 const uint32_t SL_NET_APP_MASK_TFTP_TYPE_OF_SERVICE       =   (0x00020000);
00110 const uint32_t SL_NET_APP_MASK_XMPP_CLIENT_TYPE_OF_SERVICE =  (0x00040000);
00111 const uint32_t SL_NET_APP_MASK_RAOP_TYPE_OF_SERVICE       =   (0x00080000);
00112 const uint32_t SL_NET_APP_MASK_ALL_TYPE_OF_SERVICE        =   (0xFFFFFFFF);
00113 
00114 /********************************************************************************************************/
00115 /* sl_NetAppDnsGetHostByName error codes     */
00116 
00117 const int16_t SL_NET_APP_DNS_QUERY_NO_RESPONSE            =  (-159);  /* DNS query failed, no response                        */
00118 const int16_t SL_NET_APP_DNS_NO_SERVER                    =  (-161);  /* No DNS server was specified                          */
00119 const int16_t SL_NET_APP_DNS_PARAM_ERROR                  =  (-162);  /* mDNS parameters error                                */
00120 const int16_t SL_NET_APP_DNS_QUERY_FAILED                 =  (-163);  /* DNS query failed; no DNS server sent an 'answer'     */
00121 const int16_t SL_NET_APP_DNS_INTERNAL_1                   =  (-164);
00122 const int16_t SL_NET_APP_DNS_INTERNAL_2                   =  (-165);
00123 const int16_t SL_NET_APP_DNS_MALFORMED_PACKET             =  (-166);  /* Improperly formed or corrupted DNS packet received   */
00124 const int16_t SL_NET_APP_DNS_INTERNAL_3                   =  (-167);
00125 const int16_t SL_NET_APP_DNS_INTERNAL_4                   =  (-168);
00126 const int16_t SL_NET_APP_DNS_INTERNAL_5                   =  (-169);
00127 const int16_t SL_NET_APP_DNS_INTERNAL_6                   =  (-170);
00128 const int16_t SL_NET_APP_DNS_INTERNAL_7                   =  (-171);
00129 const int16_t SL_NET_APP_DNS_INTERNAL_8                   =  (-172);
00130 const int16_t SL_NET_APP_DNS_INTERNAL_9                   =  (-173);
00131 const int16_t SL_NET_APP_DNS_MISMATCHED_RESPONSE          =  (-174);  /* Server response type does not match the query request*/
00132 const int16_t SL_NET_APP_DNS_INTERNAL_10                  =  (-175);
00133 const int16_t SL_NET_APP_DNS_INTERNAL_11                  =  (-176);
00134 const int16_t SL_NET_APP_DNS_NO_ANSWER                    =  (-177);  /* No response for one-shot query */
00135 const int16_t SL_NET_APP_DNS_NO_KNOWN_ANSWER              =  (-178);  /* No known answer for query */
00136 const int16_t SL_NET_APP_DNS_NAME_MISMATCH                =  (-179);  /* Illegal service name according to the RFC            */
00137 const int16_t SL_NET_APP_DNS_NOT_STARTED                  =  (-180);  /* mDNS is not running                                  */
00138 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 */
00139 const int16_t SL_NET_APP_DNS_NO_MORE_ENTRIES              =  (-182);  /* No more entries be found.                            */
00140 
00141 const int16_t SL_NET_APP_DNS_MAX_SERVICES_ERROR           =  (-200);  /* Maximum advertise services are already configured    */
00142 const int16_t SL_NET_APP_DNS_IDENTICAL_SERVICES_ERROR     =  (-201);  /* Trying to register a service that is already exists  */
00143 const int16_t SL_NET_APP_DNS_NOT_EXISTED_SERVICE_ERROR    =  (-203);  /* Trying to delete service that does not existed       */
00144 const int16_t SL_NET_APP_DNS_ERROR_SERVICE_NAME_ERROR     =  (-204);  /* Illegal service name according to the RFC            */
00145 const int16_t SL_NET_APP_DNS_RX_PACKET_ALLOCATION_ERROR   =  (-205);  /* Retry request                                        */
00146 const int16_t SL_NET_APP_DNS_BUFFER_SIZE_ERROR            =  (-206);  /* List size buffer is bigger than internally allowed in the NWP */
00147 const int16_t SL_NET_APP_DNS_NET_APP_SET_ERROR            =  (-207);  /* Illegal length of one of the mDNS Set functions      */
00148 const int16_t SL_NET_APP_DNS_GET_SERVICE_LIST_FLAG_ERROR  =  (-208);
00149 const int16_t SL_NET_APP_DNS_NO_CONFIGURATION_ERROR       =  (-209);
00150 
00151 /* Set Dev name error codes  (NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN) */
00152 const int16_t SL_ERROR_DEVICE_NAME_LEN_ERR                =   (-117);
00153 const int16_t SL_ERROR_DEVICE_NAME_INVALID                =   (-118);
00154 /* Set domain name error codes (NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME) */
00155 const int16_t SL_ERROR_DOMAIN_NAME_LEN_ERR                =   (-119);
00156 const int16_t SL_ERROR_DOMAIN_NAME_INVALID                =   (-120);
00157 
00158 /********************************************************************************************************/
00159 
00160 /* NetApp application IDs */
00161 const uint8_t SL_NET_APP_HTTP_SERVER_ID                   =  (1);
00162 const uint8_t SL_NET_APP_DHCP_SERVER_ID                   =  (2);
00163 const uint8_t SL_NET_APP_MDNS_ID                          =  (4);
00164 const uint8_t SL_NET_APP_DNS_SERVER_ID                    =  (8);
00165 const uint8_t SL_NET_APP_DEVICE_CONFIG_ID                 =  (16);
00166 /* NetApp application set/get options */
00167 const uint8_t NETAPP_SET_DHCP_SRV_BASIC_OPT               =  (0);
00168 /* HTTP server set/get options */
00169 const uint8_t NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER         =  (0);
00170 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK          =  (1);
00171 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_NAME           =  (2);
00172 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD       =  (3);
00173 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_REALM          =  (4);
00174 const uint8_t NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS    =  (5);
00175 
00176 const uint8_t NETAPP_SET_GET_MDNS_CONT_QUERY_OPT          =  (1);
00177 const uint8_t NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT         =  (2);
00178 const uint8_t NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT       =  (3);
00179 
00180 /* DNS server set/get options */
00181 const uint8_t NETAPP_SET_GET_DNS_OPT_DOMAIN_NAME          =  (0);
00182 
00183 /* Device Config set/get options */
00184 const uint8_t NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN      =  (0);
00185 const uint8_t NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME     =  (1);
00186 
00187 
00188 /*****************************************************************************/
00189 /* Structure/Enum declarations                                               */
00190 /*****************************************************************************/
00191 /*
00192  * The below structure depict the constant parameters that are returned in the Async event answer
00193  * according to command/API sl_DnsGetHostByService for IPv4 and IPv6.
00194  *
00195     1Status                     - The status of the response.
00196     2.Address                       - Contains the IP address of the service.
00197     3.Port                          - Contains the port of the service.
00198     4.TextLen                       - Contains the max length of the text that the user wants to get.
00199                                                 it means that if the test of service is bigger that its value than
00200                                                 the text is cut to inout_TextLen value.
00201                                         Output: Contain the length of the text that is returned. Can be full text or part
00202                                                 of the text (see above).
00203 
00204 *
00205  */
00206 typedef struct {
00207     uint16_t   Status;
00208     uint16_t   TextLen;
00209     uint32_t    Port;
00210     uint32_t    Address;
00211 } _GetHostByServiceIPv4AsyncResponse_t;
00212 
00213 /*
00214  * The below struct contains pointers to the output parameters that the user gives
00215  *
00216  */
00217 typedef struct {
00218     int16_t       Status;
00219     uint32_t      *out_pAddr;
00220     uint32_t      *out_pPort;
00221     uint16_t      *inout_TextLen; // in: max len , out: actual len
00222     unsigned char *out_pText;
00223 } _GetHostByServiceAsyncResponse_t;
00224 
00225 typedef struct {
00226     uint32_t    PacketsSent;
00227     uint32_t    PacketsReceived;
00228     uint16_t    MinRoundTime;
00229     uint16_t    MaxRoundTime;
00230     uint16_t    AvgRoundTime;
00231     uint32_t    TestTime;
00232 } SlPingReport_t;
00233 
00234 typedef struct {
00235     uint32_t    PingIntervalTime;       /* delay between pings, in milliseconds */
00236     uint16_t    PingSize;               /* ping packet size in bytes           */
00237     uint16_t    PingRequestTimeout;     /* timeout time for every ping in milliseconds  */
00238     uint32_t    TotalNumberOfAttempts;  /* max number of ping requests. 0 - forever    */
00239     uint32_t    Flags;                  /* flag - 0 report only when finished, 1 - return response for every ping, 2 - stop after 1 successful ping.  */
00240     uint32_t    Ip;                     /* IPv4 address or IPv6 first 4 bytes  */
00241     uint32_t    Ip1OrPaadding;
00242     uint32_t    Ip2OrPaadding;
00243     uint32_t    Ip3OrPaadding;
00244 } SlPingStartCommand_t;
00245 
00246 typedef struct _slHttpServerString_t {
00247     uint8_t     len;
00248     uint8_t     *data;
00249 } slHttpServerString_t;
00250 
00251 typedef struct _slHttpServerData_t {
00252     uint8_t     value_len;
00253     uint8_t     name_len;
00254     uint8_t     *token_value;
00255     uint8_t     *token_name;
00256 } slHttpServerData_t;
00257 
00258 typedef struct _slHttpServerPostData_t {
00259     slHttpServerString_t action;
00260     slHttpServerString_t token_name;
00261     slHttpServerString_t token_value;
00262 } slHttpServerPostData_t;
00263 
00264 typedef union {
00265     slHttpServerString_t     httpTokenName; /* SL_NETAPP_HTTPGETTOKENVALUE */
00266     slHttpServerPostData_t   httpPostData;  /* SL_NETAPP_HTTPPOSTTOKENVALUE */
00267 } SlHttpServerEventData_u;
00268 
00269 typedef union {
00270     slHttpServerString_t token_value;
00271 } SlHttpServerResponsedata_u;
00272 
00273 typedef struct {
00274     uint32_t                Event;
00275     SlHttpServerEventData_u EventData;
00276 } SlHttpServerEvent_t;
00277 
00278 typedef struct {
00279     uint32_t                   Response;
00280     SlHttpServerResponsedata_u ResponseData;
00281 } SlHttpServerResponse_t;
00282 
00283 
00284 typedef struct {
00285     uint32_t   lease_time;
00286     uint32_t   ipv4_addr_start;
00287     uint32_t   ipv4_addr_last;
00288 } SlNetAppDhcpServerBasicOpt_t;
00289 
00290 /*mDNS parameters*/
00291 typedef enum {
00292     SL_NET_APP_FULL_SERVICE_WITH_TEXT_IPV4_TYPE = 1,
00293     SL_NET_APP_FULL_SERVICE_IPV4_TYPE,
00294     SL_NET_APP_SHORT_SERVICE_IPV4_TYPE
00295 
00296 } SlNetAppGetServiceListType_e;
00297 
00298 typedef struct {
00299     uint32_t   service_ipv4;
00300     uint16_t   service_port;
00301     uint16_t   Reserved;
00302 } SlNetAppGetShortServiceIpv4List_t;
00303 
00304 typedef struct {
00305     uint32_t   service_ipv4;
00306     uint16_t   service_port;
00307     uint16_t   Reserved;
00308     uint8_t    service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
00309     uint8_t    service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
00310 } SlNetAppGetFullServiceIpv4List_t;
00311 
00312 typedef struct {
00313     uint32_t    service_ipv4;
00314     uint16_t    service_port;
00315     uint16_t    Reserved;
00316     uint8_t     service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
00317     uint8_t     service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
00318     uint8_t     service_text[NETAPP_MAX_SERVICE_TEXT_SIZE];
00319 } SlNetAppGetFullServiceWithTextIpv4List_t;
00320 
00321 typedef struct {
00322     /*The below parameters are used to configure the advertise times and interval
00323     For example:
00324         If:
00325         Period is set to T
00326         Repetitions are set to P
00327         Telescopic factor is K=2
00328         The transmission shall be:
00329         advertise P times
00330         wait T
00331         advertise P times
00332         wait 4 * T
00333         advertise P time
00334         wait 16 * T  ... (till max time reached / configuration changed / query issued)
00335     */
00336     uint32_t    t;              /* Number of ticks for the initial period. Default is 100 ticks for 1 second. */
00337     uint32_t    p;              /* Number of repetitions. Default value is 1                                  */
00338     uint32_t    k;              /* Telescopic factor. Default value is 2.                                     */
00339     uint32_t    RetransInterval;/* Announcing retransmission interval                                         */
00340     uint32_t    Maxinterval;     /* Announcing max period interval                                            */
00341     uint32_t    max_time;       /* Announcing max time                                                        */
00342 } SlNetAppServiceAdvertiseTimingParameters_t;
00343 
00344 /*****************************************************************************/
00345 /* Types declarations                                               */
00346 /*****************************************************************************/
00347 typedef void (*P_SL_DEV_PING_CALLBACK)(SlPingReport_t*);
00348 extern P_SL_DEV_PING_CALLBACK  pPingCallBackFunc;
00349 
00350 /*****************************************************************************************
00351 *   NETAPP structs
00352 ******************************************************************************************/
00353 
00354 
00355 typedef _BasicResponse_t _NetAppStartStopResponse_t;
00356 
00357 typedef struct {
00358     uint32_t  appId;
00359 } _NetAppStartStopCommand_t;
00360 
00361 typedef struct {
00362     uint16_t  Status;
00363     uint16_t  AppId;
00364     uint16_t  ConfigOpt;
00365     uint16_t  ConfigLen;
00366 } _NetAppSetGet_t;
00367 typedef struct {
00368     uint16_t  port_number;
00369 } _NetAppHttpServerGetSet_port_num_t;
00370 
00371 typedef struct {
00372     uint8_t  auth_enable;
00373 } _NetAppHttpServerGetSet_auth_enable_t;
00374 
00375 typedef struct _sl_NetAppHttpServerGetToken_t {
00376     uint8_t   token_name_len;
00377     uint8_t   padd1;
00378     uint16_t  padd2;
00379 } sl_NetAppHttpServerGetToken_t;
00380 
00381 typedef struct _sl_NetAppHttpServerSendToken_t {
00382     uint8_t   token_value_len;
00383     uint8_t   token_name_len;
00384     uint8_t   token_name[MAX_TOKEN_NAME_LEN];
00385     uint16_t  padd;
00386 } sl_NetAppHttpServerSendToken_t;
00387 
00388 typedef struct _sl_NetAppHttpServerPostToken_t {
00389     uint8_t post_action_len;
00390     uint8_t token_name_len;
00391     uint8_t token_value_len;
00392     uint8_t padding;
00393 } sl_NetAppHttpServerPostToken_t;
00394 
00395 
00396 typedef struct {
00397     uint16_t Len;
00398     uint8_t  family;
00399     uint8_t  padding;
00400 } _GetHostByNameCommand_t;
00401 
00402 typedef struct {
00403     uint16_t status;
00404     uint16_t padding;
00405     uint32_t ip0;
00406     uint32_t ip1;
00407     uint32_t ip2;
00408     uint32_t ip3;
00409 } _GetHostByNameIPv6AsyncResponse_t;
00410 
00411 typedef struct {
00412     uint16_t status;
00413     uint8_t  padding1;
00414     uint8_t  padding2;
00415     uint32_t ip0;
00416 } _GetHostByNameIPv4AsyncResponse_t;
00417 
00418 typedef enum {
00419     CTST_BSD_UDP_TX,
00420     CTST_BSD_UDP_RX,
00421     CTST_BSD_TCP_TX,
00422     CTST_BSD_TCP_RX,
00423     CTST_BSD_TCP_SERVER_BI_DIR,
00424     CTST_BSD_TCP_CLIENT_BI_DIR,
00425     CTST_BSD_UDP_BI_DIR,
00426     CTST_BSD_RAW_TX,
00427     CTST_BSD_RAW_RX,
00428     CTST_BSD_RAW_BI_DIR,
00429     CTST_BSD_SECURED_TCP_TX,
00430     CTST_BSD_SECURED_TCP_RX,
00431     CTST_BSD_SECURED_TCP_SERVER_BI_DIR,
00432     CTST_BSD_SECURED_TCP_CLIENT_BI_DIR
00433 } CommTest_e;
00434 
00435 typedef struct _sl_protocol_CtestStartCommand_t {
00436     uint32_t Test;
00437     uint16_t DestPort;
00438     uint16_t SrcPort;
00439     uint32_t DestAddr[4];
00440     uint32_t PayloadSize;
00441     uint32_t timeout;
00442     uint32_t csEnabled;
00443     uint32_t secure;
00444     uint32_t rawProtocol;
00445     uint8_t  reserved1[4];
00446 } _CtestStartCommand_t;
00447 
00448 typedef struct {
00449     uint8_t  test;
00450     uint8_t  socket;
00451     int16_t  status;
00452     uint32_t startTime;
00453     uint32_t endTime;
00454     uint16_t txKbitsSec;
00455     uint16_t rxKbitsSec;
00456     uint32_t outOfOrderPackets;
00457     uint32_t missedPackets;
00458     int16_t  token;
00459 } _CtestAsyncResponse_t;
00460 
00461 typedef struct {
00462     uint32_t pingIntervalTime;
00463     uint16_t PingSize;
00464     uint16_t pingRequestTimeout;
00465     uint32_t totalNumberOfAttempts;
00466     uint32_t flags;
00467     uint32_t ip0;
00468     uint32_t ip1OrPaadding;
00469     uint32_t ip2OrPaadding;
00470     uint32_t ip3OrPaadding;
00471 } _PingStartCommand_t;
00472 
00473 typedef struct {
00474     uint16_t status;
00475     uint16_t rttMin;
00476     uint16_t rttMax;
00477     uint16_t rttAvg;
00478     uint32_t numSuccsessPings;
00479     uint32_t numSendsPings;
00480     uint32_t testTime;
00481 } _PingReportResponse_t;
00482 
00483 
00484 typedef struct {
00485     uint32_t ip;
00486     uint32_t gateway;
00487     uint32_t dns;
00488 } _IpV4AcquiredAsync_t;
00489 
00490 
00491 typedef enum {
00492     ACQUIRED_IPV6_LOCAL = 1,
00493     ACQUIRED_IPV6_GLOBAL
00494 } IpV6AcquiredType_e;
00495 
00496 
00497 typedef struct {
00498     uint32_t type;
00499     uint32_t ip[4];
00500     uint32_t gateway[4];
00501     uint32_t dns[4];
00502 } _IpV6AcquiredAsync_t;
00503 
00504 
00505 typedef union {
00506     _SocketCommand_t     EventMask;
00507     _sendRecvCommand_t   DeviceInit;
00508 } _device_commands_t;
00509 
00510 
00511 class cc3100_netapp
00512 {
00513 
00514 public:
00515 
00516 //#ifndef SL_PLATFORM_MULTI_THREADED
00517 #if (!defined (SL_PLATFORM_MULTI_THREADED)) && (!defined (SL_PLATFORM_EXTERNAL_SPAWN))
00518     cc3100_netapp(cc3100_driver &driver, cc3100_nonos &nonos);
00519 #else
00520     cc3100_netapp(cc3100_driver &driver);
00521 #endif    
00522 
00523     ~cc3100_netapp();
00524 
00525     /*****************************************************************************/
00526     /* Functions prototypes                                                      */
00527     /*****************************************************************************/
00528     int16_t sl_NetAppMDNSRegisterUnregisterService(const char* pServiceName,  
00529                                                    const uint8_t ServiceNameLen, 
00530                                                    const char* pText, 
00531                                                    const uint8_t TextLen, 
00532                                                    const uint16_t Port, 
00533                                                    const uint32_t TTL, 
00534                                                    const uint32_t Options);
00535 
00536     void _sl_HandleAsync_DnsGetHostByAddr(void *pVoidBuf);
00537 
00538     void CopyPingResultsToReport(_PingReportResponse_t *pResults,SlPingReport_t *pReport);
00539     
00540 #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
00541     uint16_t sl_NetAppSendTokenValue(slHttpServerData_t * Token);
00542 #endif
00543 
00544 //    uint16_t sl_NetAppSendTokenValue(slHttpServerData_t * Token);
00545 
00546 
00547     /*****************************************************************************/
00548     /* Function prototypes                                                       */
00549     /*****************************************************************************/
00550 
00551 
00552     /*!
00553         \brief Starts a network application
00554 
00555         Gets and starts network application for the current WLAN mode
00556 
00557         \param[in] AppBitMap      application bitmap, could be one or combination of the following: \n
00558                                   - SL_NET_APP_HTTP_SERVER_ID
00559                                   - SL_NET_APP_DHCP_SERVER_ID
00560                                   - SL_NET_APP_MDNS_ID
00561 
00562         \return                   On error, negative number is returned
00563 
00564         \sa                       Stop one or more the above started applications using sl_NetAppStop
00565         \note                     This command activates the application for the current WLAN mode (AP or STA)
00566         \warning
00567         \par                 Example:
00568         \code
00569         For example: Starting internal HTTP server + DHCP server:
00570         sl_NetAppStart(SL_NET_APP_HTTP_SERVER_ID | SL_NET_APP_DHCP_SERVER_ID)
00571 
00572         \endcode
00573     */
00574 #if _SL_INCLUDE_FUNC(sl_NetAppStart)
00575     int16_t sl_NetAppStart(const uint32_t AppBitMap);
00576 #endif
00577     /*!
00578         \brief Stops a network application
00579 
00580         Gets and stops network application for the current WLAN mode
00581 
00582         \param[in] AppBitMap    application id, could be one of the following: \n
00583                                 - SL_NET_APP_HTTP_SERVER_ID
00584                                 - SL_NET_APP_DHCP_SERVER_ID
00585                                 - SL_NET_APP_MDNS_ID
00586 
00587         \return                 On error, negative number is returned
00588 
00589         \sa
00590         \note                This command disables the application for the current active WLAN mode (AP or STA)
00591         \warning
00592         \par                 Example:
00593         \code
00594 
00595         For example: Stopping internal HTTP server:
00596                              sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID);
00597 
00598         \endcode
00599     */
00600 #if _SL_INCLUDE_FUNC(sl_NetAppStop)
00601     int16_t sl_NetAppStop(const uint32_t AppBitMap);
00602 #endif
00603 
00604     /*!
00605         \brief Get host IP by name
00606 
00607         Obtain the IP Address of machine on network, by machine name.
00608 
00609         \param[in]  hostname        host name
00610         \param[in]  usNameLen       name length
00611         \param[out] out_ip_addr     This parameter is filled in with
00612                                     host IP address. In case that host name is not
00613                                     resolved, out_ip_addr is zero.
00614         \param[in]  family          protocol family
00615 
00616         \return                     On success, 0 is returned.
00617                                     On error, negative is returned
00618                                     SL_POOL_IS_EMPTY may be return in case there are no resources in the system
00619                                     In this case try again later or increase MAX_CONCURRENT_ACTIONS
00620                                     Possible DNS error codes:
00621                                     - SL_NET_APP_DNS_QUERY_NO_RESPONSE
00622                                     - SL_NET_APP_DNS_NO_SERVER
00623                                     - SL_NET_APP_DNS_QUERY_FAILED
00624                                     - SL_NET_APP_DNS_MALFORMED_PACKET
00625                                     - SL_NET_APP_DNS_MISMATCHED_RESPONSE
00626 
00627         \sa
00628         \note   Only one sl_NetAppDnsGetHostByName can be handled at a time.
00629                 Calling this API while the same command is called from another thread, may result
00630                 in one of the two scenarios:
00631                 1. The command will wait (internal) until the previous command finish, and then be executed.
00632                 2. There are not enough resources and POOL_IS_EMPTY error will return.
00633                 In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
00634                 again later to issue the command.
00635         \warning
00636         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 
00637         try to access the DNS and it will return the input address on the 'out_ip_addr' field 
00638         \par  Example:
00639         \code
00640         uint32_t DestinationIP;
00641         sl_NetAppDnsGetHostByName("www.google.com", strlen("www.google.com"), &DestinationIP,SL_AF_INET);
00642 
00643         Addr.sin_family = SL_AF_INET;
00644         Addr.sin_port = sl_Htons(80);
00645         Addr.sin_addr.s_addr = sl_Htonl(DestinationIP);
00646         AddrSize = sizeof(SlSockAddrIn_t);
00647         SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
00648         \endcode
00649     */
00650 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByName)
00651     int16_t sl_NetAppDnsGetHostByName(unsigned char * hostname, const uint16_t usNameLen, uint32_t*  out_ip_addr, const uint8_t family );
00652 #endif
00653 
00654     /*!
00655             \brief Return service attributes like IP address, port and text according to service name
00656             \par
00657             The user sets a service name Full/Part (see example below), and should get:
00658             - IP of service
00659             - The port of service
00660             - The text of service
00661 
00662             Hence it can make a connection to the specific service and use it.
00663             It is similar to get host by name method.
00664             It is done by a single shot query with PTR type on the service name.
00665                       The command that is sent is from constant parameters and variables parameters.
00666 
00667             \param[in]     pService                   Service name can be full or partial. \n
00668                                                       Example for full service name:
00669                                                       1. PC1._ipp._tcp.local
00670                                                       2. PC2_server._ftp._tcp.local \n
00671                                                       .
00672                                                       Example for partial service name:
00673                                                       1. _ipp._tcp.local
00674                                                       2. _ftp._tcp.local
00675 
00676             \param[in]    ServiceLen                  The length of the service name (in_pService).
00677             \param[in]    Family                      IPv4 or IPv6 (SL_AF_INET , SL_AF_INET6).
00678             \param[out]    pAddr                      Contains the IP address of the service.
00679             \param[out]    pPort                      Contains the port of the service.
00680             \param[out]    pTextLen                   Has 2 options. One as Input field and the other one as output:
00681                                                       - Input: \n
00682                                                       Contains the max length of the text that the user wants to get.\n
00683                                                       It means that if the text len of service is bigger that its value than
00684                                                       the text is cut to inout_TextLen value.
00685                                                       - Output: \n
00686                                                        Contain the length of the text that is returned. Can be full text or part of the text (see above).
00687 
00688             \param[out]   pOut_pText     Contains the text of the service full or partial
00689 
00690             \return       On success, zero is returned
00691                           SL_POOL_IS_EMPTY may be return in case there are no resources in the system
00692                           In this case try again later or increase MAX_CONCURRENT_ACTIONS
00693                           In case No service is found error SL_NET_APP_DNS_NO_ANSWER will be returned
00694 
00695             \note         The returns attributes belongs to the first service found.
00696                           There may be other services with the same service name that will response to the query.
00697                           The results of these responses are saved in the peer cache of the Device and should be read by another API.
00698 
00699                           Only one sl_NetAppDnsGetHostByService can be handled at a time.
00700                           Calling this API while the same command is called from another thread, may result
00701                           in one of the two scenarios:
00702                           1. The command will wait (internal) until the previous command finish, and then be executed.
00703                           2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
00704                           In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
00705                           again later to issue the command.
00706 
00707             \warning      Text length can be 120 bytes only
00708     */
00709 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByService)
00710     int32_t sl_NetAppDnsGetHostByService(unsigned char  *pServiceName, /*  string containing all (or only part): name + subtype + service */
00711                                          const uint8_t  ServiceLen,
00712                                          const uint8_t  Family,        /*  4-IPv4 , 16-IPv6  */
00713                                          uint32_t pAddr[],
00714                                          uint32_t *pPort,
00715                                          uint16_t *pTextLen,     /*  in: max len , out: actual len */
00716                                          unsigned char  *pText
00717                                         );
00718 
00719 #endif
00720 
00721     /*!
00722             \brief Get service List
00723             Insert into out pBuffer a list of peer's services that are the NWP.
00724             The list is in a form of service struct. The user should chose the type
00725             of the service struct like:
00726                 - Full service parameters with text.
00727                 - Full service parameters.
00728                 - Short service parameters (port and IP only) especially for tiny hosts.
00729 
00730             The different types of struct are made to give the
00731             Possibility to save memory in the host
00732 
00733 
00734             The user also chose how many max services to get and start point index
00735             NWP peer cache.
00736             For example:
00737                 1.    Get max of 3 full services from index 0.Up to 3 full services
00738                 from index 0 are inserted into pBuffer (services that are in indexes 0,1,2).
00739                 2.    Get max of 4 full services from index 3.Up to 4 full services
00740                 from index 3 are inserted into pBuffer (services that are in indexes 3,4,5,6).
00741                 3.    Get max of 2 int services from index 6.Up to 2 int services
00742                 from index 6 are inserted into pBuffer (services that are in indexes 6,7).
00743 
00744             See below - command parameters.
00745 
00746             \param[in] indexOffset - The start index in the peer cache that from it the first service is returned.
00747             \param[in] MaxServiceCount - The Max services that can be returned if existed or if not exceed the max index
00748                           in the peer cache
00749             \param[in] Flags - an ENUM number that means which service struct to use (means which types of service to fill)
00750                             - use SlNetAppGetFullServiceWithTextIpv4List_t
00751                             - use SlNetAppGetFullServiceIpv4List_t
00752                             - use SlNetAppGetShortServiceIpv4List_t
00753 
00754            \param[out]  Buffer - The Services are inserted into this buffer. In the struct form according to the bit that is set in the Flags
00755                           input parameter.
00756 
00757             \return    ServiceFoundCount - The number of the services that were inserted into the buffer. zero means no service is found
00758                         negative number means an error
00759             \sa           sl_NetAppMDNSRegisterService
00760             \note
00761             \warning
00762                         if the out pBuffer size is bigger than an RX packet(1480), than
00763                         an error is returned because there
00764                         is no place in the RX packet.
00765                         The size is a multiply of MaxServiceCount and size of service struct(that is set
00766                         according to flag value).
00767     */
00768 
00769 #if _SL_INCLUDE_FUNC(sl_NetAppGetServiceList)
00770     int16_t sl_NetAppGetServiceList(const uint8_t   IndexOffest,
00771                                     const uint8_t   MaxServiceCount,
00772                                     const uint8_t   Flags,
00773                                     int8_t   *pBuffer,
00774                                     const uint32_t  RxBufferLength
00775                                    );
00776 
00777 #endif
00778 
00779     /*!
00780             \brief Unregister mDNS service
00781             This function deletes the mDNS service from the mDNS package and the database.
00782 
00783             The mDNS service that is to be unregistered is a service that the application no longer wishes to provide. \n
00784             The service name should be the full service name according to RFC
00785             of the DNS-SD - meaning the value in name field in the SRV answer.
00786 
00787             Examples for service names:
00788             1. PC1._ipp._tcp.local
00789             2. PC2_server._ftp._tcp.local
00790 
00791             \param[in]    pServiceName            Full service name. \n
00792                                                     Example for service name:
00793                                                     1. PC1._ipp._tcp.local
00794                                                     2. PC2_server._ftp._tcp.local
00795             \param[in]    ServiceLen              The length of the service.
00796             \return    On success, zero is returned
00797             \sa          sl_NetAppMDNSRegisterService
00798             \note
00799             \warning
00800             The size of the service length should be smaller than 255.
00801     */
00802 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSUnRegisterService)
00803     int16_t sl_NetAppMDNSUnRegisterService(const char *pServiceName, const uint8_t ServiceNameLen);
00804 #endif
00805 
00806     /*!
00807             \brief Register a new mDNS service
00808             \par
00809             This function registers a new mDNS service to the mDNS package and the DB.
00810 
00811             This registered service is a service offered by the application.
00812             The service name should be full service name according to RFC
00813             of the DNS-SD - meaning the value in name field in the SRV answer.
00814             Example for service name:
00815             1. PC1._ipp._tcp.local
00816             2. PC2_server._ftp._tcp.local
00817 
00818             If the option is_unique is set, mDNS probes the service name to make sure
00819             it is unique before starting to announce the service on the network.
00820             Instance is the instance portion of the service name.
00821 
00822             \param[in]  ServiceLen         The length of the service.
00823             \param[in]  TextLen            The length of the service should be smaller than 64.
00824             \param[in]  port               The port on this target host port.
00825             \param[in]  TTL                The TTL of the service
00826             \param[in]  Options            bitwise parameters: \n
00827                                            - bit 0  - service is unique (means that the service needs to be unique)
00828                                            - bit 31  - for internal use if the service should be added or deleted (set means ADD).
00829                                            - bit 1-30 for future.
00830 
00831             \param[in]    pServiceName              The service name.
00832                                            Example for service name: \n
00833                                                     1. PC1._ipp._tcp.local
00834                                                     2. PC2_server._ftp._tcp.local
00835 
00836             \param[in] pText                     The description of the service.
00837                                                     should be as mentioned in the RFC
00838                                                     (according to type of the service IPP,FTP...)
00839 
00840             \return     On success, zero is returned
00841                         Possible error codes:
00842                         - Maximum advertise services are already configured.
00843                                     Delete another existed service that is registered and then register again the new service
00844                         - Trying to register a service that is already exists
00845                         - Trying to delete service that does not existed
00846                         - Illegal service name according to the RFC
00847                         - Retry request
00848                         - Illegal length of one of the mDNS Set functions
00849                         - mDNS is not operational as the device has no IP.Connect the device to an AP to get an IP address.
00850                         - mDNS parameters error
00851                         - mDNS internal cache error
00852                         - mDNS internal error
00853                         - Adding a service is not allowed as it is already exist (duplicate service)
00854                         - mDNS is not running
00855                         - Host name error. Host name format is not allowed according to RFC 1033,1034,1035, 6763
00856                         - List size buffer is bigger than internally allowed in the NWP (API get service list),
00857                          change the APIs� parameters to decrease the size of the list
00858 
00859 
00860             \sa              sl_NetAppMDNSUnRegisterService
00861 
00862             \warning      1) Temporary -  there is an allocation on stack of internal buffer.
00863                         Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. \n
00864                         It means that the sum of the text length and service name length cannot be bigger than
00865                         NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.\n
00866                         If it is - An error is returned. \n
00867                         2) According to now from certain constraints the variables parameters are set in the
00868                         attribute part (contain constant parameters)
00869     */
00870 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterService)
00871     int16_t sl_NetAppMDNSRegisterService( const char*  pServiceName,
00872                                           const uint8_t         ServiceNameLen,
00873                                           const char*  pText,
00874                                           const uint8_t         TextLen,
00875                                           const uint16_t        Port,
00876                                           const uint32_t        TTL,
00877                                           uint32_t        Options);
00878 #endif
00879 
00880     /*!
00881         \brief send ICMP ECHO_REQUEST to network hosts
00882 
00883         Ping uses the ICMP protocol's mandatory ECHO_REQUEST
00884 
00885         \param[in]   pPingParams     Pointer to the ping request structure: \n
00886                                      - if flags parameter is set to 0, ping will report back once all requested pings are done (as defined by TotalNumberOfAttempts). \n
00887                                      - if flags parameter is set to 1, ping will report back after every ping, for TotalNumberOfAttempts.
00888                                      - 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.
00889                                      For stopping an ongoing ping activity, set parameters IP address to 0
00890 
00891         \param[in]   family          SL_AF_INET or  SL_AF_INET6
00892         \param[out]  pReport         Ping pReport
00893         \param[out]  pCallback       Callback function upon completion.
00894                                      If callback is NULL, the API is blocked until data arrives
00895 
00896 
00897         \return    On success, zero is returned. On error, -1 is returned
00898                    SL_POOL_IS_EMPTY may be return in case there are no resources in the system
00899                    In this case try again later or increase MAX_CONCURRENT_ACTIONS
00900 
00901         \sa       sl_NetAppPingReport
00902         \note      Only one sl_NetAppPingStart can be handled at a time.
00903                   Calling this API while the same command is called from another thread, may result
00904                       in one of the two scenarios:
00905                   1. The command will wait (internal) until the previous command finish, and then be executed.
00906                   2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
00907                   In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
00908                   again later to issue the command.
00909         \warning
00910         \par      Example:
00911         \code
00912 
00913         An example of sending 20 ping requests and reporting results to a callback routine when
00914                   all requests are sent:
00915 
00916                   // callback routine
00917                   void pingRes(SlPingReport_t* pReport)
00918                   {
00919                    // handle ping results
00920                   }
00921 
00922                   // ping activation
00923                   void PingTest()
00924                   {
00925                      SlPingReport_t report;
00926                      SlPingStartCommand_t pingCommand;
00927 
00928                      pingCommand.Ip = SL_IPV4_VAL(10,1,1,200);     // destination IP address is 10.1.1.200
00929                      pingCommand.PingSize = 150;                   // size of ping, in bytes
00930                      pingCommand.PingIntervalTime = 100;           // delay between pings, in milliseconds
00931                      pingCommand.PingRequestTimeout = 1000;        // timeout for every ping in milliseconds
00932                      pingCommand.TotalNumberOfAttempts = 20;       // max number of ping requests. 0 - forever
00933                      pingCommand.Flags = 0;                        // report only when finished
00934 
00935                      sl_NetAppPingStart( &pingCommand, SL_AF_INET, &report, pingRes ) ;
00936                  }
00937 
00938         \endcode
00939     */
00940 #if _SL_INCLUDE_FUNC(sl_NetAppPingStart)
00941     int16_t sl_NetAppPingStart(const SlPingStartCommand_t* pPingParams, const uint8_t family,SlPingReport_t *pReport, const P_SL_DEV_PING_CALLBACK pPingCallback);
00942 #endif
00943 
00944     /*!
00945         \brief     Internal function for setting network application configurations
00946 
00947         \return    On success, zero is returned. On error, -1 is
00948                    returned
00949 
00950         \param[in] AppId          Application id, could be one of the following: \n
00951                                   - SL_NET_APP_HTTP_SERVER_ID
00952                                   - SL_NET_APP_DHCP_SERVER_ID
00953                                   - SL_NET_APP_MDNS_ID
00954                                   - SL_NET_APP_DEVICE_CONFIG_ID
00955 
00956         \param[in] SetOptions     set option, could be one of the following: \n
00957                                   - SL_NET_APP_DHCP_SERVER_ID
00958                                  - NETAPP_SET_DHCP_SRV_BASIC_OPT
00959                                  - SL_NET_APP_HTTP_SERVER_ID
00960                                  - NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER
00961                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK
00962                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_NAME
00963                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD
00964                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_REALM
00965                                  - NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS
00966                                  - SL_NET_APP_MDNS_ID
00967                                  - NETAPP_SET_GET_MDNS_CONT_QUERY_OPT
00968                                  - NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT
00969                                  - NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT
00970                                  - SL_NET_APP_DEVICE_CONFIG_ID
00971                                  - NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN
00972                                  - NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME
00973 
00974 
00975         \param[in] OptionLen       option structure length
00976 
00977         \param[in] pOptionValues   pointer to the option structure
00978         \sa
00979         \note
00980         \warning
00981         \par
00982         \code
00983             Set DHCP Server (AP mode) parameters example:
00984 
00985             SlNetAppDhcpServerBasicOpt_t dhcpParams;
00986             uint8_t outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
00987             dhcpParams.lease_time      = 4096;                         // lease time (in seconds) of the IP Address
00988             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)
00989             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)
00990             sl_NetAppStop(SL_NET_APP_DHCP_SERVER_ID);                  // Stop DHCP server before settings
00991             sl_NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, outLen, (uint8_t* )&dhcpParams);  // set parameters
00992             sl_NetAppStart(SL_NET_APP_DHCP_SERVER_ID);                 // Start DHCP server with new settings
00993         \endcode
00994         \code
00995             Set Device URN name example:
00996 
00997             Device name, maximum length of 33 characters
00998             Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P)
00999             In case no device URN name set, the default name is "mysimplelink"
01000             Allowed characters in device name are: 'a - z' , 'A - Z' , '0-9' and '-'
01001 
01002             uint8_t *my_device = "MY-SIMPLELINK-DEV";
01003             sl_NetAppSet (SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen(my_device), (uint8_t *) my_device);
01004         \endcode
01005 
01006     */
01007 #if _SL_INCLUDE_FUNC(sl_NetAppSet)
01008     int32_t sl_NetAppSet(const uint8_t AppId, const uint8_t Option, const uint8_t OptionLen, const uint8_t *pOptionValue);
01009 #endif
01010 
01011     /*!
01012         \brief     Internal function for getting network applications configurations
01013 
01014         \return    On success, zero is returned. On error, -1 is
01015                    returned
01016 
01017         \param[in] AppId          Application id, could be one of the following: \n
01018                                   - SL_NET_APP_HTTP_SERVER_ID
01019                                   - SL_NET_APP_DHCP_SERVER_ID
01020                                   - SL_NET_APP_MDNS_ID
01021                                   - SL_NET_APP_DEVICE_CONFIG_ID
01022 
01023     \param[in] SetOptions     set option, could be one of the following: \n
01024                                  - SL_NET_APP_DHCP_SERVER_ID
01025                                  - NETAPP_SET_DHCP_SRV_BASIC_OPT
01026                                  - SL_NET_APP_HTTP_SERVER_ID
01027                                  - NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER
01028                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK
01029                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_NAME
01030                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD
01031                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_REALM
01032                                  - NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS
01033                                  - SL_NET_APP_MDNS_ID
01034                                  - NETAPP_SET_GET_MDNS_CONT_QUERY_OPT
01035                                  - NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT
01036                                  - NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT
01037                                  - SL_NET_APP_DEVICE_CONFIG_ID
01038                                  - NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN
01039                                  - NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME
01040 
01041         \param[in] OptionLen     The length of the allocated memory as input, when the
01042                                             function complete, the value of this parameter would be
01043                                             the len that actually read from the device.
01044                                             If the device return length that is longer from the input
01045                                             value, the function will cut the end of the returned structure
01046                                             and will return ESMALLBUF
01047 
01048         \param[out] pValues      pointer to the option structure which will be filled with the response from the device
01049 
01050         \sa
01051         \note
01052         \warning
01053         \par
01054         \code
01055              Get DHCP Server parameters example:
01056 
01057              SlNetAppDhcpServerBasicOpt_t dhcpParams;
01058              uint8_t outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
01059              sl_NetAppGet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, &outLen, (uint8_t* )&dhcpParams);
01060 
01061              printf("DHCP Start IP %d.%d.%d.%d End IP %d.%d.%d.%d Lease time seconds %d\n",
01062                 SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,2),
01063                 SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,0),
01064                 SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,2),
01065                 SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,0),
01066                 dhcpParams.lease_time);
01067         \endcode
01068         \code
01069              Get Device URN name example:
01070              Maximum length of 33 characters of device name.
01071              Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P)
01072              in case no device URN name set, the default name is "mysimplelink"
01073 
01074              uint8_t my_device_name[35];
01075              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);
01076         \endcode
01077     */
01078 #if _SL_INCLUDE_FUNC(sl_NetAppGet)
01079     int32_t sl_NetAppGet(const uint8_t AppId, const uint8_t Option,uint8_t *pOptionLen, uint8_t *pOptionValue);
01080 #endif
01081 
01082 private:
01083 
01084     cc3100_driver           &_driver;
01085 #if (!defined (SL_PLATFORM_MULTI_THREADED)) && (!defined (SL_PLATFORM_EXTERNAL_SPAWN))    
01086 //#ifndef SL_PLATFORM_MULTI_THREADED    
01087     cc3100_nonos            &_nonos;
01088 #endif
01089 
01090 };//class
01091 
01092 /*****************************************************************************/
01093 /* Macro declarations                                                        */
01094 /*****************************************************************************/
01095 const uint8_t FLOW_CONT_MIN = 1;
01096 
01097 
01098 class cc3100_flowcont
01099 {
01100 
01101 public:
01102 
01103 //#ifndef SL_PLATFORM_MULTI_THREADED
01104 #if (!defined (SL_PLATFORM_MULTI_THREADED)) && (!defined (SL_PLATFORM_EXTERNAL_SPAWN))
01105     cc3100_flowcont(cc3100_driver &driver, cc3100_nonos &nonos);
01106 #else
01107     cc3100_flowcont(cc3100_driver &driver);
01108 #endif
01109 
01110     ~cc3100_flowcont();
01111 
01112 #if 0
01113     /*****************************************************************************/
01114     /* Function prototypes                                                       */
01115     /*****************************************************************************/
01116     void _SlDrvFlowContInit(void);
01117     void _SlDrvFlowContDeinit(void);
01118 #endif
01119 
01120 private:
01121 
01122     cc3100_driver &_driver;
01123 //#ifndef SL_PLATFORM_MULTI_THREADED
01124 #if (!defined (SL_PLATFORM_MULTI_THREADED)) && (!defined (SL_PLATFORM_EXTERNAL_SPAWN))    
01125     cc3100_nonos  &_nonos;
01126 #endif    
01127 
01128 };//class
01129 }//namespace mbed_cc3100
01130 
01131 /*!
01132 
01133  Close the Doxygen group.
01134  @}
01135 
01136  */
01137 
01138 #endif    /*  __NETAPP_H__ */
01139 
01140