Port of TI's CC3100 Websock camera demo. Using FreeRTOS, mbedTLS, also parts of Arducam for cams ov5642 and 0v2640. Can also use MT9D111. Work in progress. Be warned some parts maybe a bit flacky. This is for Seeed Arch max only, for an M3, see the demo for CM3 using the 0v5642 aducam mini.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers WebSockHandler.h Source File

WebSockHandler.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 /**
00016  * @defgroup WebSocketHandler
00017  *
00018  * @{
00019  */
00020  
00021  #ifndef __WEBSOCKHANDLER__
00022 #define __WEBSOCKHANDLER__
00023 
00024 #define FRAGMENT_LENGTH     HTTP_CORE_MAX_PACKET_SIZE_SEND
00025 
00026   
00027 //*****************************************************************************
00028 //
00029 // If building with a C++ compiler, make all of the definitions in this header
00030 // have a C binding.
00031 //
00032 //*****************************************************************************
00033 #ifdef __cplusplus
00034 extern "C"
00035 {
00036 #endif
00037 
00038 /*!
00039  *  \brief                          Parse entire websocket packet and forward only the payload to the user API.
00040  *                                  The API can handle packets received in parts. It is blocked till entire packet is received.
00041  *
00042  *
00043  *  \param[in] uConnection          Connection number on HTTP server. The library supports 4.
00044  *  \param[in] *pData               Pointer to the HttpBlob structure that holds the data.
00045  *
00046  *  \return                         1 - If packet was successfully received, parsed and sent to the user API
00047  *                                  0 - Error
00048  */
00049 
00050 int WSCore_DataRecv(UINT16 uConnection, struct HttpBlob* pData);
00051 
00052 /*!
00053  *  \brief                          Returns status string according to status code.
00054  *
00055  *  \param[in] WSStatus             Status code of the websocket packet
00056  *  \param[in] *status              String pointer to the message for the status
00057  *
00058  *  \return                         void
00059  */
00060 
00061 void WSStatusString(UINT32 WSStatus, struct HttpBlob* status);
00062 
00063 
00064 
00065 /*!
00066  *  \brief                       Sends data to a websocket client . *                               
00067  *
00068  *  \param[in] uConnection          Connection number on HTTP server. 
00069  *  \param[in] PayLoad          Structure holding the payload data and the size of the data
00070  *  \param[in] Opcode               User provides data type (text/binary/ping/pong/close).
00071  *
00072  *  \return                     1 - If packet was successfully received, parsed and sent to the user API
00073  *                              0 - Error
00074  */
00075 
00076 int WSCore_DataSend(UINT16 uConnection, struct HttpBlob PayLoad, UINT8 Opcode);
00077 
00078 
00079 /*!
00080  *  \brief                          Parses the payload length to the header if it is more than 125 ie (16 bit/64 bit)
00081  *
00082  *  \param[in] *pData               Pointer to the websocket packet
00083  *  \param[in] iter                 iter = 2 for 16 bit length
00084  *                                  iter = 8 for 64 bit length
00085  *
00086  *
00087  *  \return                         size of the payload
00088  */
00089 int Payloadlength(struct HttpBlob * pData, UINT8 iter);
00090 
00091 #define sl_WebSocketHandshakeEvtHdlr        WebSocketHandshakeEventHandler
00092 #define sl_WebSocketRecvEvtHdlr             WebSocketRecvEventHandler
00093 #define sl_WebSocketSend                    WSCore_DataSend
00094 /*
00095  * This is a call back function from the library. User is informed that the connection has been closed.
00096  */
00097 #define sl_WebSocketCloseEvtHdlr            WebSocketCloseSessionHandler
00098 
00099 #ifdef __cplusplus
00100 }
00101 #endif /* __cplusplus */
00102 #endif
00103 
00104