Local copy
Dependencies: C12832_lcd ConfigFile EthernetInterface LM75B MMA7660 MQTTPacket mbed-rtos mbed
Fork of IBMIoTClientExampleForLPC1768 by
src/QuickstartClient.h@2:25ddff75a8c7, 2014-06-23 (annotated)
- Committer:
- samdanbury
- Date:
- Mon Jun 23 20:12:18 2014 +0000
- Revision:
- 2:25ddff75a8c7
- Parent:
- 0:6276e9f72327
- Child:
- 3:ca5b84eb8f3b
reads in a config file as well as utilises the new topic space and clientId changes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
samdanbury | 0:6276e9f72327 | 1 | /******************************************************************************* |
samdanbury | 0:6276e9f72327 | 2 | * Copyright (c) 2014 IBM Corporation and other Contributors. |
samdanbury | 0:6276e9f72327 | 3 | * |
samdanbury | 0:6276e9f72327 | 4 | * All rights reserved. This program and the accompanying materials |
samdanbury | 0:6276e9f72327 | 5 | * are made available under the terms of the Eclipse Public License v1.0 |
samdanbury | 0:6276e9f72327 | 6 | * which accompanies this distribution, and is available at |
samdanbury | 0:6276e9f72327 | 7 | * http://www.eclipse.org/legal/epl-v10.html |
samdanbury | 0:6276e9f72327 | 8 | * |
samdanbury | 0:6276e9f72327 | 9 | * Contributors: Sam Danbury |
samdanbury | 0:6276e9f72327 | 10 | * IBM - Initial Contribution |
samdanbury | 0:6276e9f72327 | 11 | *******************************************************************************/ |
samdanbury | 0:6276e9f72327 | 12 | |
samdanbury | 0:6276e9f72327 | 13 | #include "MQTTPacket.h" |
samdanbury | 0:6276e9f72327 | 14 | #include "rtos.h" |
samdanbury | 2:25ddff75a8c7 | 15 | #include "mbed.h" |
samdanbury | 0:6276e9f72327 | 16 | #include "EthernetInterface.h" |
samdanbury | 0:6276e9f72327 | 17 | #include "C12832_lcd.h" |
samdanbury | 2:25ddff75a8c7 | 18 | #include "ConfigFile.h" |
samdanbury | 0:6276e9f72327 | 19 | |
samdanbury | 0:6276e9f72327 | 20 | #include <string> |
samdanbury | 0:6276e9f72327 | 21 | #include <vector> |
samdanbury | 0:6276e9f72327 | 22 | #include <map> |
samdanbury | 0:6276e9f72327 | 23 | #include <sstream> |
samdanbury | 0:6276e9f72327 | 24 | #include <algorithm> |
samdanbury | 0:6276e9f72327 | 25 | |
samdanbury | 2:25ddff75a8c7 | 26 | #define IBM_IOT_BROKER "37.58.109.238" |
samdanbury | 0:6276e9f72327 | 27 | #define IBM_IOT_PORT 1883 |
samdanbury | 0:6276e9f72327 | 28 | |
samdanbury | 0:6276e9f72327 | 29 | using namespace std; |
samdanbury | 0:6276e9f72327 | 30 | |
samdanbury | 0:6276e9f72327 | 31 | class QuickstartClient { |
samdanbury | 0:6276e9f72327 | 32 | public: |
samdanbury | 0:6276e9f72327 | 33 | bool connected; |
samdanbury | 0:6276e9f72327 | 34 | C12832_LCD lcd; |
samdanbury | 0:6276e9f72327 | 35 | TCPSocketConnection mysock; |
samdanbury | 0:6276e9f72327 | 36 | string macAddress; |
samdanbury | 2:25ddff75a8c7 | 37 | char topic[25]; |
samdanbury | 2:25ddff75a8c7 | 38 | bool quickstartMode; |
samdanbury | 2:25ddff75a8c7 | 39 | |
samdanbury | 2:25ddff75a8c7 | 40 | string org; |
samdanbury | 2:25ddff75a8c7 | 41 | string type; |
samdanbury | 2:25ddff75a8c7 | 42 | string id; |
samdanbury | 2:25ddff75a8c7 | 43 | string token; |
samdanbury | 0:6276e9f72327 | 44 | |
samdanbury | 0:6276e9f72327 | 45 | QuickstartClient(string mac); |
samdanbury | 2:25ddff75a8c7 | 46 | void loadConfig(); |
samdanbury | 0:6276e9f72327 | 47 | void tryMqttConnect(); |
samdanbury | 0:6276e9f72327 | 48 | void connect(); |
samdanbury | 0:6276e9f72327 | 49 | void publish(string payload); |
samdanbury | 0:6276e9f72327 | 50 | bool getConnection(); |
samdanbury | 2:25ddff75a8c7 | 51 | int reconnectDelay(int attempt); |
samdanbury | 0:6276e9f72327 | 52 | }; |