An API for using MQTT over multiple transports
Dependencies: FP MQTTPacket
Dependents: Cellular_HelloMQTT IoTStarterKit GSwifiInterface_HelloMQTT IBMIoTClientEthernetExample ... more
This library is part of the EclipseTM Paho project; specifically the embedded client.
The goals of this API are:
- to be independent of any system library: hence templates parameters for networking, timer and threading classes
- not to rely on heap storage, only automatic (I think this is a good thing)
- to limit memory use, for instance by defining the size of the buffers and arrays used at object creation time
MQTTClient.cpp@10:68a4ada53367, 2014-04-10 (annotated)
- Committer:
- icraggs
- Date:
- Thu Apr 10 15:19:08 2014 +0000
- Revision:
- 10:68a4ada53367
- Parent:
- 9:01b8cc7d94cc
- Child:
- 11:db15da110a37
- Child:
- 12:cc7f2d62a393
Move linux main to a better place
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
icraggs | 6:4d312a49200b | 1 | /******************************************************************************* |
icraggs | 6:4d312a49200b | 2 | * Copyright (c) 2014 IBM Corp. |
sam_grove | 0:fe461e4d7afe | 3 | * |
icraggs | 6:4d312a49200b | 4 | * All rights reserved. This program and the accompanying materials |
icraggs | 6:4d312a49200b | 5 | * are made available under the terms of the Eclipse Public License v1.0 |
icraggs | 6:4d312a49200b | 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. |
sam_grove | 0:fe461e4d7afe | 7 | * |
icraggs | 6:4d312a49200b | 8 | * The Eclipse Public License is available at |
icraggs | 6:4d312a49200b | 9 | * http://www.eclipse.org/legal/epl-v10.html |
icraggs | 6:4d312a49200b | 10 | * and the Eclipse Distribution License is available at |
icraggs | 6:4d312a49200b | 11 | * http://www.eclipse.org/org/documents/edl-v10.php. |
sam_grove | 0:fe461e4d7afe | 12 | * |
icraggs | 6:4d312a49200b | 13 | * Contributors: |
icraggs | 6:4d312a49200b | 14 | * Ian Craggs - initial API and implementation and/or initial documentation |
icraggs | 6:4d312a49200b | 15 | *******************************************************************************/ |
sam_grove | 0:fe461e4d7afe | 16 | |
icraggs | 2:dcfdd2abfe71 | 17 | #include "MQTTClient.h" |
icraggs | 2:dcfdd2abfe71 | 18 | #include "MQTTPacket.h" |
icraggs | 2:dcfdd2abfe71 | 19 | |
icraggs | 3:dbff6b768d28 | 20 | |
icraggs | 8:c46930bd6c82 | 21 | void MQTT::threadfn(void* arg) |
icraggs | 3:dbff6b768d28 | 22 | { |
icraggs | 8:c46930bd6c82 | 23 | ((Client<Network, Timer, Thread>*) arg)->run(NULL); |
icraggs | 3:dbff6b768d28 | 24 | } |
icraggs | 3:dbff6b768d28 | 25 | |
icraggs | 9:01b8cc7d94cc | 26 | |
icraggs | 9:01b8cc7d94cc | 27 | MQTT::PacketId::PacketId() |
icraggs | 9:01b8cc7d94cc | 28 | { |
icraggs | 9:01b8cc7d94cc | 29 | next = 0; |
icraggs | 9:01b8cc7d94cc | 30 | } |
icraggs | 9:01b8cc7d94cc | 31 | |
icraggs | 9:01b8cc7d94cc | 32 | int MQTT::PacketId::getNext() |
icraggs | 9:01b8cc7d94cc | 33 | { |
icraggs | 9:01b8cc7d94cc | 34 | return next = (next == MAX_PACKET_ID) ? 1 : ++next; |
icraggs | 9:01b8cc7d94cc | 35 | } |