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@15:a0eae7ab1e59, 2014-04-03 (annotated)
- Committer:
- ansond
- Date:
- Thu Apr 03 02:01:36 2014 +0000
- Revision:
- 15:a0eae7ab1e59
- Parent:
- 14:07b77fbb1985
- Child:
- 19:3cecccc1a3d4
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 | 5:94d000e6fa70 | 22 | // BaseClass support |
ansond | 5:94d000e6fa70 | 23 | #include "BaseClass.h" |
ansond | 0:e1c4378df3fe | 24 | |
ansond | 0:e1c4378df3fe | 25 | // NSP Transport support |
ansond | 0:e1c4378df3fe | 26 | #include "NSPTransport.h" |
ansond | 0:e1c4378df3fe | 27 | |
ansond | 0:e1c4378df3fe | 28 | // HTTP Transport support |
ansond | 0:e1c4378df3fe | 29 | #include "HTTPTransport.h" |
ansond | 0:e1c4378df3fe | 30 | |
ansond | 4:7f7fe167d9c0 | 31 | // Personality Support |
ansond | 4:7f7fe167d9c0 | 32 | #include "Personality.h" |
ansond | 0:e1c4378df3fe | 33 | |
ansond | 0:e1c4378df3fe | 34 | // Preferences Support |
ansond | 0:e1c4378df3fe | 35 | #include "Preferences.h" |
ansond | 6:edf306673e54 | 36 | |
ansond | 11:c4d02616e10f | 37 | // network selection |
ansond | 11:c4d02616e10f | 38 | #ifdef CELLULAR_NETWORK |
ansond | 11:c4d02616e10f | 39 | // Cellular |
ansond | 11:c4d02616e10f | 40 | #include "MBEDUbloxCellRadio.h" |
ansond | 11:c4d02616e10f | 41 | #include "MBEDUbloxGPS.h" |
ansond | 11:c4d02616e10f | 42 | #else |
ansond | 11:c4d02616e10f | 43 | // Ethernet |
ansond | 6:edf306673e54 | 44 | #include "EthernetInterface.h" |
ansond | 6:edf306673e54 | 45 | #endif |
ansond | 0:e1c4378df3fe | 46 | |
ansond | 5:94d000e6fa70 | 47 | class MBEDEndpoint : public BaseClass { |
ansond | 0:e1c4378df3fe | 48 | private: |
ansond | 11:c4d02616e10f | 49 | #ifdef CELLULAR_NETWORK |
ansond | 11:c4d02616e10f | 50 | MBEDUbloxCellRadio *m_cellular_modem; // cell modem |
ansond | 11:c4d02616e10f | 51 | MBEDUbloxGPS *m_gps; // GPS receiver |
ansond | 11:c4d02616e10f | 52 | #else |
ansond | 11:c4d02616e10f | 53 | EthernetInterface *m_ethernet; // ethernet interface |
ansond | 6:edf306673e54 | 54 | #endif |
ansond | 11:c4d02616e10f | 55 | |
ansond | 4:7f7fe167d9c0 | 56 | Transport *m_transports[NUM_TRANSPORTS]; // our transport |
ansond | 4:7f7fe167d9c0 | 57 | Personality *m_personalities[NUM_PERSONALITY_INSTANCES]; // our personalities (at least 1 instance) |
ansond | 4:7f7fe167d9c0 | 58 | char m_endpoint_name[PERSONALITY_NAME_LEN+1]; // our endpoint name (personalities[0]) |
ansond | 4:7f7fe167d9c0 | 59 | Preferences *m_preferences; // preference support |
ansond | 4:7f7fe167d9c0 | 60 | char m_lcd_status[TEMP_BUFFER_LEN+1]; // LCD status buffer |
ansond | 4:7f7fe167d9c0 | 61 | char m_nsp_address[PREFERENCE_VALUE_LEN+1]; // NSP address buffer |
ansond | 4:7f7fe167d9c0 | 62 | int m_instance_id; // Instance ID for this endpoint |
ansond | 0:e1c4378df3fe | 63 | |
ansond | 0:e1c4378df3fe | 64 | public: |
ansond | 14:07b77fbb1985 | 65 | MBEDEndpoint(ErrorHandler *error_handler,void *transport,void *pinouts); |
ansond | 5:94d000e6fa70 | 66 | virtual ~MBEDEndpoint(); |
ansond | 0:e1c4378df3fe | 67 | ResourceFactory *initResourceFactory(); |
ansond | 0:e1c4378df3fe | 68 | void run(); |
ansond | 0:e1c4378df3fe | 69 | |
ansond | 0:e1c4378df3fe | 70 | char *getEndpointName(); |
ansond | 0:e1c4378df3fe | 71 | char *getNSPAddress(); |
ansond | 0:e1c4378df3fe | 72 | Preferences *preferences(); |
ansond | 0:e1c4378df3fe | 73 | |
ansond | 0:e1c4378df3fe | 74 | char *getLCDStatus(); |
ansond | 0:e1c4378df3fe | 75 | |
ansond | 0:e1c4378df3fe | 76 | int getInstanceID(); |
ansond | 0:e1c4378df3fe | 77 | |
ansond | 0:e1c4378df3fe | 78 | void sendObservations(); |
ansond | 0:e1c4378df3fe | 79 | |
ansond | 0:e1c4378df3fe | 80 | private: |
ansond | 0:e1c4378df3fe | 81 | void initPreferences(); |
ansond | 0:e1c4378df3fe | 82 | void initNSPAddress(); |
ansond | 0:e1c4378df3fe | 83 | void initEndpointName(); |
ansond | 4:7f7fe167d9c0 | 84 | bool initializePersonalities(); |
ansond | 0:e1c4378df3fe | 85 | bool initializeLights(); |
ansond | 0:e1c4378df3fe | 86 | bool initializeTransport(int index,char *key,Transport *transport); |
ansond | 0:e1c4378df3fe | 87 | bool initializeTransports(); |
ansond | 4:7f7fe167d9c0 | 88 | bool closePersonalities(); |
ansond | 0:e1c4378df3fe | 89 | bool closeTransport(int index,char *key); |
ansond | 0:e1c4378df3fe | 90 | bool closeTransports(); |
ansond | 11:c4d02616e10f | 91 | |
ansond | 11:c4d02616e10f | 92 | #ifdef CELLULAR_NETWORK |
ansond | 14:07b77fbb1985 | 93 | bool initializeCellularModem(void *transport,void *pinouts); |
ansond | 15:a0eae7ab1e59 | 94 | bool initializeGPSReceiver(void *pinouts); |
ansond | 11:c4d02616e10f | 95 | bool closeCellularModem(); |
ansond | 11:c4d02616e10f | 96 | bool closeGPSReceiver(); |
ansond | 11:c4d02616e10f | 97 | #else |
ansond | 6:edf306673e54 | 98 | bool initializeEthernet(EthernetInterface *ethernet); |
ansond | 11:c4d02616e10f | 99 | bool closeEthernet(); |
ansond | 11:c4d02616e10f | 100 | #endif |
ansond | 0:e1c4378df3fe | 101 | }; |
ansond | 0:e1c4378df3fe | 102 | |
ansond | 0:e1c4378df3fe | 103 | #endif // _MBED_ENDPOINT_H_ |