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 * evnt_handler.h - 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 #ifndef __EVENT_HANDLER_H__
dflet 0:6ad60d78b315 36 #define __EVENT_HANDLER_H__
dflet 0:6ad60d78b315 37 #include "hci.h"
dflet 0:6ad60d78b315 38 #include "socket.h"
dflet 0:6ad60d78b315 39
dflet 0:6ad60d78b315 40 //*****************************************************************************
dflet 0:6ad60d78b315 41 //
dflet 0:6ad60d78b315 42 // If building with a C++ compiler, make all of the definitions in this header
dflet 0:6ad60d78b315 43 // have a C binding.
dflet 0:6ad60d78b315 44 //
dflet 0:6ad60d78b315 45 //*****************************************************************************
dflet 0:6ad60d78b315 46 #ifdef __cplusplus
dflet 0:6ad60d78b315 47 extern "C" {
dflet 0:6ad60d78b315 48 #endif
dflet 0:6ad60d78b315 49
dflet 0:6ad60d78b315 50 //*****************************************************************************
dflet 0:6ad60d78b315 51 //
dflet 0:6ad60d78b315 52 // Prototypes for the APIs.
dflet 0:6ad60d78b315 53 //
dflet 0:6ad60d78b315 54 //*****************************************************************************
dflet 0:6ad60d78b315 55
dflet 0:6ad60d78b315 56 //*****************************************************************************
dflet 0:6ad60d78b315 57 //
dflet 0:6ad60d78b315 58 //! hci_event_handler
dflet 0:6ad60d78b315 59 //!
dflet 0:6ad60d78b315 60 //! @param pRetParams incoming data buffer
dflet 0:6ad60d78b315 61 //! @param from from information (in case of data received)
dflet 0:6ad60d78b315 62 //! @param fromlen from information length (in case of data received)
dflet 0:6ad60d78b315 63 //!
dflet 0:6ad60d78b315 64 //! @return none
dflet 0:6ad60d78b315 65 //!
dflet 0:6ad60d78b315 66 //! @brief Parse the incoming events packets and issues corresponding
dflet 0:6ad60d78b315 67 //! event handler from global array of handlers pointers
dflet 0:6ad60d78b315 68 //
dflet 0:6ad60d78b315 69 //*****************************************************************************
dflet 0:6ad60d78b315 70 extern unsigned char *hci_event_handler(void *pRetParams, unsigned char *from, unsigned char *fromlen);
dflet 0:6ad60d78b315 71
dflet 0:6ad60d78b315 72 //*****************************************************************************
dflet 0:6ad60d78b315 73 //
dflet 0:6ad60d78b315 74 //! hci_unsol_event_handler
dflet 0:6ad60d78b315 75 //!
dflet 0:6ad60d78b315 76 //! @param event_hdr event header
dflet 0:6ad60d78b315 77 //!
dflet 0:6ad60d78b315 78 //! @return 1 if event supported and handled
dflet 0:6ad60d78b315 79 //! 0 if event is not supported
dflet 0:6ad60d78b315 80 //!
dflet 0:6ad60d78b315 81 //! @brief Handle unsolicited events
dflet 0:6ad60d78b315 82 //
dflet 0:6ad60d78b315 83 //*****************************************************************************
dflet 0:6ad60d78b315 84 extern long hci_unsol_event_handler(char *event_hdr);
dflet 0:6ad60d78b315 85
dflet 0:6ad60d78b315 86 //*****************************************************************************
dflet 0:6ad60d78b315 87 //
dflet 0:6ad60d78b315 88 //! hci_unsolicited_event_handler
dflet 0:6ad60d78b315 89 //!
dflet 0:6ad60d78b315 90 //! @param None
dflet 0:6ad60d78b315 91 //!
dflet 0:6ad60d78b315 92 //! @return ESUCCESS if successful, EFAIL if an error occurred
dflet 0:6ad60d78b315 93 //!
dflet 0:6ad60d78b315 94 //! @brief Parse the incoming unsolicited event packets and issues
dflet 0:6ad60d78b315 95 //! corresponding event handler.
dflet 0:6ad60d78b315 96 //
dflet 0:6ad60d78b315 97 //*****************************************************************************
dflet 0:6ad60d78b315 98 extern long hci_unsolicited_event_handler(void);
dflet 0:6ad60d78b315 99
dflet 0:6ad60d78b315 100 #define M_BSD_RESP_PARAMS_OFFSET(hci_event_hdr)((char *)(hci_event_hdr) + HCI_EVENT_HEADER_SIZE)
dflet 0:6ad60d78b315 101
dflet 0:6ad60d78b315 102 #define SOCKET_STATUS_ACTIVE 0
dflet 0:6ad60d78b315 103 #define SOCKET_STATUS_INACTIVE 1
dflet 0:6ad60d78b315 104 /* Init socket_active_status = 'all ones': init all sockets with SOCKET_STATUS_INACTIVE.
dflet 0:6ad60d78b315 105 Will be changed by 'set_socket_active_status' upon 'connect' and 'accept' calls */
dflet 0:6ad60d78b315 106 #define SOCKET_STATUS_INIT_VAL 0xFFFF
dflet 0:6ad60d78b315 107 #define M_IS_VALID_SD(sd) ((0 <= (sd)) && ((sd) <= 7))
dflet 0:6ad60d78b315 108 #define M_IS_VALID_STATUS(status) (((status) == SOCKET_STATUS_ACTIVE)||((status) == SOCKET_STATUS_INACTIVE))
dflet 0:6ad60d78b315 109
dflet 0:6ad60d78b315 110 extern unsigned long socket_active_status;
dflet 0:6ad60d78b315 111
dflet 0:6ad60d78b315 112 extern void set_socket_active_status(long Sd, long Status);
dflet 0:6ad60d78b315 113 extern long get_socket_active_status(long Sd);
dflet 0:6ad60d78b315 114
dflet 0:6ad60d78b315 115 typedef struct _bsd_accept_return_t
dflet 0:6ad60d78b315 116 {
dflet 0:6ad60d78b315 117 long iSocketDescriptor;
dflet 0:6ad60d78b315 118 long iStatus;
dflet 0:6ad60d78b315 119 sockaddr tSocketAddress;
dflet 0:6ad60d78b315 120
dflet 0:6ad60d78b315 121 } tBsdReturnParams;
dflet 0:6ad60d78b315 122
dflet 0:6ad60d78b315 123
dflet 0:6ad60d78b315 124 typedef struct _bsd_read_return_t
dflet 0:6ad60d78b315 125 {
dflet 0:6ad60d78b315 126 long iSocketDescriptor;
dflet 0:6ad60d78b315 127 long iNumberOfBytes;
dflet 0:6ad60d78b315 128 unsigned long uiFlags;
dflet 0:6ad60d78b315 129 } tBsdReadReturnParams;
dflet 0:6ad60d78b315 130
dflet 0:6ad60d78b315 131 #define BSD_RECV_FROM_FROMLEN_OFFSET (4)
dflet 0:6ad60d78b315 132 #define BSD_RECV_FROM_FROM_OFFSET (16)
dflet 0:6ad60d78b315 133
dflet 0:6ad60d78b315 134
dflet 0:6ad60d78b315 135 typedef struct _bsd_select_return_t
dflet 0:6ad60d78b315 136 {
dflet 0:6ad60d78b315 137 long iStatus;
dflet 0:6ad60d78b315 138 unsigned long uiRdfd;
dflet 0:6ad60d78b315 139 unsigned long uiWrfd;
dflet 0:6ad60d78b315 140 unsigned long uiExfd;
dflet 0:6ad60d78b315 141 } tBsdSelectRecvParams;
dflet 0:6ad60d78b315 142
dflet 0:6ad60d78b315 143
dflet 0:6ad60d78b315 144 typedef struct _bsd_getsockopt_return_t
dflet 0:6ad60d78b315 145 {
dflet 0:6ad60d78b315 146 unsigned char ucOptValue[4];
dflet 0:6ad60d78b315 147 char iStatus;
dflet 0:6ad60d78b315 148 } tBsdGetSockOptReturnParams;
dflet 0:6ad60d78b315 149
dflet 0:6ad60d78b315 150 typedef struct _bsd_gethostbyname_return_t
dflet 0:6ad60d78b315 151 {
dflet 0:6ad60d78b315 152 long retVal;
dflet 0:6ad60d78b315 153 long outputAddress;
dflet 0:6ad60d78b315 154 } tBsdGethostbynameParams;
dflet 0:6ad60d78b315 155
dflet 0:6ad60d78b315 156 //*****************************************************************************
dflet 0:6ad60d78b315 157 //
dflet 0:6ad60d78b315 158 // Mark the end of the C bindings section for C++ compilers.
dflet 0:6ad60d78b315 159 //
dflet 0:6ad60d78b315 160 //*****************************************************************************
dflet 0:6ad60d78b315 161 #ifdef __cplusplus
dflet 0:6ad60d78b315 162 }
dflet 0:6ad60d78b315 163 #endif // __cplusplus
dflet 0:6ad60d78b315 164
dflet 0:6ad60d78b315 165 #endif // __EVENT_HANDLER_H__
dflet 0:6ad60d78b315 166
dflet 0:6ad60d78b315 167