Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of HttpServer_snapshot_mbed-os by
Handler/SnapshotHandler.h@16:13f082bef9a9, 2017-09-30 (annotated)
- Committer:
- fxanhkhoa
- Date:
- Sat Sep 30 08:36:29 2017 +0000
- Revision:
- 16:13f082bef9a9
- Parent:
- 15:371fbad587ed
Renesas GR Peach ASEAN Contest
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| dkato | 6:d9e6379eefac | 1 | /******************************************************************************* |
| dkato | 6:d9e6379eefac | 2 | * DISCLAIMER |
| dkato | 6:d9e6379eefac | 3 | * This software is supplied by Renesas Electronics Corporation and is only |
| dkato | 6:d9e6379eefac | 4 | * intended for use with Renesas products. No other uses are authorized. This |
| dkato | 6:d9e6379eefac | 5 | * software is owned by Renesas Electronics Corporation and is protected under |
| dkato | 6:d9e6379eefac | 6 | * all applicable laws, including copyright laws. |
| dkato | 6:d9e6379eefac | 7 | * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING |
| dkato | 6:d9e6379eefac | 8 | * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT |
| dkato | 6:d9e6379eefac | 9 | * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE |
| dkato | 6:d9e6379eefac | 10 | * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. |
| dkato | 6:d9e6379eefac | 11 | * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS |
| dkato | 6:d9e6379eefac | 12 | * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE |
| dkato | 6:d9e6379eefac | 13 | * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR |
| dkato | 6:d9e6379eefac | 14 | * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE |
| dkato | 6:d9e6379eefac | 15 | * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
| dkato | 6:d9e6379eefac | 16 | * Renesas reserves the right, without notice, to make changes to this software |
| dkato | 6:d9e6379eefac | 17 | * and to discontinue the availability of this software. By using this software, |
| dkato | 6:d9e6379eefac | 18 | * you agree to the additional terms and conditions found by accessing the |
| dkato | 6:d9e6379eefac | 19 | * following link: |
| dkato | 6:d9e6379eefac | 20 | * http://www.renesas.com/disclaimer* |
| dkato | 6:d9e6379eefac | 21 | * Copyright (C) 2015 Renesas Electronics Corporation. All rights reserved. |
| dkato | 6:d9e6379eefac | 22 | *******************************************************************************/ |
| dkato | 6:d9e6379eefac | 23 | |
| dkato | 6:d9e6379eefac | 24 | #ifndef SNAPSHOT_HANDLER_H |
| dkato | 6:d9e6379eefac | 25 | #define SNAPSHOT_HANDLER_H |
| dkato | 6:d9e6379eefac | 26 | |
| dkato | 6:d9e6379eefac | 27 | #include "HTTPRequestHandler.h" |
| dkato | 6:d9e6379eefac | 28 | |
| dkato | 6:d9e6379eefac | 29 | class SnapshotHandler : public HTTPRequestHandler |
| dkato | 6:d9e6379eefac | 30 | { |
| dkato | 6:d9e6379eefac | 31 | public: |
| dkato | 11:0700755d64ae | 32 | SnapshotHandler(const char* rootPath, const char* path, TCPSocket* pTCPSocket); |
| dkato | 6:d9e6379eefac | 33 | virtual ~SnapshotHandler(); |
| dkato | 6:d9e6379eefac | 34 | |
| dkato | 6:d9e6379eefac | 35 | static void attach_req(int(*fptr)(const char ** pp_data)) { |
| dkato | 6:d9e6379eefac | 36 | callback_func_req = fptr; |
| dkato | 6:d9e6379eefac | 37 | } |
| dkato | 6:d9e6379eefac | 38 | |
| dkato | 14:d3dc6ad09790 | 39 | static void attach_req(int(*fptr)(const char* rootPath, const char* path, const char ** pp_data)) { |
| dkato | 13:d3571c244759 | 40 | callback_func_req2 = fptr; |
| dkato | 13:d3571c244759 | 41 | } |
| dkato | 13:d3571c244759 | 42 | |
| dkato | 15:371fbad587ed | 43 | static void attach_req_send_end(void(*fptr)(const char* rootPath, const char* path, const char * p_data)) { |
| dkato | 15:371fbad587ed | 44 | callback_func_send_end = fptr; |
| dkato | 15:371fbad587ed | 45 | } |
| dkato | 15:371fbad587ed | 46 | |
| dkato | 6:d9e6379eefac | 47 | //protected: |
| dkato | 11:0700755d64ae | 48 | 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 |
| dkato | 6:d9e6379eefac | 49 | |
| dkato | 6:d9e6379eefac | 50 | virtual void doGet(); |
| dkato | 6:d9e6379eefac | 51 | virtual void doPost(); |
| dkato | 6:d9e6379eefac | 52 | virtual void doHead(); |
| dkato | 6:d9e6379eefac | 53 | |
| dkato | 6:d9e6379eefac | 54 | virtual void onReadable(); //Data has been read |
| dkato | 6:d9e6379eefac | 55 | virtual void onWriteable(); //Data has been written & buf is free |
| dkato | 6:d9e6379eefac | 56 | virtual void onClose(); //Connection is closing |
| dkato | 6:d9e6379eefac | 57 | |
| dkato | 6:d9e6379eefac | 58 | private: |
| dkato | 6:d9e6379eefac | 59 | static int (*callback_func_req)(const char ** pp_data); |
| dkato | 14:d3dc6ad09790 | 60 | static int (*callback_func_req2)(const char* rootPath, const char* path, const char ** pp_data); |
| dkato | 15:371fbad587ed | 61 | static void (*callback_func_send_end)(const char* rootPath, const char* path, const char * p_data); |
| dkato | 6:d9e6379eefac | 62 | static Semaphore req_sem; |
| dkato | 6:d9e6379eefac | 63 | const char * send_data_buf; |
| dkato | 6:d9e6379eefac | 64 | int send_size; |
| dkato | 6:d9e6379eefac | 65 | int send_index; |
| dkato | 6:d9e6379eefac | 66 | bool m_err404; |
| dkato | 6:d9e6379eefac | 67 | }; |
| dkato | 6:d9e6379eefac | 68 | |
| dkato | 6:d9e6379eefac | 69 | #endif |
