David Fletcher / Mbed 2 deprecated cc3100_Test_websock_Camera_CM4F

Dependencies:   mbed

Committer:
dflet
Date:
Tue Sep 15 16:45:04 2015 +0000
Revision:
22:f9b5e0b80bf2
Parent:
0:50cedd586816
Removed some debug.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:50cedd586816 1 //*****************************************************************************
dflet 0:50cedd586816 2 // Copyright (C) 2014 Texas Instruments Incorporated
dflet 0:50cedd586816 3 //
dflet 0:50cedd586816 4 // All rights reserved. Property of Texas Instruments Incorporated.
dflet 0:50cedd586816 5 // Restricted rights to use, duplicate or disclose this code are
dflet 0:50cedd586816 6 // granted through contract.
dflet 0:50cedd586816 7 // The program may not be used without the written permission of
dflet 0:50cedd586816 8 // Texas Instruments Incorporated or against the terms and conditions
dflet 0:50cedd586816 9 // stipulated in the agreement under which this program has been supplied,
dflet 0:50cedd586816 10 // and under no circumstances can it be used with non-TI connectivity device.
dflet 0:50cedd586816 11 //
dflet 0:50cedd586816 12 //*****************************************************************************
dflet 0:50cedd586816 13
dflet 0:50cedd586816 14
dflet 0:50cedd586816 15 #ifndef HTTPSOCKET_H_
dflet 0:50cedd586816 16 #define HTTPSOCKET_H_
dflet 0:50cedd586816 17
dflet 0:50cedd586816 18 /**
dflet 0:50cedd586816 19 * @defgroup HttpSocket
dflet 0:50cedd586816 20 * This module performs all HTTP socket operations
dflet 0:50cedd586816 21 *
dflet 0:50cedd586816 22 * @{
dflet 0:50cedd586816 23 */
dflet 0:50cedd586816 24
dflet 0:50cedd586816 25
dflet 0:50cedd586816 26 #include "HttpCore.h"
dflet 0:50cedd586816 27
dflet 0:50cedd586816 28 // Max number of times server must retry to setup connection
dflet 0:50cedd586816 29 #define SERVER_MAX_SETUP_RETRY_COUNT 3
dflet 0:50cedd586816 30
dflet 0:50cedd586816 31 #define SL_SSL_SRV_KEY "/cert/serverkey.der" /* Server key file ID */
dflet 0:50cedd586816 32 #define SL_SSL_SRV_CERT "/cert/servercert.der" /* Server certificate file ID */
dflet 0:50cedd586816 33
dflet 0:50cedd586816 34 #ifdef __cplusplus
dflet 0:50cedd586816 35 extern "C" {
dflet 0:50cedd586816 36 #endif
dflet 0:50cedd586816 37
dflet 0:50cedd586816 38 //****************************************************************************
dflet 0:50cedd586816 39 //
dflet 0:50cedd586816 40 //! Creates a TCP server socket. It calls OpenTCPServerSocket.
dflet 0:50cedd586816 41 //!
dflet 0:50cedd586816 42 //! \param uiPortNum is the port number to bind to
dflet 0:50cedd586816 43 //!
dflet 0:50cedd586816 44 //! This function
dflet 0:50cedd586816 45 //! 1. Creates a TCP socket and binds to it
dflet 0:50cedd586816 46 //! 2. Sets the socket options
dflet 0:50cedd586816 47 //!
dflet 0:50cedd586816 48 //! \return Soceket Descriptor, < 1 if error.
dflet 0:50cedd586816 49 //
dflet 0:50cedd586816 50 //****************************************************************************
dflet 0:50cedd586816 51 int CreateTCPServerSocket(unsigned int uiPortNum);
dflet 0:50cedd586816 52
dflet 0:50cedd586816 53 //****************************************************************************
dflet 0:50cedd586816 54 //
dflet 0:50cedd586816 55 //! Creates a TCP socket and binds to it
dflet 0:50cedd586816 56 //!
dflet 0:50cedd586816 57 //! \param uiPortNum is the port number to bind to
dflet 0:50cedd586816 58 //!
dflet 0:50cedd586816 59 //! This function
dflet 0:50cedd586816 60 //! 1. Creates a TCP socket and binds to it
dflet 0:50cedd586816 61 //!
dflet 0:50cedd586816 62 //! \return Soceket Descriptor, < 1 if error.
dflet 0:50cedd586816 63 //
dflet 0:50cedd586816 64 //****************************************************************************
dflet 0:50cedd586816 65 int OpenTCPServerSocket(unsigned int uiPortNum);
dflet 0:50cedd586816 66
dflet 0:50cedd586816 67 //****************************************************************************
dflet 0:50cedd586816 68 //
dflet 0:50cedd586816 69 //! Accepts the client socket. Sets it to blocking with receive timeout.
dflet 0:50cedd586816 70 //!
dflet 0:50cedd586816 71 //! \param iSockDesc is the socket ID obtained from CreateTCPServerSocket
dflet 0:50cedd586816 72 //!
dflet 0:50cedd586816 73 //! This function
dflet 0:50cedd586816 74 //! 1. Accepts the client socket.
dflet 0:50cedd586816 75 //! 2. Sets to blocking mode with RECV timeout
dflet 0:50cedd586816 76 //!
dflet 0:50cedd586816 77 //! \return socket handler is returned after the SockID is put in listening state
dflet 0:50cedd586816 78 //
dflet 0:50cedd586816 79 //****************************************************************************
dflet 0:50cedd586816 80 int CreateTCPClientSocket(int iSockDesc);
dflet 0:50cedd586816 81
dflet 0:50cedd586816 82 //****************************************************************************
dflet 0:50cedd586816 83 //
dflet 0:50cedd586816 84 //! Closes TCP client socket when the Http connection with that client is closed.
dflet 0:50cedd586816 85 //!
dflet 0:50cedd586816 86 //! \param iSockDesc is the socket ID obtained from CreateTCPServerSocket
dflet 0:50cedd586816 87 //!
dflet 0:50cedd586816 88 //! This function
dflet 0:50cedd586816 89 //! 1. Calls sl_close. Tries 3 times before returning error
dflet 0:50cedd586816 90 //!
dflet 0:50cedd586816 91 //! \return 0 if success
dflet 0:50cedd586816 92 //! -1 if error
dflet 0:50cedd586816 93 //
dflet 0:50cedd586816 94 //****************************************************************************
dflet 0:50cedd586816 95 int CloseTCPClientSocket(int iSockDesc);
dflet 0:50cedd586816 96
dflet 0:50cedd586816 97 //****************************************************************************
dflet 0:50cedd586816 98 //
dflet 0:50cedd586816 99 //! Sends over the socket to a specific client. In non blocking socket type, it keeps looping till send is success
dflet 0:50cedd586816 100 //!
dflet 0:50cedd586816 101 //! \param socket is the handle obtained from CreateTCPClientSocket
dflet 0:50cedd586816 102 //! buffer is the pointer to the data to be sent
dflet 0:50cedd586816 103 //! len is the length of the data to be sent
dflet 0:50cedd586816 104 //!
dflet 0:50cedd586816 105 //! This function
dflet 0:50cedd586816 106 //! 1. Calls send and keeps trying as long as the return is SL_EAGAIN.
dflet 0:50cedd586816 107 //!
dflet 0:50cedd586816 108 //! \return length successfully sent if it was a success
dflet 0:50cedd586816 109 //! error code if there was a failure.
dflet 0:50cedd586816 110 //!
dflet 0:50cedd586816 111 //! It will not return an error if simplelink returns SL_EAGAIN. Instead it will keep trying till it succeeds.
dflet 0:50cedd586816 112 //
dflet 0:50cedd586816 113 //****************************************************************************
dflet 0:50cedd586816 114 int ClientSocketSend(long socket, char * buffer, unsigned int len);
dflet 0:50cedd586816 115
dflet 0:50cedd586816 116 //****************************************************************************
dflet 0:50cedd586816 117 //
dflet 0:50cedd586816 118 //! Closes TCP server socket.
dflet 0:50cedd586816 119 //!
dflet 0:50cedd586816 120 //! \param iSockDesc is the socket ID obtained from CreateTCPServerSocket
dflet 0:50cedd586816 121 //!
dflet 0:50cedd586816 122 //! This function
dflet 0:50cedd586816 123 //! 1. Calls sl_close. Tries 3 times before returning error
dflet 0:50cedd586816 124 //!
dflet 0:50cedd586816 125 //! \return 0 if success
dflet 0:50cedd586816 126 //! -1 if error
dflet 0:50cedd586816 127 //
dflet 0:50cedd586816 128 //****************************************************************************
dflet 0:50cedd586816 129 int CloseTCPServerSocket(int iSockDesc);
dflet 0:50cedd586816 130
dflet 0:50cedd586816 131
dflet 0:50cedd586816 132 #ifdef __cplusplus
dflet 0:50cedd586816 133 }
dflet 0:50cedd586816 134 #endif /* __cplusplus */
dflet 0:50cedd586816 135
dflet 0:50cedd586816 136 #endif /* HTTPSOCKET_H_ */
dflet 0:50cedd586816 137
dflet 0:50cedd586816 138 //*****************************************************************************
dflet 0:50cedd586816 139 //
dflet 0:50cedd586816 140 // Close the Doxygen group.
dflet 0:50cedd586816 141 //! @}
dflet 0:50cedd586816 142 //
dflet 0:50cedd586816 143 //*****************************************************************************
dflet 0:50cedd586816 144