TI's CC3100 websocket camera demo with Arducam mini ov5642 and freertos. Should work with other M3's. Work in progress test demo.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HttpSocket.h Source File

HttpSocket.h

00001 //*****************************************************************************
00002 // Copyright (C) 2014 Texas Instruments Incorporated
00003 //
00004 // All rights reserved. Property of Texas Instruments Incorporated.
00005 // Restricted rights to use, duplicate or disclose this code are
00006 // granted through contract.
00007 // The program may not be used without the written permission of
00008 // Texas Instruments Incorporated or against the terms and conditions
00009 // stipulated in the agreement under which this program has been supplied,
00010 // and under no circumstances can it be used with non-TI connectivity device.
00011 //
00012 //*****************************************************************************
00013 
00014 
00015 #ifndef HTTPSOCKET_H_
00016 #define HTTPSOCKET_H_
00017 
00018 /**
00019  * @defgroup HttpSocket
00020  * This module performs all HTTP socket operations
00021  *
00022  * @{
00023  */
00024 
00025 
00026 #include "HttpCore.h"
00027 
00028 // Max number of times server must retry to setup connection
00029 #define SERVER_MAX_SETUP_RETRY_COUNT           3
00030 
00031 #define SL_SSL_SRV_KEY              "/cert/serverkey.der"   /* Server key file ID */
00032 #define SL_SSL_SRV_CERT               "/cert/servercert.der"  /* Server certificate file ID */
00033 
00034 #ifdef  __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038 //****************************************************************************
00039 //
00040 //! Creates a TCP server socket. It calls OpenTCPServerSocket.
00041 //!
00042 //! \param uiPortNum is the port number to bind to
00043 //!
00044 //! This function
00045 //!    1. Creates a TCP socket and binds to it
00046 //!    2. Sets the socket options
00047 //!
00048 //! \return Soceket Descriptor, < 1 if error.
00049 //
00050 //****************************************************************************
00051 int CreateTCPServerSocket(unsigned int uiPortNum);
00052 
00053 //****************************************************************************
00054 //
00055 //! Creates a TCP socket and binds to it
00056 //!
00057 //! \param uiPortNum is the port number to bind to
00058 //!
00059 //! This function
00060 //!    1. Creates a TCP socket and binds to it
00061 //!
00062 //! \return Soceket Descriptor, < 1 if error.
00063 //
00064 //****************************************************************************
00065 int OpenTCPServerSocket(unsigned int uiPortNum);
00066 
00067 //****************************************************************************
00068 //
00069 //! Accepts the client socket. Sets it to blocking with receive timeout.
00070 //!
00071 //! \param iSockDesc is the socket ID obtained from CreateTCPServerSocket
00072 //!
00073 //! This function
00074 //!    1. Accepts the client socket.
00075 //!    2. Sets to blocking mode with RECV timeout
00076 //!
00077 //! \return socket handler is returned after the SockID is put in listening state
00078 //
00079 //****************************************************************************
00080 int CreateTCPClientSocket(int iSockDesc);
00081 
00082 //****************************************************************************
00083 //
00084 //! Closes TCP client socket when the Http connection with that client is closed.
00085 //!
00086 //! \param iSockDesc is the socket ID obtained from CreateTCPServerSocket
00087 //!
00088 //! This function
00089 //!    1. Calls sl_close. Tries 3 times before returning error
00090 //!
00091 //! \return 0 if success
00092 //!         -1 if error
00093 //
00094 //****************************************************************************
00095 int CloseTCPClientSocket(int iSockDesc);
00096 
00097 //****************************************************************************
00098 //
00099 //! Sends over the socket to a specific client. In non blocking socket type, it keeps looping till send is success
00100 //!
00101 //! \param socket is the handle obtained from CreateTCPClientSocket
00102 //!        buffer is the pointer to the data to be sent
00103 //!        len is the length of the data to be sent
00104 //!
00105 //! This function
00106 //!    1. Calls send and keeps trying as long as the return is SL_EAGAIN.
00107 //!
00108 //! \return length successfully sent if it was a success
00109 //!         error code if there was a failure.
00110 //!
00111 //!         It will not return an error if simplelink returns SL_EAGAIN. Instead it will keep trying till it succeeds.
00112 //
00113 //****************************************************************************
00114 int ClientSocketSend(long socket, char * buffer, unsigned int len);
00115 
00116 //****************************************************************************
00117 //
00118 //! Closes TCP server socket.
00119 //!
00120 //! \param iSockDesc is the socket ID obtained from CreateTCPServerSocket
00121 //!
00122 //! This function
00123 //!    1. Calls sl_close. Tries 3 times before returning error
00124 //!
00125 //! \return 0 if success
00126 //!         -1 if error
00127 //
00128 //****************************************************************************
00129 int CloseTCPServerSocket(int iSockDesc);
00130 
00131 
00132 #ifdef  __cplusplus
00133 }
00134 #endif /* __cplusplus */
00135 
00136 #endif /* HTTPSOCKET_H_ */
00137 
00138 //*****************************************************************************
00139 //
00140 // Close the Doxygen group.
00141 //! @}
00142 //
00143 //*****************************************************************************
00144