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.
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_mqtt_endpoint_nxp
MBEDEndpoint.h@46:32a7545dde45, 2014-07-01 (annotated)
- Committer:
- ansond
- Date:
- Tue Jul 01 21:26:40 2014 +0000
- Revision:
- 46:32a7545dde45
- Parent:
- 44:2740794b059a
- Child:
- 51:15c81f725ba2
made gw port configurable
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 | 11:9ae0fe4517c1 | 22 | // BaseClass support | 
| ansond | 11:9ae0fe4517c1 | 23 | #include "BaseClass.h" | 
| ansond | 0:a3fc1c6ef150 | 24 | |
| ansond | 0:a3fc1c6ef150 | 25 | // MBED to IOC Resource Map | 
| ansond | 0:a3fc1c6ef150 | 26 | #include "MBEDToIOCResourceMap.h" | 
| ansond | 0:a3fc1c6ef150 | 27 | |
| ansond | 0:a3fc1c6ef150 | 28 | // Transport support | 
| ansond | 0:a3fc1c6ef150 | 29 | #include "MQTTTransport.h" | 
| ansond | 0:a3fc1c6ef150 | 30 | #include "IOCHTTPTransport.h" | 
| ansond | 0:a3fc1c6ef150 | 31 | |
| ansond | 6:2db2c7e75ad9 | 32 | // IOC Endpoint support | 
| ansond | 6:2db2c7e75ad9 | 33 | #include "IOCEndpoint.h" | 
| ansond | 6:2db2c7e75ad9 | 34 | |
| ansond | 9:28bd23e25409 | 35 | // Personality Support | 
| ansond | 9:28bd23e25409 | 36 | #include "Personality.h" | 
| ansond | 0:a3fc1c6ef150 | 37 | |
| ansond | 0:a3fc1c6ef150 | 38 | // ResourceFactory Support | 
| ansond | 0:a3fc1c6ef150 | 39 | #include "ResourceFactory.h" | 
| ansond | 0:a3fc1c6ef150 | 40 | |
| ansond | 0:a3fc1c6ef150 | 41 | // Preferences Support | 
| ansond | 0:a3fc1c6ef150 | 42 | #include "Preferences.h" | 
| ansond | 16:4cc5df8bf10c | 43 | |
| ansond | 18:8ab7aa1dbb41 | 44 | // network selection | 
| ansond | 18:8ab7aa1dbb41 | 45 | #ifdef CELLULAR_NETWORK | 
| ansond | 18:8ab7aa1dbb41 | 46 | // Cellular | 
| ansond | 18:8ab7aa1dbb41 | 47 | #include "MBEDUbloxCellRadio.h" | 
| ansond | 18:8ab7aa1dbb41 | 48 | #include "MBEDUbloxGPS.h" | 
| ansond | 18:8ab7aa1dbb41 | 49 | #else | 
| ansond | 18:8ab7aa1dbb41 | 50 | // Ethernet | 
| ansond | 16:4cc5df8bf10c | 51 | #include "EthernetInterface.h" | 
| ansond | 16:4cc5df8bf10c | 52 | #endif | 
| ansond | 0:a3fc1c6ef150 | 53 | |
| ansond | 11:9ae0fe4517c1 | 54 | class MBEDEndpoint : public BaseClass { | 
| ansond | 0:a3fc1c6ef150 | 55 | private: | 
| ansond | 18:8ab7aa1dbb41 | 56 | #ifdef CELLULAR_NETWORK | 
| ansond | 18:8ab7aa1dbb41 | 57 | MBEDUbloxCellRadio *m_cellular_modem; // cell modem | 
| ansond | 18:8ab7aa1dbb41 | 58 | MBEDUbloxGPS *m_gps; // GPS receiver | 
| ansond | 18:8ab7aa1dbb41 | 59 | #else | 
| ansond | 15:363a3299e41a | 60 | EthernetInterface *m_ethernet; // ethernet interface | 
| ansond | 15:363a3299e41a | 61 | #endif | 
| ansond | 7:8a4a61202b36 | 62 | Transport *m_transports[NUM_TRANSPORTS]; // our transport | 
| ansond | 9:28bd23e25409 | 63 | Personality *m_personalities[NUM_PERSONALITY_INSTANCES]; // our personality instances (at least 1) | 
| ansond | 7:8a4a61202b36 | 64 | char m_endpoint_name[PERSONALITY_NAME_LEN+1]; // our endpoint name (personality[0]) | 
| ansond | 7:8a4a61202b36 | 65 | MBEDToIOCResourceMap *m_map; // IOC <--> MBED resource mapping | 
| ansond | 7:8a4a61202b36 | 66 | Preferences *m_preferences; // preference support | 
| ansond | 7:8a4a61202b36 | 67 | char m_lcd_status[TEMP_BUFFER_LEN+1]; // LCD status buffer | 
| ansond | 7:8a4a61202b36 | 68 | char m_gw_address[PREFERENCE_VALUE_LEN+1]; // GW address buffer | 
| ansond | 46:32a7545dde45 | 69 | char m_gw_port[PREFERENCE_VALUE_LEN+1]; // GW port buffer | 
| ansond | 7:8a4a61202b36 | 70 | int m_instance_id; // instance ID for this endpoint | 
| ansond | 0:a3fc1c6ef150 | 71 | |
| ansond | 0:a3fc1c6ef150 | 72 | public: | 
| ansond | 39:fec38d630383 | 73 | MBEDEndpoint(ErrorHandler *error_handler,void *transport,void *extra); | 
| ansond | 11:9ae0fe4517c1 | 74 | virtual ~MBEDEndpoint(); | 
| ansond | 0:a3fc1c6ef150 | 75 | ResourceFactory *initResourceFactory(); | 
| ansond | 0:a3fc1c6ef150 | 76 | void run(); | 
| ansond | 0:a3fc1c6ef150 | 77 | |
| ansond | 7:8a4a61202b36 | 78 | int indexOfPersonality(char *name); | 
| ansond | 0:a3fc1c6ef150 | 79 | ResourceFactory *getResources(int index); | 
| ansond | 0:a3fc1c6ef150 | 80 | |
| ansond | 7:8a4a61202b36 | 81 | bool loadPersonalities(); | 
| ansond | 7:8a4a61202b36 | 82 | bool updatePersonalities(); | 
| ansond | 7:8a4a61202b36 | 83 | bool updatePersonality(int index); | 
| ansond | 0:a3fc1c6ef150 | 84 | |
| ansond | 0:a3fc1c6ef150 | 85 | char *getEndpointName(); | 
| ansond | 0:a3fc1c6ef150 | 86 | char *getGWAddress(); | 
| ansond | 46:32a7545dde45 | 87 | char *getGWPort(); | 
| ansond | 0:a3fc1c6ef150 | 88 | |
| ansond | 0:a3fc1c6ef150 | 89 | char *getLCDStatus(); | 
| ansond | 0:a3fc1c6ef150 | 90 | |
| ansond | 0:a3fc1c6ef150 | 91 | int getInstanceID(); | 
| ansond | 0:a3fc1c6ef150 | 92 | |
| ansond | 0:a3fc1c6ef150 | 93 | MBEDToIOCResourceMap *getMap(); | 
| ansond | 0:a3fc1c6ef150 | 94 | |
| ansond | 29:ac6390032cec | 95 | Preferences *preferences(); | 
| ansond | 29:ac6390032cec | 96 | |
| ansond | 0:a3fc1c6ef150 | 97 | protected: | 
| ansond | 0:a3fc1c6ef150 | 98 | |
| ansond | 0:a3fc1c6ef150 | 99 | private: | 
| ansond | 7:8a4a61202b36 | 100 | bool initializePersonalities(); | 
| ansond | 7:8a4a61202b36 | 101 | bool closePersonalities(); | 
| ansond | 5:1ba6e68bf50e | 102 | |
| ansond | 5:1ba6e68bf50e | 103 | ResourceFactory *initLightResourceFactory(); | 
| ansond | 7:8a4a61202b36 | 104 | bool initializeLights(); | 
| ansond | 7:8a4a61202b36 | 105 | |
| ansond | 0:a3fc1c6ef150 | 106 | void initPreferences(); | 
| ansond | 0:a3fc1c6ef150 | 107 | void initGWAddress(); | 
| ansond | 0:a3fc1c6ef150 | 108 | void initEndpointName(); | 
| ansond | 0:a3fc1c6ef150 | 109 | bool initializeTransport(int index,char *key,Transport *transport); | 
| ansond | 0:a3fc1c6ef150 | 110 | bool initializeTransports(); | 
| ansond | 7:8a4a61202b36 | 111 | bool loadPersonality(Personality *instance); | 
| ansond | 7:8a4a61202b36 | 112 | bool updatePersonality(Personality *instance); | 
| ansond | 0:a3fc1c6ef150 | 113 | bool closeTransport(int index,char *key); | 
| ansond | 0:a3fc1c6ef150 | 114 | bool closeTransports(); | 
| ansond | 12:0114a6493457 | 115 | |
| ansond | 18:8ab7aa1dbb41 | 116 | #ifdef CELLULAR_NETWORK | 
| ansond | 44:2740794b059a | 117 | bool initializeCellularModem(void *modem); | 
| ansond | 40:72884152baaa | 118 | bool initializeGPSReceiver(void *gps); | 
| ansond | 18:8ab7aa1dbb41 | 119 | bool closeCellularModem(); | 
| ansond | 18:8ab7aa1dbb41 | 120 | bool closeGPSReceiver(); | 
| ansond | 18:8ab7aa1dbb41 | 121 | #else | 
| ansond | 18:8ab7aa1dbb41 | 122 | bool initializeEthernet(EthernetInterface *ethernet); | 
| ansond | 18:8ab7aa1dbb41 | 123 | bool closeEthernet(); | 
| ansond | 15:363a3299e41a | 124 | #endif | 
| ansond | 0:a3fc1c6ef150 | 125 | }; | 
| ansond | 0:a3fc1c6ef150 | 126 | |
| ansond | 0:a3fc1c6ef150 | 127 | #endif // _MBED_ENDPOINT_H_ |