Own fork of MbedSmartRest
Dependents: MbedSmartRestMain MbedSmartRestMain
Fork of MbedSmartRest by
SmartRest.h
00001 /* 00002 * SmartRest.h 00003 * 00004 * Created on: Nov 1, 2013 00005 * * Authors: Vincent Wochnik <v.wochnik@gmail.com> 00006 * 00007 * Copyright (c) 2013 Cumulocity GmbH 00008 * 00009 * Permission is hereby granted, free of charge, to any person obtaining 00010 * a copy of this software and associated documentation files (the 00011 * "Software"), to deal in the Software without restriction, including 00012 * without limitation the rights to use, copy, modify, merge, publish, 00013 * distribute, sublicense, and/or sell copies of the Software, and to 00014 * permit persons to whom the Software is furnished to do so, subject to 00015 * the following conditions: 00016 * 00017 * The above copyright notice and this permission notice shall be 00018 * included in all copies or substantial portions of the Software. 00019 * 00020 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00021 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00022 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00023 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00024 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00025 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00026 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00027 */ 00028 00029 /** 00030 * @file SmartRest.h 00031 * The main SmartRest facade class. This class is abstract, because the 00032 * actual implementation has to supply a client. 00033 */ 00034 #ifndef SMARTREST_H 00035 #define SMARTREST_H 00036 00037 #include <stddef.h> 00038 #include <stdint.h> 00039 #include "AbstractSmartRest.h" 00040 #include "MbedClient.h" 00041 #include "config.h" 00042 #include "Parser.h" 00043 00044 #define MBEDSMARTREST_TRIES 3 00045 00046 /** 00047 * The main SmartRest client implementation. 00048 */ 00049 class SmartRest : public AbstractSmartRest 00050 { 00051 public: 00052 /** 00053 * Creates a new generic SmartRest object. 00054 * @param client the abstract client to use 00055 * @param identifier the device identifier 00056 */ 00057 SmartRest(uint8_t tries= MBEDSMARTREST_TRIES): 00058 _source(NULL), _client(tries) { 00059 _mogid[0] = 0; 00060 } 00061 00062 #ifdef SMARTREST_TRANSACTIONAL 00063 uint8_t request(const DataGenerator&, const char* = NULL); 00064 uint8_t request(const DataGenerator&, Aggregator&, const char* = NULL); 00065 #endif 00066 virtual uint8_t bootstrap(const DataGenerator&); 00067 virtual uint8_t send(const DataGenerator&, const char* = NULL); 00068 virtual uint8_t sendAndClose(const DataGenerator&, const char* = NULL); 00069 virtual uint8_t stream(const char*, const Record&, const char* = NULL); 00070 virtual uint8_t receive(ParsedRecord&); 00071 virtual void stop(); 00072 const char* getIdentifier() const; 00073 00074 protected: 00075 uint8_t beginRequest(const char*, const char*); 00076 uint8_t awaitResponse(); 00077 bool setMoGid(ParsedRecord&); 00078 00079 private: 00080 AbstractDataSource *_source; 00081 char _mogid[8 * sizeof(long) + 1]; 00082 Parser _parser; 00083 MbedClient _client; 00084 }; 00085 00086 #endif
Generated on Tue Jul 12 2022 17:00:01 by 1.7.2