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@24:b62fec3ff73c, 2014-09-13 (annotated)
- Committer:
- ansond
- Date:
- Sat Sep 13 04:27:32 2014 +0000
- Revision:
- 24:b62fec3ff73c
- Parent:
- 23:6f6e97a276b9
- Child:
- 28:b6a7959c8be0
updates for autoregistration
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 | 22:0f2a0269ce6d | 62 | char m_nsp_port_str[PREFERENCE_VALUE_LEN+1]; // NSP address port buffer |
ansond | 22:0f2a0269ce6d | 63 | char m_nsp_port_str_def[PREFERENCE_VALUE_LEN+1]; // NSP address port buffer (default) |
ansond | 22:0f2a0269ce6d | 64 | int m_nsp_port; // NSP port |
ansond | 4:7f7fe167d9c0 | 65 | int m_instance_id; // Instance ID for this endpoint |
ansond | 23:6f6e97a276b9 | 66 | void *m_status_reporter; // Status Reporter |
ansond | 0:e1c4378df3fe | 67 | |
ansond | 0:e1c4378df3fe | 68 | public: |
ansond | 23:6f6e97a276b9 | 69 | MBEDEndpoint(ErrorHandler *error_handler,void *transport,void *status_reporter,void *extra); |
ansond | 5:94d000e6fa70 | 70 | virtual ~MBEDEndpoint(); |
ansond | 0:e1c4378df3fe | 71 | ResourceFactory *initResourceFactory(); |
ansond | 0:e1c4378df3fe | 72 | void run(); |
ansond | 0:e1c4378df3fe | 73 | |
ansond | 0:e1c4378df3fe | 74 | char *getEndpointName(); |
ansond | 0:e1c4378df3fe | 75 | char *getNSPAddress(); |
ansond | 22:0f2a0269ce6d | 76 | int getNSPPort(); |
ansond | 0:e1c4378df3fe | 77 | Preferences *preferences(); |
ansond | 0:e1c4378df3fe | 78 | |
ansond | 0:e1c4378df3fe | 79 | char *getLCDStatus(); |
ansond | 0:e1c4378df3fe | 80 | |
ansond | 0:e1c4378df3fe | 81 | int getInstanceID(); |
ansond | 0:e1c4378df3fe | 82 | |
ansond | 0:e1c4378df3fe | 83 | void sendObservations(); |
ansond | 0:e1c4378df3fe | 84 | |
ansond | 23:6f6e97a276b9 | 85 | void extraEventLoopWork(); |
ansond | 23:6f6e97a276b9 | 86 | |
ansond | 0:e1c4378df3fe | 87 | private: |
ansond | 0:e1c4378df3fe | 88 | void initPreferences(); |
ansond | 0:e1c4378df3fe | 89 | void initNSPAddress(); |
ansond | 0:e1c4378df3fe | 90 | void initEndpointName(); |
ansond | 4:7f7fe167d9c0 | 91 | bool initializePersonalities(); |
ansond | 0:e1c4378df3fe | 92 | bool initializeLights(); |
ansond | 0:e1c4378df3fe | 93 | bool initializeTransport(int index,char *key,Transport *transport); |
ansond | 0:e1c4378df3fe | 94 | bool initializeTransports(); |
ansond | 4:7f7fe167d9c0 | 95 | bool closePersonalities(); |
ansond | 0:e1c4378df3fe | 96 | bool closeTransport(int index,char *key); |
ansond | 0:e1c4378df3fe | 97 | bool closeTransports(); |
ansond | 11:c4d02616e10f | 98 | |
ansond | 24:b62fec3ff73c | 99 | bool autoRegisterWithIOC(); |
ansond | 24:b62fec3ff73c | 100 | |
ansond | 11:c4d02616e10f | 101 | #ifdef CELLULAR_NETWORK |
ansond | 21:272df0444756 | 102 | bool initializeCellularModem(void *modem); |
ansond | 19:3cecccc1a3d4 | 103 | bool initializeGPSReceiver(void *gps); |
ansond | 11:c4d02616e10f | 104 | bool closeCellularModem(); |
ansond | 11:c4d02616e10f | 105 | bool closeGPSReceiver(); |
ansond | 11:c4d02616e10f | 106 | #else |
ansond | 6:edf306673e54 | 107 | bool initializeEthernet(EthernetInterface *ethernet); |
ansond | 11:c4d02616e10f | 108 | bool closeEthernet(); |
ansond | 11:c4d02616e10f | 109 | #endif |
ansond | 0:e1c4378df3fe | 110 | }; |
ansond | 0:e1c4378df3fe | 111 | |
ansond | 0:e1c4378df3fe | 112 | #endif // _MBED_ENDPOINT_H_ |