Local copy
Dependencies: C12832_lcd ConfigFile EthernetInterface LM75B MMA7660 MQTTPacket mbed-rtos mbed
Fork of IBMIoTClientExampleForLPC1768 by
src/QuickstartClient.h@9:cbabd85f2d5d, 2014-07-01 (annotated)
- Committer:
- rajathishere
- Date:
- Tue Jul 01 19:10:47 2014 +0000
- Revision:
- 9:cbabd85f2d5d
- Parent:
- 6:a022f983f94b
- Child:
- 12:e9ff8869a99d
Added iniital drop of Subscription
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 | |
rajathishere | 9:cbabd85f2d5d | 26 | #define IBM_IOT_BROKER "5.153.46.201"//"108.168.183.11" //-wdc01-2 msproxy //"208.43.110.186" //-wdc01-2 quickstart-msproxy //"37.58.109.238"=old quickstart |
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 | 3:ca5b84eb8f3b | 37 | char topic[30]; |
rajathishere | 6:a022f983f94b | 38 | char subscribeTopic[30]; |
samdanbury | 2:25ddff75a8c7 | 39 | bool quickstartMode; |
samdanbury | 2:25ddff75a8c7 | 40 | |
samdanbury | 2:25ddff75a8c7 | 41 | string org; |
samdanbury | 2:25ddff75a8c7 | 42 | string type; |
samdanbury | 2:25ddff75a8c7 | 43 | string id; |
samdanbury | 2:25ddff75a8c7 | 44 | string token; |
samdanbury | 0:6276e9f72327 | 45 | |
samdanbury | 0:6276e9f72327 | 46 | QuickstartClient(string mac); |
samdanbury | 2:25ddff75a8c7 | 47 | void loadConfig(); |
samdanbury | 0:6276e9f72327 | 48 | void tryMqttConnect(); |
samdanbury | 0:6276e9f72327 | 49 | void connect(); |
samdanbury | 0:6276e9f72327 | 50 | void publish(string payload); |
samdanbury | 0:6276e9f72327 | 51 | bool getConnection(); |
samdanbury | 2:25ddff75a8c7 | 52 | int reconnectDelay(int attempt); |
rajathishere | 9:cbabd85f2d5d | 53 | int subscribe(); |
rajathishere | 6:a022f983f94b | 54 | //int* processEvents(char* buf, size_t count); |
samdanbury | 0:6276e9f72327 | 55 | }; |