nsp specific components for the NSP version of the impact endpoint
Dependents: mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet mbed_nsp_endpoint_nxp
MBEDEndpoint.h@0:e1c4378df3fe, 2014-03-26 (annotated)
- Committer:
- ansond
- Date:
- Wed Mar 26 19:51:29 2014 +0000
- Revision:
- 0:e1c4378df3fe
- Child:
- 4:7f7fe167d9c0
updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 0:e1c4378df3fe | 1 | /* Copyright C2013 Doug Anson, MIT License |
ansond | 0:e1c4378df3fe | 2 | * |
ansond | 0:e1c4378df3fe | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
ansond | 0:e1c4378df3fe | 4 | * and associated documentation files the "Software", to deal in the Software without restriction, |
ansond | 0:e1c4378df3fe | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
ansond | 0:e1c4378df3fe | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
ansond | 0:e1c4378df3fe | 7 | * furnished to do so, subject to the following conditions: |
ansond | 0:e1c4378df3fe | 8 | * |
ansond | 0:e1c4378df3fe | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
ansond | 0:e1c4378df3fe | 10 | * substantial portions of the Software. |
ansond | 0:e1c4378df3fe | 11 | * |
ansond | 0:e1c4378df3fe | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
ansond | 0:e1c4378df3fe | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
ansond | 0:e1c4378df3fe | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
ansond | 0:e1c4378df3fe | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ansond | 0:e1c4378df3fe | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
ansond | 0:e1c4378df3fe | 17 | */ |
ansond | 0:e1c4378df3fe | 18 | |
ansond | 0:e1c4378df3fe | 19 | #ifndef _MBED_ENDPOINT_H_ |
ansond | 0:e1c4378df3fe | 20 | #define _MBED_ENDPOINT_H_ |
ansond | 0:e1c4378df3fe | 21 | |
ansond | 0:e1c4378df3fe | 22 | // MBED Ethernet Interface |
ansond | 0:e1c4378df3fe | 23 | #include "EthernetInterface.h" |
ansond | 0:e1c4378df3fe | 24 | |
ansond | 0:e1c4378df3fe | 25 | // ErrorHandler support |
ansond | 0:e1c4378df3fe | 26 | #include "ErrorHandler.h" |
ansond | 0:e1c4378df3fe | 27 | |
ansond | 0:e1c4378df3fe | 28 | // NSP Transport support |
ansond | 0:e1c4378df3fe | 29 | #include "NSPTransport.h" |
ansond | 0:e1c4378df3fe | 30 | |
ansond | 0:e1c4378df3fe | 31 | // HTTP Transport support |
ansond | 0:e1c4378df3fe | 32 | #include "HTTPTransport.h" |
ansond | 0:e1c4378df3fe | 33 | |
ansond | 0:e1c4378df3fe | 34 | // MBED Light Support |
ansond | 0:e1c4378df3fe | 35 | #include "MBEDLight.h" |
ansond | 0:e1c4378df3fe | 36 | |
ansond | 0:e1c4378df3fe | 37 | // NSP ResourceFactory Support |
ansond | 0:e1c4378df3fe | 38 | #include "NSPResourceFactory.h" |
ansond | 0:e1c4378df3fe | 39 | |
ansond | 0:e1c4378df3fe | 40 | // Preferences Support |
ansond | 0:e1c4378df3fe | 41 | #include "Preferences.h" |
ansond | 0:e1c4378df3fe | 42 | |
ansond | 0:e1c4378df3fe | 43 | class MBEDEndpoint { |
ansond | 0:e1c4378df3fe | 44 | private: |
ansond | 0:e1c4378df3fe | 45 | EthernetInterface *m_ethernet; // ethernet interface |
ansond | 0:e1c4378df3fe | 46 | ErrorHandler *m_error_handler; // our error handler |
ansond | 0:e1c4378df3fe | 47 | Transport *m_transports[NUM_TRANSPORTS]; // our transport |
ansond | 0:e1c4378df3fe | 48 | Light *m_lights[NUM_LIGHTS]; // our lights (at least 1) |
ansond | 0:e1c4378df3fe | 49 | char m_endpoint_name[LIGHT_NAME_LEN+1]; // our endpoint name (light[0]) |
ansond | 0:e1c4378df3fe | 50 | Preferences *m_preferences; // preference support |
ansond | 0:e1c4378df3fe | 51 | char m_lcd_status[TEMP_BUFFER_LEN+1]; // LCD status buffer |
ansond | 0:e1c4378df3fe | 52 | char m_nsp_address[PREFERENCE_VALUE_LEN+1]; // NSP address buffer |
ansond | 0:e1c4378df3fe | 53 | int m_instance_id; // Instance ID for this endpoint |
ansond | 0:e1c4378df3fe | 54 | |
ansond | 0:e1c4378df3fe | 55 | public: |
ansond | 0:e1c4378df3fe | 56 | MBEDEndpoint(ErrorHandler *error_handler,EthernetInterface *ethernet); |
ansond | 0:e1c4378df3fe | 57 | ~MBEDEndpoint(); |
ansond | 0:e1c4378df3fe | 58 | ResourceFactory *initResourceFactory(); |
ansond | 0:e1c4378df3fe | 59 | void run(); |
ansond | 0:e1c4378df3fe | 60 | |
ansond | 0:e1c4378df3fe | 61 | char *getEndpointName(); |
ansond | 0:e1c4378df3fe | 62 | char *getNSPAddress(); |
ansond | 0:e1c4378df3fe | 63 | Preferences *preferences(); |
ansond | 0:e1c4378df3fe | 64 | |
ansond | 0:e1c4378df3fe | 65 | char *getLCDStatus(); |
ansond | 0:e1c4378df3fe | 66 | |
ansond | 0:e1c4378df3fe | 67 | int getInstanceID(); |
ansond | 0:e1c4378df3fe | 68 | |
ansond | 0:e1c4378df3fe | 69 | void sendObservations(); |
ansond | 0:e1c4378df3fe | 70 | |
ansond | 0:e1c4378df3fe | 71 | private: |
ansond | 0:e1c4378df3fe | 72 | void initPreferences(); |
ansond | 0:e1c4378df3fe | 73 | void initNSPAddress(); |
ansond | 0:e1c4378df3fe | 74 | void initEndpointName(); |
ansond | 0:e1c4378df3fe | 75 | bool initializeLights(); |
ansond | 0:e1c4378df3fe | 76 | bool initializeTransport(int index,char *key,Transport *transport); |
ansond | 0:e1c4378df3fe | 77 | bool initializeTransports(); |
ansond | 0:e1c4378df3fe | 78 | bool initializeEthernet(EthernetInterface *ethernet); |
ansond | 0:e1c4378df3fe | 79 | bool closeLights(); |
ansond | 0:e1c4378df3fe | 80 | bool closeTransport(int index,char *key); |
ansond | 0:e1c4378df3fe | 81 | bool closeTransports(); |
ansond | 0:e1c4378df3fe | 82 | bool closeEthernet(); |
ansond | 0:e1c4378df3fe | 83 | ErrorHandler *logger(); |
ansond | 0:e1c4378df3fe | 84 | }; |
ansond | 0:e1c4378df3fe | 85 | |
ansond | 0:e1c4378df3fe | 86 | #endif // _MBED_ENDPOINT_H_ |