mqtt specific components for the impact mbed endpoint library
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_mqtt_endpoint_nxp
MBEDEndpoint.h@14:717372430717, 2014-03-31 (annotated)
- Committer:
- ansond
- Date:
- Mon Mar 31 18:47:19 2014 +0000
- Revision:
- 14:717372430717
- Parent:
- 13:66f6cf705184
- Child:
- 15:363a3299e41a
updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 0:a3fc1c6ef150 | 1 | /* Copyright C2013 Doug Anson, MIT License |
ansond | 0:a3fc1c6ef150 | 2 | * |
ansond | 0:a3fc1c6ef150 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
ansond | 0:a3fc1c6ef150 | 4 | * and associated documentation files the "Software", to deal in the Software without restriction, |
ansond | 0:a3fc1c6ef150 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
ansond | 0:a3fc1c6ef150 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
ansond | 0:a3fc1c6ef150 | 7 | * furnished to do so, subject to the following conditions: |
ansond | 0:a3fc1c6ef150 | 8 | * |
ansond | 0:a3fc1c6ef150 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
ansond | 0:a3fc1c6ef150 | 10 | * substantial portions of the Software. |
ansond | 0:a3fc1c6ef150 | 11 | * |
ansond | 0:a3fc1c6ef150 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
ansond | 0:a3fc1c6ef150 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
ansond | 0:a3fc1c6ef150 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
ansond | 0:a3fc1c6ef150 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ansond | 0:a3fc1c6ef150 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
ansond | 0:a3fc1c6ef150 | 17 | */ |
ansond | 0:a3fc1c6ef150 | 18 | |
ansond | 0:a3fc1c6ef150 | 19 | #ifndef _MBED_ENDPOINT_H_ |
ansond | 0:a3fc1c6ef150 | 20 | #define _MBED_ENDPOINT_H_ |
ansond | 0:a3fc1c6ef150 | 21 | |
ansond | 0:a3fc1c6ef150 | 22 | // Ethernet Interface |
ansond | 14:717372430717 | 23 | //DMA #include "EthernetInterface.h" |
ansond | 0:a3fc1c6ef150 | 24 | |
ansond | 11:9ae0fe4517c1 | 25 | // BaseClass support |
ansond | 11:9ae0fe4517c1 | 26 | #include "BaseClass.h" |
ansond | 0:a3fc1c6ef150 | 27 | |
ansond | 0:a3fc1c6ef150 | 28 | // MBED to IOC Resource Map |
ansond | 0:a3fc1c6ef150 | 29 | #include "MBEDToIOCResourceMap.h" |
ansond | 0:a3fc1c6ef150 | 30 | |
ansond | 0:a3fc1c6ef150 | 31 | // Transport support |
ansond | 0:a3fc1c6ef150 | 32 | #include "MQTTTransport.h" |
ansond | 0:a3fc1c6ef150 | 33 | #include "IOCHTTPTransport.h" |
ansond | 0:a3fc1c6ef150 | 34 | |
ansond | 6:2db2c7e75ad9 | 35 | // IOC Endpoint support |
ansond | 6:2db2c7e75ad9 | 36 | #include "IOCEndpoint.h" |
ansond | 6:2db2c7e75ad9 | 37 | |
ansond | 9:28bd23e25409 | 38 | // Personality Support |
ansond | 9:28bd23e25409 | 39 | #include "Personality.h" |
ansond | 0:a3fc1c6ef150 | 40 | |
ansond | 0:a3fc1c6ef150 | 41 | // ResourceFactory Support |
ansond | 0:a3fc1c6ef150 | 42 | #include "ResourceFactory.h" |
ansond | 0:a3fc1c6ef150 | 43 | |
ansond | 0:a3fc1c6ef150 | 44 | // Preferences Support |
ansond | 0:a3fc1c6ef150 | 45 | #include "Preferences.h" |
ansond | 0:a3fc1c6ef150 | 46 | |
ansond | 11:9ae0fe4517c1 | 47 | class MBEDEndpoint : public BaseClass { |
ansond | 0:a3fc1c6ef150 | 48 | private: |
ansond | 14:717372430717 | 49 | void *m_ethernet; // ethernet interface |
ansond | 7:8a4a61202b36 | 50 | Transport *m_transports[NUM_TRANSPORTS]; // our transport |
ansond | 9:28bd23e25409 | 51 | Personality *m_personalities[NUM_PERSONALITY_INSTANCES]; // our personality instances (at least 1) |
ansond | 7:8a4a61202b36 | 52 | char m_endpoint_name[PERSONALITY_NAME_LEN+1]; // our endpoint name (personality[0]) |
ansond | 7:8a4a61202b36 | 53 | MBEDToIOCResourceMap *m_map; // IOC <--> MBED resource mapping |
ansond | 7:8a4a61202b36 | 54 | Preferences *m_preferences; // preference support |
ansond | 7:8a4a61202b36 | 55 | char m_lcd_status[TEMP_BUFFER_LEN+1]; // LCD status buffer |
ansond | 7:8a4a61202b36 | 56 | char m_gw_address[PREFERENCE_VALUE_LEN+1]; // GW address buffer |
ansond | 7:8a4a61202b36 | 57 | int m_instance_id; // instance ID for this endpoint |
ansond | 0:a3fc1c6ef150 | 58 | |
ansond | 0:a3fc1c6ef150 | 59 | public: |
ansond | 14:717372430717 | 60 | MBEDEndpoint(ErrorHandler *error_handler,void *ethernet); |
ansond | 11:9ae0fe4517c1 | 61 | virtual ~MBEDEndpoint(); |
ansond | 0:a3fc1c6ef150 | 62 | ResourceFactory *initResourceFactory(); |
ansond | 0:a3fc1c6ef150 | 63 | void run(); |
ansond | 0:a3fc1c6ef150 | 64 | |
ansond | 7:8a4a61202b36 | 65 | int indexOfPersonality(char *name); |
ansond | 0:a3fc1c6ef150 | 66 | ResourceFactory *getResources(int index); |
ansond | 0:a3fc1c6ef150 | 67 | |
ansond | 7:8a4a61202b36 | 68 | bool loadPersonalities(); |
ansond | 7:8a4a61202b36 | 69 | bool updatePersonalities(); |
ansond | 7:8a4a61202b36 | 70 | bool updatePersonality(int index); |
ansond | 0:a3fc1c6ef150 | 71 | |
ansond | 0:a3fc1c6ef150 | 72 | char *getEndpointName(); |
ansond | 0:a3fc1c6ef150 | 73 | char *getGWAddress(); |
ansond | 0:a3fc1c6ef150 | 74 | Preferences *preferences(); |
ansond | 0:a3fc1c6ef150 | 75 | |
ansond | 0:a3fc1c6ef150 | 76 | char *getLCDStatus(); |
ansond | 0:a3fc1c6ef150 | 77 | |
ansond | 0:a3fc1c6ef150 | 78 | int getInstanceID(); |
ansond | 0:a3fc1c6ef150 | 79 | |
ansond | 0:a3fc1c6ef150 | 80 | MBEDToIOCResourceMap *getMap(); |
ansond | 0:a3fc1c6ef150 | 81 | |
ansond | 0:a3fc1c6ef150 | 82 | protected: |
ansond | 0:a3fc1c6ef150 | 83 | |
ansond | 0:a3fc1c6ef150 | 84 | private: |
ansond | 7:8a4a61202b36 | 85 | bool initializePersonalities(); |
ansond | 7:8a4a61202b36 | 86 | bool closePersonalities(); |
ansond | 5:1ba6e68bf50e | 87 | |
ansond | 5:1ba6e68bf50e | 88 | ResourceFactory *initLightResourceFactory(); |
ansond | 7:8a4a61202b36 | 89 | bool initializeLights(); |
ansond | 7:8a4a61202b36 | 90 | |
ansond | 0:a3fc1c6ef150 | 91 | void initPreferences(); |
ansond | 0:a3fc1c6ef150 | 92 | void initGWAddress(); |
ansond | 0:a3fc1c6ef150 | 93 | void initEndpointName(); |
ansond | 0:a3fc1c6ef150 | 94 | bool initializeTransport(int index,char *key,Transport *transport); |
ansond | 0:a3fc1c6ef150 | 95 | bool initializeTransports(); |
ansond | 7:8a4a61202b36 | 96 | bool loadPersonality(Personality *instance); |
ansond | 7:8a4a61202b36 | 97 | bool updatePersonality(Personality *instance); |
ansond | 0:a3fc1c6ef150 | 98 | bool closeTransport(int index,char *key); |
ansond | 0:a3fc1c6ef150 | 99 | bool closeTransports(); |
ansond | 12:0114a6493457 | 100 | |
ansond | 14:717372430717 | 101 | // bool initializeEthernet(EthernetInterface *ethernet); |
ansond | 14:717372430717 | 102 | // bool closeEthernet(); |
ansond | 0:a3fc1c6ef150 | 103 | }; |
ansond | 0:a3fc1c6ef150 | 104 | |
ansond | 0:a3fc1c6ef150 | 105 | #endif // _MBED_ENDPOINT_H_ |