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 HttpCore.h Source File

HttpCore.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 #ifndef _HTTP_CORE_H_
00015 #define _HTTP_CORE_H_
00016 
00017 #include "datatypes.h"
00018 
00019 #ifdef __cplusplus
00020 extern "C"
00021 {
00022 #endif /* __cplusplus */
00023 
00024 /**
00025  * @addtogroup HttpCore
00026  *
00027  * @{
00028  */
00029 
00030 /// The TCP port to listen on.
00031 #define HTTP_CORE_SERVER_PORT 80
00032 
00033 /// Maximum number of concurrent client connections. This should be one less than the CC3200 maximum number of sockets
00034 #define HTTP_CORE_MAX_CONNECTIONS 7//cc3100/cc3200 has max sockets of 8 so why was this defined as 10
00035 
00036 /// Maximum size for a received or sent packet. Two buffers of this size must be allocated at all times.
00037 #define HTTP_CORE_MAX_PACKET_SIZE_RECEIVED 1000
00038 
00039 /// Maximum size for a received or sent packet. Two buffers of this size must be allocated at all times.
00040 #define HTTP_CORE_MAX_PACKET_SIZE_SEND 1000
00041 
00042 /// Maximum length of header line which might be buffered, per connection, if a line is broken between packets
00043 #define HTTP_CORE_MAX_HEADER_LINE_LENGTH 320
00044 
00045 /**
00046  * Initialize and start the HTTP server.
00047  * The Wifi interface of the CC3200 chip should be initialized by now, and connected to the network
00048  */
00049 void HttpServerInitAndRun(void * param);
00050 void HttpResponse_AddCharToResponseHeaders(char ch);
00051 void HttpResponse_AddStringToResponseHeaders(char * str, UINT16 len);
00052 int WS_SendPacket(UINT16 uConnection);
00053 void HttpCore_CloseConnection(UINT16 uConnection);
00054 
00055 int HttpResponse_CannedError(UINT16 uConnection, UINT16 uHttpStatus);
00056 int HttpResponse_CannedRedirect(UINT16 uConnection, struct HttpBlob location, UINT16 bPermanent);
00057 int HttpResponse_Content(UINT16 uConnection, struct HttpBlob content);
00058 void HttpResponse_GetPacketSendBuffer(struct HttpBlob* pPacketSendBuffer);
00059 int HttpResponse_Headers(UINT16 uConnection, UINT16 uHttpStatus, UINT16 uFlags, UINT32 uContentLength, struct HttpBlob contentType, struct HttpBlob location);
00060 static void HttpStatusString(UINT16 uHttpStatus, struct HttpBlob* status);
00061 static void HttpResponse_AddHeaderLineNumValue(char * headerName, UINT16 uHeaderNameLen, UINT32 headerValue);
00062 static void HttpResponse_AddHeaderLine(char * headerName, UINT16 headerNameLen, char * headerValue, UINT16 headerValueLen);
00063 static void HttpResponse_AddNumberToResponseHeaders(UINT32 num);
00064 static int HttpCore_SendPacket(UINT16 uConnection, struct HttpBlob buffer);
00065 static int HttpCore_GetNextLine(UINT16 uConnection, struct HttpBlob* pCurrentLocation, struct HttpBlob* pLine);
00066 static void HttpCore_ResetConnection(UINT16 uConnection);
00067 void HttpCloseServer(void);
00068 
00069 // Forward declarations for static functions
00070 static void HttpCore_InitWebServer(void);
00071 static int HttpCore_HandleRequestPacket(UINT16 uConnection, struct HttpBlob packet);
00072 static int HttpCore_HandleMethodLine(UINT16 uConnection, struct HttpBlob line);
00073 static int HttpCore_HandleHeaderLine(UINT16 uConnection, struct HttpBlob line);
00074 static int WSCore_HandshakeRequest(UINT16 uConnection, struct HttpBlob line);
00075 static int WSCore_HandshakeResponse (UINT16 uConnection, struct HttpBlob line);
00076 static int WS_HandshakeHash(char *InKey, char *OutKey, char *EncOutKey);
00077 static int HttpCore_HandleRequestData(UINT16 uConnection, struct HttpBlob* pData);
00078 static void HttpCore_ProcessNotFound(UINT16 uConnection);
00079 static void RunHttpServer(void);
00080 
00081 #define sl_HttpServerCb             SimpleLinkWebSocketEventHandler /* Does not appear to be implemented at present */
00082 
00083 
00084 /// @}
00085 //*****************************************************************************
00086 //
00087 // Mark the end of the C bindings section for C++ compilers.
00088 //
00089 //*****************************************************************************
00090 #ifdef __cplusplus
00091 }
00092 #endif /* __cplusplus */
00093 #endif //_HTTP_CORE_H_
00094