mbed OS5に対応したMilkcocoaライブラリのテストバージョンです。

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
jksoft
Date:
Tue Jan 24 13:41:36 2017 +0000
Revision:
24:6ba1245bf049
??????????

Who changed what in which revision?

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