HttpServer Library for "mbed-os" which added a snapshot handler.

Dependents:   GR-PEACH-webcam GR-Boards_WebCamera GR-Boards_WebCamera GR-Boards_WebCamera

Fork of HttpServer_snapshot by Renesas

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SnapshotHandler.h Source File

SnapshotHandler.h

00001 /*******************************************************************************
00002 * DISCLAIMER
00003 * This software is supplied by Renesas Electronics Corporation and is only
00004 * intended for use with Renesas products. No other uses are authorized. This
00005 * software is owned by Renesas Electronics Corporation and is protected under
00006 * all applicable laws, including copyright laws.
00007 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
00008 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
00009 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
00010 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
00011 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
00012 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
00013 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
00014 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
00015 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
00016 * Renesas reserves the right, without notice, to make changes to this software
00017 * and to discontinue the availability of this software. By using this software,
00018 * you agree to the additional terms and conditions found by accessing the
00019 * following link:
00020 * http://www.renesas.com/disclaimer*
00021 * Copyright (C) 2015 Renesas Electronics Corporation. All rights reserved.
00022 *******************************************************************************/
00023 
00024 #ifndef SNAPSHOT_HANDLER_H
00025 #define SNAPSHOT_HANDLER_H
00026 
00027 #include "HTTPRequestHandler.h"
00028 
00029 class SnapshotHandler : public HTTPRequestHandler
00030 {
00031 public:
00032     SnapshotHandler(const char* rootPath, const char* path, TCPSocket* pTCPSocket);
00033     virtual ~SnapshotHandler();
00034 
00035     static void attach_req(int(*fptr)(const char ** pp_data)) {
00036         callback_func_req = fptr;
00037     }
00038 
00039     static void attach_req(int(*fptr)(const char* rootPath, const char* path, const char ** pp_data)) {
00040         callback_func_req2 = fptr;
00041     }
00042 
00043     static void attach_req_send_end(void(*fptr)(const char* rootPath, const char* path, const char * p_data)) {
00044         callback_func_send_end = fptr;
00045     }
00046 
00047 //protected:
00048     static inline HTTPRequestHandler* inst(const char* rootPath, const char* path, TCPSocket* pTCPSocket) { return new SnapshotHandler(rootPath, path, pTCPSocket); } //if we ever could do static virtual functions, this would be one
00049 
00050     virtual void doGet();
00051     virtual void doPost();
00052     virtual void doHead();
00053 
00054     virtual void onReadable(); //Data has been read
00055     virtual void onWriteable(); //Data has been written & buf is free
00056     virtual void onClose(); //Connection is closing
00057 
00058 private:
00059     static int (*callback_func_req)(const char ** pp_data);
00060     static int (*callback_func_req2)(const char* rootPath, const char* path, const char ** pp_data);
00061     static void (*callback_func_send_end)(const char* rootPath, const char* path, const char * p_data);
00062     static Semaphore req_sem;
00063     const char * send_data_buf;
00064     int send_size;
00065     int send_index;
00066     bool m_err404;
00067 };
00068 
00069 #endif