ME910 support
Dependents: 5_Dragonfly_Cayenne_Sprint_IKS01A1
Fork of Cayenne-MQTT-mbed-MTSAS by
src/MQTTCommon/MQTTConnect.h@0:09ef59d2d0f7, 2016-10-07 (annotated)
- Committer:
- jburhenn
- Date:
- Fri Oct 07 17:21:45 2016 +0000
- Revision:
- 0:09ef59d2d0f7
- Child:
- 22:0dbabcc6e7b2
Initial commit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jburhenn | 0:09ef59d2d0f7 | 1 | /******************************************************************************* |
jburhenn | 0:09ef59d2d0f7 | 2 | * Copyright (c) 2014 IBM Corp. |
jburhenn | 0:09ef59d2d0f7 | 3 | * |
jburhenn | 0:09ef59d2d0f7 | 4 | * All rights reserved. This program and the accompanying materials |
jburhenn | 0:09ef59d2d0f7 | 5 | * are made available under the terms of the Eclipse Public License v1.0 |
jburhenn | 0:09ef59d2d0f7 | 6 | * and Eclipse Distribution License v1.0 which accompany this distribution. |
jburhenn | 0:09ef59d2d0f7 | 7 | * |
jburhenn | 0:09ef59d2d0f7 | 8 | * The Eclipse Public License is available at |
jburhenn | 0:09ef59d2d0f7 | 9 | * http://www.eclipse.org/legal/epl-v10.html |
jburhenn | 0:09ef59d2d0f7 | 10 | * and the Eclipse Distribution License is available at |
jburhenn | 0:09ef59d2d0f7 | 11 | * http://www.eclipse.org/org/documents/edl-v10.php. |
jburhenn | 0:09ef59d2d0f7 | 12 | * |
jburhenn | 0:09ef59d2d0f7 | 13 | * Contributors: |
jburhenn | 0:09ef59d2d0f7 | 14 | * Ian Craggs - initial API and implementation and/or initial documentation |
jburhenn | 0:09ef59d2d0f7 | 15 | * Xiang Rong - 442039 Add makefile to Embedded C client |
jburhenn | 0:09ef59d2d0f7 | 16 | *******************************************************************************/ |
jburhenn | 0:09ef59d2d0f7 | 17 | |
jburhenn | 0:09ef59d2d0f7 | 18 | #ifndef MQTTCONNECT_H_ |
jburhenn | 0:09ef59d2d0f7 | 19 | #define MQTTCONNECT_H_ |
jburhenn | 0:09ef59d2d0f7 | 20 | |
jburhenn | 0:09ef59d2d0f7 | 21 | #if !defined(DLLImport) |
jburhenn | 0:09ef59d2d0f7 | 22 | #define DLLImport |
jburhenn | 0:09ef59d2d0f7 | 23 | #endif |
jburhenn | 0:09ef59d2d0f7 | 24 | #if !defined(DLLExport) |
jburhenn | 0:09ef59d2d0f7 | 25 | #define DLLExport |
jburhenn | 0:09ef59d2d0f7 | 26 | #endif |
jburhenn | 0:09ef59d2d0f7 | 27 | |
jburhenn | 0:09ef59d2d0f7 | 28 | |
jburhenn | 0:09ef59d2d0f7 | 29 | typedef union |
jburhenn | 0:09ef59d2d0f7 | 30 | { |
jburhenn | 0:09ef59d2d0f7 | 31 | unsigned char all; /**< all connect flags */ |
jburhenn | 0:09ef59d2d0f7 | 32 | #if defined(REVERSED) |
jburhenn | 0:09ef59d2d0f7 | 33 | struct |
jburhenn | 0:09ef59d2d0f7 | 34 | { |
jburhenn | 0:09ef59d2d0f7 | 35 | unsigned int username : 1; /**< 3.1 user name */ |
jburhenn | 0:09ef59d2d0f7 | 36 | unsigned int password : 1; /**< 3.1 password */ |
jburhenn | 0:09ef59d2d0f7 | 37 | unsigned int willRetain : 1; /**< will retain setting */ |
jburhenn | 0:09ef59d2d0f7 | 38 | unsigned int willQoS : 2; /**< will QoS value */ |
jburhenn | 0:09ef59d2d0f7 | 39 | unsigned int will : 1; /**< will flag */ |
jburhenn | 0:09ef59d2d0f7 | 40 | unsigned int cleansession : 1; /**< clean session flag */ |
jburhenn | 0:09ef59d2d0f7 | 41 | unsigned int : 1; /**< unused */ |
jburhenn | 0:09ef59d2d0f7 | 42 | } bits; |
jburhenn | 0:09ef59d2d0f7 | 43 | #else |
jburhenn | 0:09ef59d2d0f7 | 44 | struct |
jburhenn | 0:09ef59d2d0f7 | 45 | { |
jburhenn | 0:09ef59d2d0f7 | 46 | unsigned int : 1; /**< unused */ |
jburhenn | 0:09ef59d2d0f7 | 47 | unsigned int cleansession : 1; /**< cleansession flag */ |
jburhenn | 0:09ef59d2d0f7 | 48 | unsigned int will : 1; /**< will flag */ |
jburhenn | 0:09ef59d2d0f7 | 49 | unsigned int willQoS : 2; /**< will QoS value */ |
jburhenn | 0:09ef59d2d0f7 | 50 | unsigned int willRetain : 1; /**< will retain setting */ |
jburhenn | 0:09ef59d2d0f7 | 51 | unsigned int password : 1; /**< 3.1 password */ |
jburhenn | 0:09ef59d2d0f7 | 52 | unsigned int username : 1; /**< 3.1 user name */ |
jburhenn | 0:09ef59d2d0f7 | 53 | } bits; |
jburhenn | 0:09ef59d2d0f7 | 54 | #endif |
jburhenn | 0:09ef59d2d0f7 | 55 | } MQTTConnectFlags; /**< connect flags byte */ |
jburhenn | 0:09ef59d2d0f7 | 56 | |
jburhenn | 0:09ef59d2d0f7 | 57 | |
jburhenn | 0:09ef59d2d0f7 | 58 | |
jburhenn | 0:09ef59d2d0f7 | 59 | /** |
jburhenn | 0:09ef59d2d0f7 | 60 | * Defines the MQTT "Last Will and Testament" (LWT) settings for |
jburhenn | 0:09ef59d2d0f7 | 61 | * the connect packet. |
jburhenn | 0:09ef59d2d0f7 | 62 | */ |
jburhenn | 0:09ef59d2d0f7 | 63 | typedef struct |
jburhenn | 0:09ef59d2d0f7 | 64 | { |
jburhenn | 0:09ef59d2d0f7 | 65 | /** The eyecatcher for this structure. must be MQTW. */ |
jburhenn | 0:09ef59d2d0f7 | 66 | char struct_id[4]; |
jburhenn | 0:09ef59d2d0f7 | 67 | /** The version number of this structure. Must be 0 */ |
jburhenn | 0:09ef59d2d0f7 | 68 | int struct_version; |
jburhenn | 0:09ef59d2d0f7 | 69 | /** The LWT topic to which the LWT message will be published. */ |
jburhenn | 0:09ef59d2d0f7 | 70 | MQTTString topicName; |
jburhenn | 0:09ef59d2d0f7 | 71 | /** The LWT payload. */ |
jburhenn | 0:09ef59d2d0f7 | 72 | MQTTString message; |
jburhenn | 0:09ef59d2d0f7 | 73 | /** |
jburhenn | 0:09ef59d2d0f7 | 74 | * The retained flag for the LWT message (see MQTTAsync_message.retained). |
jburhenn | 0:09ef59d2d0f7 | 75 | */ |
jburhenn | 0:09ef59d2d0f7 | 76 | unsigned char retained; |
jburhenn | 0:09ef59d2d0f7 | 77 | /** |
jburhenn | 0:09ef59d2d0f7 | 78 | * The quality of service setting for the LWT message (see |
jburhenn | 0:09ef59d2d0f7 | 79 | * MQTTAsync_message.qos and @ref qos). |
jburhenn | 0:09ef59d2d0f7 | 80 | */ |
jburhenn | 0:09ef59d2d0f7 | 81 | char qos; |
jburhenn | 0:09ef59d2d0f7 | 82 | } MQTTPacket_willOptions; |
jburhenn | 0:09ef59d2d0f7 | 83 | |
jburhenn | 0:09ef59d2d0f7 | 84 | |
jburhenn | 0:09ef59d2d0f7 | 85 | #define MQTTPacket_willOptions_initializer { {'M', 'Q', 'T', 'W'}, 0, {NULL, {0, NULL}}, {NULL, {0, NULL}}, 0, 0 } |
jburhenn | 0:09ef59d2d0f7 | 86 | |
jburhenn | 0:09ef59d2d0f7 | 87 | |
jburhenn | 0:09ef59d2d0f7 | 88 | typedef struct |
jburhenn | 0:09ef59d2d0f7 | 89 | { |
jburhenn | 0:09ef59d2d0f7 | 90 | /** The eyecatcher for this structure. must be MQTC. */ |
jburhenn | 0:09ef59d2d0f7 | 91 | char struct_id[4]; |
jburhenn | 0:09ef59d2d0f7 | 92 | /** The version number of this structure. Must be 0 */ |
jburhenn | 0:09ef59d2d0f7 | 93 | int struct_version; |
jburhenn | 0:09ef59d2d0f7 | 94 | /** Version of MQTT to be used. 3 = 3.1 4 = 3.1.1 |
jburhenn | 0:09ef59d2d0f7 | 95 | */ |
jburhenn | 0:09ef59d2d0f7 | 96 | unsigned char MQTTVersion; |
jburhenn | 0:09ef59d2d0f7 | 97 | MQTTString clientID; |
jburhenn | 0:09ef59d2d0f7 | 98 | unsigned short keepAliveInterval; |
jburhenn | 0:09ef59d2d0f7 | 99 | unsigned char cleansession; |
jburhenn | 0:09ef59d2d0f7 | 100 | unsigned char willFlag; |
jburhenn | 0:09ef59d2d0f7 | 101 | MQTTPacket_willOptions will; |
jburhenn | 0:09ef59d2d0f7 | 102 | MQTTString username; |
jburhenn | 0:09ef59d2d0f7 | 103 | MQTTString password; |
jburhenn | 0:09ef59d2d0f7 | 104 | } MQTTPacket_connectData; |
jburhenn | 0:09ef59d2d0f7 | 105 | |
jburhenn | 0:09ef59d2d0f7 | 106 | typedef union |
jburhenn | 0:09ef59d2d0f7 | 107 | { |
jburhenn | 0:09ef59d2d0f7 | 108 | unsigned char all; /**< all connack flags */ |
jburhenn | 0:09ef59d2d0f7 | 109 | #if defined(REVERSED) |
jburhenn | 0:09ef59d2d0f7 | 110 | struct |
jburhenn | 0:09ef59d2d0f7 | 111 | { |
jburhenn | 0:09ef59d2d0f7 | 112 | unsigned int sessionpresent : 1; /**< session present flag */ |
jburhenn | 0:09ef59d2d0f7 | 113 | unsigned int : 7; /**< unused */ |
jburhenn | 0:09ef59d2d0f7 | 114 | } bits; |
jburhenn | 0:09ef59d2d0f7 | 115 | #else |
jburhenn | 0:09ef59d2d0f7 | 116 | struct |
jburhenn | 0:09ef59d2d0f7 | 117 | { |
jburhenn | 0:09ef59d2d0f7 | 118 | unsigned int : 7; /**< unused */ |
jburhenn | 0:09ef59d2d0f7 | 119 | unsigned int sessionpresent : 1; /**< session present flag */ |
jburhenn | 0:09ef59d2d0f7 | 120 | } bits; |
jburhenn | 0:09ef59d2d0f7 | 121 | #endif |
jburhenn | 0:09ef59d2d0f7 | 122 | } MQTTConnackFlags; /**< connack flags byte */ |
jburhenn | 0:09ef59d2d0f7 | 123 | |
jburhenn | 0:09ef59d2d0f7 | 124 | #define MQTTPacket_connectData_initializer { {'M', 'Q', 'T', 'C'}, 0, 4, {NULL, {0, NULL}}, 60, 1, 0, \ |
jburhenn | 0:09ef59d2d0f7 | 125 | MQTTPacket_willOptions_initializer, {NULL, {0, NULL}}, {NULL, {0, NULL}} } |
jburhenn | 0:09ef59d2d0f7 | 126 | |
jburhenn | 0:09ef59d2d0f7 | 127 | DLLExport int MQTTSerialize_connect(unsigned char* buf, int buflen, MQTTPacket_connectData* options); |
jburhenn | 0:09ef59d2d0f7 | 128 | DLLExport int MQTTDeserialize_connect(MQTTPacket_connectData* data, unsigned char* buf, int len); |
jburhenn | 0:09ef59d2d0f7 | 129 | |
jburhenn | 0:09ef59d2d0f7 | 130 | DLLExport int MQTTSerialize_connack(unsigned char* buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent); |
jburhenn | 0:09ef59d2d0f7 | 131 | DLLExport int MQTTDeserialize_connack(unsigned char* sessionPresent, unsigned char* connack_rc, unsigned char* buf, int buflen); |
jburhenn | 0:09ef59d2d0f7 | 132 | |
jburhenn | 0:09ef59d2d0f7 | 133 | DLLExport int MQTTSerialize_disconnect(unsigned char* buf, int buflen); |
jburhenn | 0:09ef59d2d0f7 | 134 | DLLExport int MQTTSerialize_pingreq(unsigned char* buf, int buflen); |
jburhenn | 0:09ef59d2d0f7 | 135 | |
jburhenn | 0:09ef59d2d0f7 | 136 | #endif /* MQTTCONNECT_H_ */ |