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

WebSocketHandler

WebSocketHandler

Functions

int WSCore_DataRecv (UINT16 uConnection, struct HttpBlob *pData)
 Parse entire websocket packet and forward only the payload to the user API. The API can handle packets received in parts. It is blocked till entire packet is received.
void WSStatusString (UINT32 WSStatus, struct HttpBlob *status)
 Returns status string according to status code.
int WSCore_DataSend (UINT16 uConnection, struct HttpBlob PayLoad, UINT8 Opcode)
 Sends data to a websocket client . *.
int Payloadlength (struct HttpBlob *pData, UINT8 iter)
 Parses the payload length to the header if it is more than 125 ie (16 bit/64 bit)

Function Documentation

int Payloadlength ( struct HttpBlob *  pData,
UINT8  iter 
)

Parses the payload length to the header if it is more than 125 ie (16 bit/64 bit)

Parameters:
[in]*pDataPointer to the websocket packet
[in]iteriter = 2 for 16 bit length iter = 8 for 64 bit length
Returns:
size of the payload

Definition at line 86 of file WebSockHandler.cpp.

int WSCore_DataRecv ( UINT16  uConnection,
struct HttpBlob *  pData 
)

Parse entire websocket packet and forward only the payload to the user API. The API can handle packets received in parts. It is blocked till entire packet is received.

Parameters:
[in]uConnectionConnection number on HTTP server. The library supports 4.
[in]*pDataPointer to the HttpBlob structure that holds the data.
Returns:
1 - If packet was successfully received, parsed and sent to the user API 0 - Error

If header supports extension, send back error Send error frame : TODO

Definition at line 104 of file WebSockHandler.cpp.

int WSCore_DataSend ( UINT16  uConnection,
struct HttpBlob  PayLoad,
UINT8  Opcode 
)

Sends data to a websocket client . *.

Parameters:
[in]uConnectionConnection number on HTTP server.
[in]PayLoadStructure holding the payload data and the size of the data
[in]OpcodeUser provides data type (text/binary/ping/pong/close).
Returns:
1 - If packet was successfully received, parsed and sent to the user API 0 - Error

Sends data to a websocket client . *.

Parameters:
[in]uConnectionConnection number on HTTP server.
[in]PayLoadStructure holding the payload data and the size of the data
[in]OpcodeUser provides data type (text/binary/ping/pong/close).
Returns:
1 - If packet was successfully received, parsed and sent to the user API 0 - Error

Is this the final packet?

Add opcode to the header

Add this byte to the sendpacket

Reset byte

Mask bit is always set to 0 from server to client

PayloadLen field

Add this byte to the sendpacket

If payload length is more than 125 bytes, we need 16 bits to represent it.

Reset byte

Definition at line 291 of file WebSockHandler.cpp.

void WSStatusString ( UINT32  WS_Status,
struct HttpBlob *  status 
)

Returns status string according to status code.

Parameters:
[in]WSStatusStatus code of the websocket packet
[in]*statusString pointer to the message for the status
Returns:
void

Definition at line 386 of file WebSockHandler.cpp.