A Port of TI's Webserver for the CC3000

Dependencies:   mbed

Committer:
dflet
Date:
Mon Sep 16 18:37:14 2013 +0000
Revision:
2:e6a185df9e4c
Parent:
0:6ad60d78b315
ADC and Leds now work on board and config.html page.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:6ad60d78b315 1 /*****************************************************************************
dflet 0:6ad60d78b315 2 *
dflet 0:6ad60d78b315 3 * netapp.c - CC3000 Host Driver Implementation.
dflet 0:6ad60d78b315 4 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
dflet 0:6ad60d78b315 5 *
dflet 0:6ad60d78b315 6 * Redistribution and use in source and binary forms, with or without
dflet 0:6ad60d78b315 7 * modification, are permitted provided that the following conditions
dflet 0:6ad60d78b315 8 * are met:
dflet 0:6ad60d78b315 9 *
dflet 0:6ad60d78b315 10 * Redistributions of source code must retain the above copyright
dflet 0:6ad60d78b315 11 * notice, this list of conditions and the following disclaimer.
dflet 0:6ad60d78b315 12 *
dflet 0:6ad60d78b315 13 * Redistributions in binary form must reproduce the above copyright
dflet 0:6ad60d78b315 14 * notice, this list of conditions and the following disclaimer in the
dflet 0:6ad60d78b315 15 * documentation and/or other materials provided with the
dflet 0:6ad60d78b315 16 * distribution.
dflet 0:6ad60d78b315 17 *
dflet 0:6ad60d78b315 18 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 0:6ad60d78b315 19 * its contributors may be used to endorse or promote products derived
dflet 0:6ad60d78b315 20 * from this software without specific prior written permission.
dflet 0:6ad60d78b315 21 *
dflet 0:6ad60d78b315 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 0:6ad60d78b315 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 0:6ad60d78b315 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 0:6ad60d78b315 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 0:6ad60d78b315 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 0:6ad60d78b315 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 0:6ad60d78b315 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 0:6ad60d78b315 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 0:6ad60d78b315 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 0:6ad60d78b315 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 0:6ad60d78b315 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 0:6ad60d78b315 33 *
dflet 0:6ad60d78b315 34 *****************************************************************************/
dflet 0:6ad60d78b315 35 #include <string.h>
dflet 0:6ad60d78b315 36 #include "netapp.h"
dflet 0:6ad60d78b315 37 #include "hci.h"
dflet 0:6ad60d78b315 38 #include "socket.h"
dflet 0:6ad60d78b315 39 #include "evnt_handler.h"
dflet 0:6ad60d78b315 40 #include "nvmem.h"
dflet 0:6ad60d78b315 41
dflet 0:6ad60d78b315 42 #define MIN_TIMER_VAL_SECONDS 20
dflet 0:6ad60d78b315 43 #define MIN_TIMER_SET(t) if ((0 != t) && (t < MIN_TIMER_VAL_SECONDS)) \
dflet 0:6ad60d78b315 44 { \
dflet 0:6ad60d78b315 45 t = MIN_TIMER_VAL_SECONDS; \
dflet 0:6ad60d78b315 46 }
dflet 0:6ad60d78b315 47
dflet 0:6ad60d78b315 48
dflet 0:6ad60d78b315 49 #define NETAPP_DHCP_PARAMS_LEN (20)
dflet 0:6ad60d78b315 50 #define NETAPP_SET_TIMER_PARAMS_LEN (20)
dflet 0:6ad60d78b315 51 #define NETAPP_SET_DEBUG_LEVEL_PARAMS_LEN (4)
dflet 0:6ad60d78b315 52 #define NETAPP_PING_SEND_PARAMS_LEN (16)
dflet 0:6ad60d78b315 53
dflet 0:6ad60d78b315 54
dflet 0:6ad60d78b315 55 //*****************************************************************************
dflet 0:6ad60d78b315 56 //
dflet 0:6ad60d78b315 57 //! netapp_config_mac_adrress
dflet 0:6ad60d78b315 58 //!
dflet 0:6ad60d78b315 59 //! @param mac device mac address, 6 bytes. Saved: yes
dflet 0:6ad60d78b315 60 //!
dflet 0:6ad60d78b315 61 //! @return return on success 0, otherwise error.
dflet 0:6ad60d78b315 62 //!
dflet 0:6ad60d78b315 63 //! @brief Configure device MAC address and store it in NVMEM.
dflet 0:6ad60d78b315 64 //! The value of the MAC address configured through the API will
dflet 0:6ad60d78b315 65 //! be stored in CC3000 non volatile memory, thus preserved
dflet 0:6ad60d78b315 66 //! over resets.
dflet 0:6ad60d78b315 67 //
dflet 0:6ad60d78b315 68 //*****************************************************************************
dflet 0:6ad60d78b315 69 long netapp_config_mac_adrress(unsigned char * mac)
dflet 0:6ad60d78b315 70 {
dflet 0:6ad60d78b315 71 return nvmem_set_mac_address(mac);
dflet 0:6ad60d78b315 72 }
dflet 0:6ad60d78b315 73
dflet 0:6ad60d78b315 74 //*****************************************************************************
dflet 0:6ad60d78b315 75 //
dflet 0:6ad60d78b315 76 //! netapp_dhcp
dflet 0:6ad60d78b315 77 //!
dflet 0:6ad60d78b315 78 //! @param aucIP device mac address, 6 bytes. Saved: yes
dflet 0:6ad60d78b315 79 //! @param aucSubnetMask device mac address, 6 bytes. Saved: yes
dflet 0:6ad60d78b315 80 //! @param aucDefaultGateway device mac address, 6 bytes. Saved: yes
dflet 0:6ad60d78b315 81 //! @param aucDNSServer device mac address, 6 bytes. Saved: yes
dflet 0:6ad60d78b315 82 //!
dflet 0:6ad60d78b315 83 //! @return return on success 0, otherwise error.
dflet 0:6ad60d78b315 84 //!
dflet 0:6ad60d78b315 85 //! @brief netapp_dhcp is used to configure the network interface,
dflet 0:6ad60d78b315 86 //! static or dynamic (DHCP).\n In order to activate DHCP mode,
dflet 0:6ad60d78b315 87 //! aucIP, aucSubnetMask, aucDefaultGateway must be 0.
dflet 0:6ad60d78b315 88 //! The default mode of CC3000 is DHCP mode.
dflet 0:6ad60d78b315 89 //! Note that the configuration is saved in non volatile memory
dflet 0:6ad60d78b315 90 //! and thus preserved over resets.
dflet 0:6ad60d78b315 91 //!
dflet 0:6ad60d78b315 92 //! @note If the mode is altered a reset of CC3000 device is required
dflet 0:6ad60d78b315 93 //! in order to apply changes.\nAlso note that asynchronous event
dflet 0:6ad60d78b315 94 //! of DHCP_EVENT, which is generated when an IP address is
dflet 0:6ad60d78b315 95 //! allocated either by the DHCP server or due to static
dflet 0:6ad60d78b315 96 //! allocation is generated only upon a connection to the
dflet 0:6ad60d78b315 97 //! AP was established.
dflet 0:6ad60d78b315 98 //!
dflet 0:6ad60d78b315 99 //*****************************************************************************
dflet 0:6ad60d78b315 100 long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask,unsigned long *aucDefaultGateway, unsigned long *aucDNSServer)
dflet 0:6ad60d78b315 101 {
dflet 0:6ad60d78b315 102 signed char scRet;
dflet 0:6ad60d78b315 103 unsigned char *ptr;
dflet 0:6ad60d78b315 104 unsigned char *args;
dflet 0:6ad60d78b315 105
dflet 0:6ad60d78b315 106 scRet = EFAIL;
dflet 0:6ad60d78b315 107 ptr = tSLInformation.pucTxCommandBuffer;
dflet 0:6ad60d78b315 108 args = (ptr + HEADERS_SIZE_CMD);
dflet 0:6ad60d78b315 109
dflet 0:6ad60d78b315 110 // Fill in temporary command buffer
dflet 0:6ad60d78b315 111 ARRAY_TO_STREAM(args,aucIP,4);
dflet 0:6ad60d78b315 112 ARRAY_TO_STREAM(args,aucSubnetMask,4);
dflet 0:6ad60d78b315 113 ARRAY_TO_STREAM(args,aucDefaultGateway,4);
dflet 0:6ad60d78b315 114 args = UINT32_TO_STREAM(args, 0);
dflet 0:6ad60d78b315 115 ARRAY_TO_STREAM(args,aucDNSServer,4);
dflet 0:6ad60d78b315 116
dflet 0:6ad60d78b315 117 // Initiate a HCI command
dflet 0:6ad60d78b315 118 hci_command_send(HCI_NETAPP_DHCP, ptr, NETAPP_DHCP_PARAMS_LEN);
dflet 0:6ad60d78b315 119
dflet 0:6ad60d78b315 120 // Wait for command complete event
dflet 0:6ad60d78b315 121 SimpleLinkWaitEvent(HCI_NETAPP_DHCP, &scRet);
dflet 0:6ad60d78b315 122
dflet 0:6ad60d78b315 123 return(scRet);
dflet 0:6ad60d78b315 124 }
dflet 0:6ad60d78b315 125
dflet 0:6ad60d78b315 126
dflet 0:6ad60d78b315 127 //*****************************************************************************
dflet 0:6ad60d78b315 128 //
dflet 0:6ad60d78b315 129 //! netapp_timeout_values
dflet 0:6ad60d78b315 130 //!
dflet 0:6ad60d78b315 131 //! @param aucDHCP DHCP lease time request, also impact
dflet 0:6ad60d78b315 132 //! the DHCP renew timeout. Range: [0-0xffffffff] seconds,
dflet 0:6ad60d78b315 133 //! 0 or 0xffffffff == infinity lease timeout.
dflet 0:6ad60d78b315 134 //! Resolution:10 seconds. Influence: only after
dflet 0:6ad60d78b315 135 //! reconnecting to the AP.
dflet 0:6ad60d78b315 136 //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds.
dflet 0:6ad60d78b315 137 //! The parameter is saved into the CC3000 NVMEM.
dflet 0:6ad60d78b315 138 //! The default value on CC3000 is 14400 seconds.
dflet 0:6ad60d78b315 139 //!
dflet 0:6ad60d78b315 140 //! @param aucARP ARP refresh timeout, if ARP entry is not updated by
dflet 0:6ad60d78b315 141 //! incoming packet, the ARP entry will be deleted by
dflet 0:6ad60d78b315 142 //! the end of the timeout.
dflet 0:6ad60d78b315 143 //! Range: [0-0xffffffff] seconds, 0 == infinity ARP timeout
dflet 0:6ad60d78b315 144 //! Resolution: 10 seconds. Influence: on runtime.
dflet 0:6ad60d78b315 145 //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds
dflet 0:6ad60d78b315 146 //! The parameter is saved into the CC3000 NVMEM.
dflet 0:6ad60d78b315 147 //! The default value on CC3000 is 3600 seconds.
dflet 0:6ad60d78b315 148 //!
dflet 0:6ad60d78b315 149 //! @param aucKeepalive Keepalive event sent by the end of keepalive timeout
dflet 0:6ad60d78b315 150 //! Range: [0-0xffffffff] seconds, 0 == infinity timeout
dflet 0:6ad60d78b315 151 //! Resolution: 10 seconds.
dflet 0:6ad60d78b315 152 //! Influence: on runtime.
dflet 0:6ad60d78b315 153 //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec
dflet 0:6ad60d78b315 154 //! The parameter is saved into the CC3000 NVMEM.
dflet 0:6ad60d78b315 155 //! The default value on CC3000 is 10 seconds.
dflet 0:6ad60d78b315 156 //!
dflet 0:6ad60d78b315 157 //! @param aucInactivity Socket inactivity timeout, socket timeout is
dflet 0:6ad60d78b315 158 //! refreshed by incoming or outgoing packet, by the
dflet 0:6ad60d78b315 159 //! end of the socket timeout the socket will be closed
dflet 0:6ad60d78b315 160 //! Range: [0-0xffffffff] sec, 0 == infinity timeout.
dflet 0:6ad60d78b315 161 //! Resolution: 10 seconds. Influence: on runtime.
dflet 0:6ad60d78b315 162 //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec
dflet 0:6ad60d78b315 163 //! The parameter is saved into the CC3000 NVMEM.
dflet 0:6ad60d78b315 164 //! The default value on CC3000 is 60 seconds.
dflet 0:6ad60d78b315 165 //!
dflet 0:6ad60d78b315 166 //! @return return on success 0, otherwise error.
dflet 0:6ad60d78b315 167 //!
dflet 0:6ad60d78b315 168 //! @brief Set new timeout values. Function set new timeout values for:
dflet 0:6ad60d78b315 169 //! DHCP lease timeout, ARP refresh timeout, keepalive event
dflet 0:6ad60d78b315 170 //! timeout and socket inactivity timeout
dflet 0:6ad60d78b315 171 //!
dflet 0:6ad60d78b315 172 //! @note If a parameter set to non zero value which is less than 20s,
dflet 0:6ad60d78b315 173 //! it will be set automatically to 20s.
dflet 0:6ad60d78b315 174 //!
dflet 0:6ad60d78b315 175 //*****************************************************************************
dflet 0:6ad60d78b315 176
dflet 0:6ad60d78b315 177 #ifndef CC3000_TINY_DRIVER
dflet 0:6ad60d78b315 178 long
dflet 0:6ad60d78b315 179 netapp_timeout_values(unsigned long *aucDHCP, unsigned long *aucARP,unsigned long *aucKeepalive, unsigned long *aucInactivity)
dflet 0:6ad60d78b315 180 {
dflet 0:6ad60d78b315 181 signed char scRet;
dflet 0:6ad60d78b315 182 unsigned char *ptr;
dflet 0:6ad60d78b315 183 unsigned char *args;
dflet 0:6ad60d78b315 184
dflet 0:6ad60d78b315 185 scRet = EFAIL;
dflet 0:6ad60d78b315 186 ptr = tSLInformation.pucTxCommandBuffer;
dflet 0:6ad60d78b315 187 args = (ptr + HEADERS_SIZE_CMD);
dflet 0:6ad60d78b315 188
dflet 0:6ad60d78b315 189 // Set minimal values of timers
dflet 0:6ad60d78b315 190 MIN_TIMER_SET(*aucDHCP)
dflet 0:6ad60d78b315 191 MIN_TIMER_SET(*aucARP)
dflet 0:6ad60d78b315 192 MIN_TIMER_SET(*aucKeepalive)
dflet 0:6ad60d78b315 193 MIN_TIMER_SET(*aucInactivity)
dflet 0:6ad60d78b315 194
dflet 0:6ad60d78b315 195 // Fill in temporary command buffer
dflet 0:6ad60d78b315 196 args = UINT32_TO_STREAM(args, *aucDHCP);
dflet 0:6ad60d78b315 197 args = UINT32_TO_STREAM(args, *aucARP);
dflet 0:6ad60d78b315 198 args = UINT32_TO_STREAM(args, *aucKeepalive);
dflet 0:6ad60d78b315 199 args = UINT32_TO_STREAM(args, *aucInactivity);
dflet 0:6ad60d78b315 200
dflet 0:6ad60d78b315 201 // Initiate a HCI command
dflet 0:6ad60d78b315 202 hci_command_send(HCI_NETAPP_SET_TIMERS, ptr, NETAPP_SET_TIMER_PARAMS_LEN);
dflet 0:6ad60d78b315 203
dflet 0:6ad60d78b315 204 // Wait for command complete event
dflet 0:6ad60d78b315 205 SimpleLinkWaitEvent(HCI_NETAPP_SET_TIMERS, &scRet);
dflet 0:6ad60d78b315 206
dflet 0:6ad60d78b315 207 return(scRet);
dflet 0:6ad60d78b315 208 }
dflet 0:6ad60d78b315 209 #endif
dflet 0:6ad60d78b315 210
dflet 0:6ad60d78b315 211
dflet 0:6ad60d78b315 212 //*****************************************************************************
dflet 0:6ad60d78b315 213 //
dflet 0:6ad60d78b315 214 //! netapp_ping_send
dflet 0:6ad60d78b315 215 //!
dflet 0:6ad60d78b315 216 //! @param ip destination IP address
dflet 0:6ad60d78b315 217 //! @param pingAttempts number of echo requests to send
dflet 0:6ad60d78b315 218 //! @param pingSize send buffer size which may be up to 1400 bytes
dflet 0:6ad60d78b315 219 //! @param pingTimeout Time to wait for a response,in milliseconds.
dflet 0:6ad60d78b315 220 //!
dflet 0:6ad60d78b315 221 //! @return return on success 0, otherwise error.
dflet 0:6ad60d78b315 222 //!
dflet 0:6ad60d78b315 223 //! @brief send ICMP ECHO_REQUEST to network hosts
dflet 0:6ad60d78b315 224 //!
dflet 0:6ad60d78b315 225 //! @note If an operation finished successfully asynchronous ping report
dflet 0:6ad60d78b315 226 //! event will be generated. The report structure is as defined
dflet 0:6ad60d78b315 227 //! by structure netapp_pingreport_args_t.
dflet 0:6ad60d78b315 228 //!
dflet 0:6ad60d78b315 229 //! @warning Calling this function while a previous Ping Requests are in
dflet 0:6ad60d78b315 230 //! progress will stop the previous ping request.
dflet 0:6ad60d78b315 231 //*****************************************************************************
dflet 0:6ad60d78b315 232
dflet 0:6ad60d78b315 233 #ifndef CC3000_TINY_DRIVER
dflet 0:6ad60d78b315 234 long
dflet 0:6ad60d78b315 235 netapp_ping_send(unsigned long *ip, unsigned long ulPingAttempts, unsigned long ulPingSize, unsigned long ulPingTimeout)
dflet 0:6ad60d78b315 236 {
dflet 0:6ad60d78b315 237 signed char scRet;
dflet 0:6ad60d78b315 238 unsigned char *ptr, *args;
dflet 0:6ad60d78b315 239
dflet 0:6ad60d78b315 240 scRet = EFAIL;
dflet 0:6ad60d78b315 241 ptr = tSLInformation.pucTxCommandBuffer;
dflet 0:6ad60d78b315 242 args = (ptr + HEADERS_SIZE_CMD);
dflet 0:6ad60d78b315 243
dflet 0:6ad60d78b315 244 // Fill in temporary command buffer
dflet 0:6ad60d78b315 245 args = UINT32_TO_STREAM(args, *ip);
dflet 0:6ad60d78b315 246 args = UINT32_TO_STREAM(args, ulPingAttempts);
dflet 0:6ad60d78b315 247 args = UINT32_TO_STREAM(args, ulPingSize);
dflet 0:6ad60d78b315 248 args = UINT32_TO_STREAM(args, ulPingTimeout);
dflet 0:6ad60d78b315 249
dflet 0:6ad60d78b315 250 // Initiate a HCI command
dflet 0:6ad60d78b315 251 hci_command_send(HCI_NETAPP_PING_SEND, ptr, NETAPP_PING_SEND_PARAMS_LEN);
dflet 0:6ad60d78b315 252
dflet 0:6ad60d78b315 253 // Wait for command complete event
dflet 0:6ad60d78b315 254 SimpleLinkWaitEvent(HCI_NETAPP_PING_SEND, &scRet);
dflet 0:6ad60d78b315 255
dflet 0:6ad60d78b315 256 return(scRet);
dflet 0:6ad60d78b315 257 }
dflet 0:6ad60d78b315 258 #endif
dflet 0:6ad60d78b315 259
dflet 0:6ad60d78b315 260 //*****************************************************************************
dflet 0:6ad60d78b315 261 //
dflet 0:6ad60d78b315 262 //! netapp_ping_report
dflet 0:6ad60d78b315 263 //!
dflet 0:6ad60d78b315 264 //! @param none
dflet 0:6ad60d78b315 265 //!
dflet 0:6ad60d78b315 266 //! @return none
dflet 0:6ad60d78b315 267 //!
dflet 0:6ad60d78b315 268 //! @brief Request for ping status. This API triggers the CC3000 to send
dflet 0:6ad60d78b315 269 //! asynchronous events: HCI_EVNT_WLAN_ASYNC_PING_REPORT.
dflet 0:6ad60d78b315 270 //! This event will carry the report structure:
dflet 0:6ad60d78b315 271 //! netapp_pingreport_args_t. This structure is filled in with ping
dflet 0:6ad60d78b315 272 //! results up till point of triggering API.
dflet 0:6ad60d78b315 273 //! netapp_pingreport_args_t:\n packets_sent - echo sent,
dflet 0:6ad60d78b315 274 //! packets_received - echo reply, min_round_time - minimum
dflet 0:6ad60d78b315 275 //! round time, max_round_time - max round time,
dflet 0:6ad60d78b315 276 //! avg_round_time - average round time
dflet 0:6ad60d78b315 277 //!
dflet 0:6ad60d78b315 278 //! @note When a ping operation is not active, the returned structure
dflet 0:6ad60d78b315 279 //! fields are 0.
dflet 0:6ad60d78b315 280 //!
dflet 0:6ad60d78b315 281 //*****************************************************************************
dflet 0:6ad60d78b315 282
dflet 0:6ad60d78b315 283
dflet 0:6ad60d78b315 284 #ifndef CC3000_TINY_DRIVER
dflet 0:6ad60d78b315 285 void netapp_ping_report()
dflet 0:6ad60d78b315 286 {
dflet 0:6ad60d78b315 287 unsigned char *ptr;
dflet 0:6ad60d78b315 288 ptr = tSLInformation.pucTxCommandBuffer;
dflet 0:6ad60d78b315 289 signed char scRet;
dflet 0:6ad60d78b315 290
dflet 0:6ad60d78b315 291 scRet = EFAIL;
dflet 0:6ad60d78b315 292
dflet 0:6ad60d78b315 293 // Initiate a HCI command
dflet 0:6ad60d78b315 294 hci_command_send(HCI_NETAPP_PING_REPORT, ptr, 0);
dflet 0:6ad60d78b315 295
dflet 0:6ad60d78b315 296 // Wait for command complete event
dflet 0:6ad60d78b315 297 SimpleLinkWaitEvent(HCI_NETAPP_PING_REPORT, &scRet);
dflet 0:6ad60d78b315 298 }
dflet 0:6ad60d78b315 299 #endif
dflet 0:6ad60d78b315 300
dflet 0:6ad60d78b315 301 //*****************************************************************************
dflet 0:6ad60d78b315 302 //
dflet 0:6ad60d78b315 303 //! netapp_ping_stop
dflet 0:6ad60d78b315 304 //!
dflet 0:6ad60d78b315 305 //! @param none
dflet 0:6ad60d78b315 306 //!
dflet 0:6ad60d78b315 307 //! @return On success, zero is returned. On error, -1 is returned.
dflet 0:6ad60d78b315 308 //!
dflet 0:6ad60d78b315 309 //! @brief Stop any ping request.
dflet 0:6ad60d78b315 310 //!
dflet 0:6ad60d78b315 311 //!
dflet 0:6ad60d78b315 312 //*****************************************************************************
dflet 0:6ad60d78b315 313
dflet 0:6ad60d78b315 314 #ifndef CC3000_TINY_DRIVER
dflet 0:6ad60d78b315 315 long netapp_ping_stop()
dflet 0:6ad60d78b315 316 {
dflet 0:6ad60d78b315 317 signed char scRet;
dflet 0:6ad60d78b315 318 unsigned char *ptr;
dflet 0:6ad60d78b315 319
dflet 0:6ad60d78b315 320 scRet = EFAIL;
dflet 0:6ad60d78b315 321 ptr = tSLInformation.pucTxCommandBuffer;
dflet 0:6ad60d78b315 322
dflet 0:6ad60d78b315 323 // Initiate a HCI command
dflet 0:6ad60d78b315 324 hci_command_send(HCI_NETAPP_PING_STOP, ptr, 0);
dflet 0:6ad60d78b315 325
dflet 0:6ad60d78b315 326 // Wait for command complete event
dflet 0:6ad60d78b315 327 SimpleLinkWaitEvent(HCI_NETAPP_PING_STOP, &scRet);
dflet 0:6ad60d78b315 328
dflet 0:6ad60d78b315 329 return(scRet);
dflet 0:6ad60d78b315 330 }
dflet 0:6ad60d78b315 331 #endif
dflet 0:6ad60d78b315 332
dflet 0:6ad60d78b315 333 //*****************************************************************************
dflet 0:6ad60d78b315 334 //
dflet 0:6ad60d78b315 335 //! netapp_ipconfig
dflet 0:6ad60d78b315 336 //!
dflet 0:6ad60d78b315 337 //! @param[out] ipconfig This argument is a pointer to a
dflet 0:6ad60d78b315 338 //! tNetappIpconfigRetArgs structure. This structure is
dflet 0:6ad60d78b315 339 //! filled in with the network interface configuration.
dflet 0:6ad60d78b315 340 //! tNetappIpconfigRetArgs:\n aucIP - ip address,
dflet 0:6ad60d78b315 341 //! aucSubnetMask - mask, aucDefaultGateway - default
dflet 0:6ad60d78b315 342 //! gateway address, aucDHCPServer - dhcp server address
dflet 0:6ad60d78b315 343 //! aucDNSServer - dns server address, uaMacAddr - mac
dflet 0:6ad60d78b315 344 //! address, uaSSID - connected AP ssid
dflet 0:6ad60d78b315 345 //!
dflet 0:6ad60d78b315 346 //! @return none
dflet 0:6ad60d78b315 347 //!
dflet 0:6ad60d78b315 348 //! @brief Obtain the CC3000 Network interface information.
dflet 0:6ad60d78b315 349 //! Note that the information is available only after the WLAN
dflet 0:6ad60d78b315 350 //! connection was established. Calling this function before
dflet 0:6ad60d78b315 351 //! associated, will cause non-defined values to be returned.
dflet 0:6ad60d78b315 352 //!
dflet 0:6ad60d78b315 353 //! @note The function is useful for figuring out the IP Configuration of
dflet 0:6ad60d78b315 354 //! the device when DHCP is used and for figuring out the SSID of
dflet 0:6ad60d78b315 355 //! the Wireless network the device is associated with.
dflet 0:6ad60d78b315 356 //!
dflet 0:6ad60d78b315 357 //*****************************************************************************
dflet 0:6ad60d78b315 358
dflet 0:6ad60d78b315 359 #ifndef CC3000_TINY_DRIVER
dflet 0:6ad60d78b315 360 void netapp_ipconfig( tNetappIpconfigRetArgs * ipconfig )
dflet 0:6ad60d78b315 361 {
dflet 0:6ad60d78b315 362 unsigned char *ptr;
dflet 0:6ad60d78b315 363
dflet 0:6ad60d78b315 364 ptr = tSLInformation.pucTxCommandBuffer;
dflet 0:6ad60d78b315 365
dflet 0:6ad60d78b315 366 // Initiate a HCI command
dflet 0:6ad60d78b315 367 hci_command_send(HCI_NETAPP_IPCONFIG, ptr, 0);
dflet 0:6ad60d78b315 368
dflet 0:6ad60d78b315 369 // Wait for command complete event
dflet 0:6ad60d78b315 370 SimpleLinkWaitEvent(HCI_NETAPP_IPCONFIG, ipconfig );
dflet 0:6ad60d78b315 371
dflet 0:6ad60d78b315 372 }
dflet 0:6ad60d78b315 373 #else
dflet 0:6ad60d78b315 374 void netapp_ipconfig( tNetappIpconfigRetArgs * ipconfig )
dflet 0:6ad60d78b315 375 {
dflet 0:6ad60d78b315 376
dflet 0:6ad60d78b315 377 }
dflet 0:6ad60d78b315 378 #endif
dflet 0:6ad60d78b315 379
dflet 0:6ad60d78b315 380 //*****************************************************************************
dflet 0:6ad60d78b315 381 //
dflet 0:6ad60d78b315 382 //! netapp_arp_flush
dflet 0:6ad60d78b315 383 //!
dflet 0:6ad60d78b315 384 //! @param none
dflet 0:6ad60d78b315 385 //!
dflet 0:6ad60d78b315 386 //! @return none
dflet 0:6ad60d78b315 387 //!
dflet 0:6ad60d78b315 388 //! @brief Flushes ARP table
dflet 0:6ad60d78b315 389 //!
dflet 0:6ad60d78b315 390 //*****************************************************************************
dflet 0:6ad60d78b315 391
dflet 0:6ad60d78b315 392 #ifndef CC3000_TINY_DRIVER
dflet 0:6ad60d78b315 393 long netapp_arp_flush(void)
dflet 0:6ad60d78b315 394 {
dflet 0:6ad60d78b315 395 signed char scRet;
dflet 0:6ad60d78b315 396 unsigned char *ptr;
dflet 0:6ad60d78b315 397
dflet 0:6ad60d78b315 398 scRet = EFAIL;
dflet 0:6ad60d78b315 399 ptr = tSLInformation.pucTxCommandBuffer;
dflet 0:6ad60d78b315 400
dflet 0:6ad60d78b315 401 // Initiate a HCI command
dflet 0:6ad60d78b315 402 hci_command_send(HCI_NETAPP_ARP_FLUSH, ptr, 0);
dflet 0:6ad60d78b315 403
dflet 0:6ad60d78b315 404 // Wait for command complete event
dflet 0:6ad60d78b315 405 SimpleLinkWaitEvent(HCI_NETAPP_ARP_FLUSH, &scRet);
dflet 0:6ad60d78b315 406
dflet 0:6ad60d78b315 407 return(scRet);
dflet 0:6ad60d78b315 408 }
dflet 0:6ad60d78b315 409 #endif
dflet 0:6ad60d78b315 410
dflet 0:6ad60d78b315 411 //*****************************************************************************
dflet 0:6ad60d78b315 412 //
dflet 0:6ad60d78b315 413 //! netapp_set_debug_level
dflet 0:6ad60d78b315 414 //!
dflet 0:6ad60d78b315 415 //! @param[in] level debug level. Bitwise [0-8],
dflet 0:6ad60d78b315 416 //! 0(disable)or 1(enable).\n Bitwise map: 0 - Critical
dflet 0:6ad60d78b315 417 //! message, 1 information message, 2 - core messages, 3 -
dflet 0:6ad60d78b315 418 //! HCI messages, 4 - Network stack messages, 5 - wlan
dflet 0:6ad60d78b315 419 //! messages, 6 - wlan driver messages, 7 - epprom messages,
dflet 0:6ad60d78b315 420 //! 8 - general messages. Default: 0x13f. Saved: no
dflet 0:6ad60d78b315 421 //!
dflet 0:6ad60d78b315 422 //! @return On success, zero is returned. On error, -1 is returned
dflet 0:6ad60d78b315 423 //!
dflet 0:6ad60d78b315 424 //! @brief Debug messages sent via the UART debug channel, this function
dflet 0:6ad60d78b315 425 //! enable/disable the debug level
dflet 0:6ad60d78b315 426 //!
dflet 0:6ad60d78b315 427 //*****************************************************************************
dflet 0:6ad60d78b315 428
dflet 0:6ad60d78b315 429
dflet 0:6ad60d78b315 430 #ifndef CC3000_TINY_DRIVER
dflet 0:6ad60d78b315 431 long netapp_set_debug_level(unsigned long ulLevel)
dflet 0:6ad60d78b315 432 {
dflet 0:6ad60d78b315 433 signed char scRet;
dflet 0:6ad60d78b315 434 unsigned char *ptr, *args;
dflet 0:6ad60d78b315 435
dflet 0:6ad60d78b315 436 scRet = EFAIL;
dflet 0:6ad60d78b315 437 ptr = tSLInformation.pucTxCommandBuffer;
dflet 0:6ad60d78b315 438 args = (ptr + HEADERS_SIZE_CMD);
dflet 0:6ad60d78b315 439
dflet 0:6ad60d78b315 440 //
dflet 0:6ad60d78b315 441 // Fill in temporary command buffer
dflet 0:6ad60d78b315 442 //
dflet 0:6ad60d78b315 443 args = UINT32_TO_STREAM(args, ulLevel);
dflet 0:6ad60d78b315 444
dflet 0:6ad60d78b315 445
dflet 0:6ad60d78b315 446 //
dflet 0:6ad60d78b315 447 // Initiate a HCI command
dflet 0:6ad60d78b315 448 //
dflet 0:6ad60d78b315 449 hci_command_send(HCI_NETAPP_SET_DEBUG_LEVEL, ptr, NETAPP_SET_DEBUG_LEVEL_PARAMS_LEN);
dflet 0:6ad60d78b315 450
dflet 0:6ad60d78b315 451 //
dflet 0:6ad60d78b315 452 // Wait for command complete event
dflet 0:6ad60d78b315 453 //
dflet 0:6ad60d78b315 454 SimpleLinkWaitEvent(HCI_NETAPP_SET_DEBUG_LEVEL, &scRet);
dflet 0:6ad60d78b315 455
dflet 0:6ad60d78b315 456 return(scRet);
dflet 0:6ad60d78b315 457
dflet 0:6ad60d78b315 458 }
dflet 0:6ad60d78b315 459 #endif
dflet 0:6ad60d78b315 460