Core Base Classes for the Light Endpoints
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more
main.cpp@0:4c9bfcb3e759, 2014-02-24 (annotated)
- Committer:
- ansond
- Date:
- Mon Feb 24 19:09:25 2014 +0000
- Revision:
- 0:4c9bfcb3e759
- Child:
- 18:bc165829bb88
initial checkin
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ansond | 0:4c9bfcb3e759 | 1 | /* Copyright C2013 Doug Anson, MIT License |
ansond | 0:4c9bfcb3e759 | 2 | * |
ansond | 0:4c9bfcb3e759 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
ansond | 0:4c9bfcb3e759 | 4 | * and associated documentation files the "Software", to deal in the Software without restriction, |
ansond | 0:4c9bfcb3e759 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
ansond | 0:4c9bfcb3e759 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
ansond | 0:4c9bfcb3e759 | 7 | * furnished to do so, subject to the following conditions: |
ansond | 0:4c9bfcb3e759 | 8 | * |
ansond | 0:4c9bfcb3e759 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
ansond | 0:4c9bfcb3e759 | 10 | * substantial portions of the Software. |
ansond | 0:4c9bfcb3e759 | 11 | * |
ansond | 0:4c9bfcb3e759 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
ansond | 0:4c9bfcb3e759 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
ansond | 0:4c9bfcb3e759 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
ansond | 0:4c9bfcb3e759 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ansond | 0:4c9bfcb3e759 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
ansond | 0:4c9bfcb3e759 | 17 | */ |
ansond | 0:4c9bfcb3e759 | 18 | |
ansond | 0:4c9bfcb3e759 | 19 | #include "MBEDEndpoint.h" |
ansond | 0:4c9bfcb3e759 | 20 | |
ansond | 0:4c9bfcb3e759 | 21 | // Ethernet Interface |
ansond | 0:4c9bfcb3e759 | 22 | EthernetInterface ethernet; |
ansond | 0:4c9bfcb3e759 | 23 | |
ansond | 0:4c9bfcb3e759 | 24 | // Serial Console Support |
ansond | 0:4c9bfcb3e759 | 25 | #include "MODSERIAL.h" |
ansond | 0:4c9bfcb3e759 | 26 | MODSERIAL pc(USBTX, USBRX); |
ansond | 0:4c9bfcb3e759 | 27 | |
ansond | 0:4c9bfcb3e759 | 28 | // LCD Support |
ansond | 0:4c9bfcb3e759 | 29 | #include "C12832_lcd.h" |
ansond | 0:4c9bfcb3e759 | 30 | C12832_LCD lcd; |
ansond | 0:4c9bfcb3e759 | 31 | |
ansond | 0:4c9bfcb3e759 | 32 | // Instances for the Endpoint |
ansond | 0:4c9bfcb3e759 | 33 | ErrorHandler *error_handler = NULL; |
ansond | 0:4c9bfcb3e759 | 34 | MBEDEndpoint *endpoint = NULL; |
ansond | 0:4c9bfcb3e759 | 35 | |
ansond | 0:4c9bfcb3e759 | 36 | // ErrorHandler (logger) |
ansond | 0:4c9bfcb3e759 | 37 | ErrorHandler *logger() { return error_handler; } |
ansond | 0:4c9bfcb3e759 | 38 | |
ansond | 0:4c9bfcb3e759 | 39 | // close down the application and exit |
ansond | 0:4c9bfcb3e759 | 40 | void closedown() { |
ansond | 0:4c9bfcb3e759 | 41 | if (endpoint != NULL) { |
ansond | 0:4c9bfcb3e759 | 42 | error_handler->log("Closing down Endpoint..."); |
ansond | 0:4c9bfcb3e759 | 43 | delete endpoint; |
ansond | 0:4c9bfcb3e759 | 44 | } |
ansond | 0:4c9bfcb3e759 | 45 | |
ansond | 0:4c9bfcb3e759 | 46 | pc.printf("Exiting...\r\n"); |
ansond | 0:4c9bfcb3e759 | 47 | lcd.locate(0,0); |
ansond | 0:4c9bfcb3e759 | 48 | lcd.printf("Shutdown Complete"); |
ansond | 0:4c9bfcb3e759 | 49 | delete error_handler; |
ansond | 0:4c9bfcb3e759 | 50 | exit(1); |
ansond | 0:4c9bfcb3e759 | 51 | } |
ansond | 0:4c9bfcb3e759 | 52 | |
ansond | 0:4c9bfcb3e759 | 53 | // Main Entry |
ansond | 0:4c9bfcb3e759 | 54 | int main() { |
ansond | 0:4c9bfcb3e759 | 55 | error_handler = new ErrorHandler(&pc,&lcd); |
ansond | 0:4c9bfcb3e759 | 56 | endpoint = new MBEDEndpoint(error_handler,ðernet); |
ansond | 0:4c9bfcb3e759 | 57 | if (endpoint != NULL) endpoint->run(); |
ansond | 0:4c9bfcb3e759 | 58 | } |