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 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 *******************************************************************************/
jksoft 24:6ba1245bf049 16
jksoft 24:6ba1245bf049 17 #ifndef MQTTPACKET_H_
jksoft 24:6ba1245bf049 18 #define MQTTPACKET_H_
jksoft 24:6ba1245bf049 19
jksoft 24:6ba1245bf049 20 #if defined(__cplusplus) /* If this is a C++ compiler, use C linkage */
jksoft 24:6ba1245bf049 21 extern "C" {
jksoft 24:6ba1245bf049 22 #endif
jksoft 24:6ba1245bf049 23
jksoft 24:6ba1245bf049 24 enum errors
jksoft 24:6ba1245bf049 25 {
jksoft 24:6ba1245bf049 26 MQTTPACKET_BUFFER_TOO_SHORT = -2,
jksoft 24:6ba1245bf049 27 MQTTPACKET_READ_ERROR = -1,
jksoft 24:6ba1245bf049 28 MQTTPACKET_READ_COMPLETE,
jksoft 24:6ba1245bf049 29 };
jksoft 24:6ba1245bf049 30
jksoft 24:6ba1245bf049 31 enum msgTypes
jksoft 24:6ba1245bf049 32 {
jksoft 24:6ba1245bf049 33 CONNECT = 1, CONNACK, PUBLISH, PUBACK, PUBREC, PUBREL,
jksoft 24:6ba1245bf049 34 PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK,
jksoft 24:6ba1245bf049 35 PINGREQ, PINGRESP, DISCONNECT
jksoft 24:6ba1245bf049 36 };
jksoft 24:6ba1245bf049 37
jksoft 24:6ba1245bf049 38 /**
jksoft 24:6ba1245bf049 39 * Bitfields for the MQTT header byte.
jksoft 24:6ba1245bf049 40 */
jksoft 24:6ba1245bf049 41 typedef union
jksoft 24:6ba1245bf049 42 {
jksoft 24:6ba1245bf049 43 unsigned char byte; /**< the whole byte */
jksoft 24:6ba1245bf049 44 #if defined(REVERSED)
jksoft 24:6ba1245bf049 45 struct
jksoft 24:6ba1245bf049 46 {
jksoft 24:6ba1245bf049 47 unsigned int type : 4; /**< message type nibble */
jksoft 24:6ba1245bf049 48 unsigned int dup : 1; /**< DUP flag bit */
jksoft 24:6ba1245bf049 49 unsigned int qos : 2; /**< QoS value, 0, 1 or 2 */
jksoft 24:6ba1245bf049 50 unsigned int retain : 1; /**< retained flag bit */
jksoft 24:6ba1245bf049 51 } bits;
jksoft 24:6ba1245bf049 52 #else
jksoft 24:6ba1245bf049 53 struct
jksoft 24:6ba1245bf049 54 {
jksoft 24:6ba1245bf049 55 unsigned int retain : 1; /**< retained flag bit */
jksoft 24:6ba1245bf049 56 unsigned int qos : 2; /**< QoS value, 0, 1 or 2 */
jksoft 24:6ba1245bf049 57 unsigned int dup : 1; /**< DUP flag bit */
jksoft 24:6ba1245bf049 58 unsigned int type : 4; /**< message type nibble */
jksoft 24:6ba1245bf049 59 } bits;
jksoft 24:6ba1245bf049 60 #endif
jksoft 24:6ba1245bf049 61 } MQTTHeader;
jksoft 24:6ba1245bf049 62
jksoft 24:6ba1245bf049 63 typedef struct
jksoft 24:6ba1245bf049 64 {
jksoft 24:6ba1245bf049 65 int len;
jksoft 24:6ba1245bf049 66 char* data;
jksoft 24:6ba1245bf049 67 } MQTTLenString;
jksoft 24:6ba1245bf049 68
jksoft 24:6ba1245bf049 69 typedef struct
jksoft 24:6ba1245bf049 70 {
jksoft 24:6ba1245bf049 71 char* cstring;
jksoft 24:6ba1245bf049 72 MQTTLenString lenstring;
jksoft 24:6ba1245bf049 73 } MQTTString;
jksoft 24:6ba1245bf049 74
jksoft 24:6ba1245bf049 75 #define MQTTString_initializer {NULL, {0, NULL}}
jksoft 24:6ba1245bf049 76
jksoft 24:6ba1245bf049 77 int MQTTstrlen(MQTTString mqttstring);
jksoft 24:6ba1245bf049 78
jksoft 24:6ba1245bf049 79 #include "MQTTConnect.h"
jksoft 24:6ba1245bf049 80 #include "MQTTPublish.h"
jksoft 24:6ba1245bf049 81 #include "MQTTSubscribe.h"
jksoft 24:6ba1245bf049 82 #include "MQTTUnsubscribe.h"
jksoft 24:6ba1245bf049 83
jksoft 24:6ba1245bf049 84 int MQTTSerialize_ack(unsigned char* buf, int buflen, unsigned char type, unsigned char dup, unsigned short packetid);
jksoft 24:6ba1245bf049 85 int MQTTDeserialize_ack(unsigned char* packettype, unsigned char* dup, unsigned short* packetid, unsigned char* buf, int buflen);
jksoft 24:6ba1245bf049 86
jksoft 24:6ba1245bf049 87 int MQTTPacket_len(int rem_len);
jksoft 24:6ba1245bf049 88 int MQTTPacket_equals(MQTTString* a, char* b);
jksoft 24:6ba1245bf049 89
jksoft 24:6ba1245bf049 90 int MQTTPacket_encode(unsigned char* buf, int length);
jksoft 24:6ba1245bf049 91 int MQTTPacket_decode(int (*getcharfn)(unsigned char*, int), int* value);
jksoft 24:6ba1245bf049 92 int MQTTPacket_decodeBuf(unsigned char* buf, int* value);
jksoft 24:6ba1245bf049 93
jksoft 24:6ba1245bf049 94 int readInt(unsigned char** pptr);
jksoft 24:6ba1245bf049 95 char readChar(unsigned char** pptr);
jksoft 24:6ba1245bf049 96 void writeChar(unsigned char** pptr, char c);
jksoft 24:6ba1245bf049 97 void writeInt(unsigned char** pptr, int anInt);
jksoft 24:6ba1245bf049 98 int readMQTTLenString(MQTTString* mqttstring, unsigned char** pptr, unsigned char* enddata);
jksoft 24:6ba1245bf049 99 void writeCString(unsigned char** pptr, const char* string);
jksoft 24:6ba1245bf049 100 void writeMQTTString(unsigned char** pptr, MQTTString mqttstring);
jksoft 24:6ba1245bf049 101
jksoft 24:6ba1245bf049 102 int MQTTPacket_read(unsigned char* buf, int buflen, int (*getfn)(unsigned char*, int));
jksoft 24:6ba1245bf049 103
jksoft 24:6ba1245bf049 104 char* MQTTPacket_toString(char* strbuf, int strbuflen, unsigned char* buf, int buflen);
jksoft 24:6ba1245bf049 105
jksoft 24:6ba1245bf049 106 #ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
jksoft 24:6ba1245bf049 107 }
jksoft 24:6ba1245bf049 108 #endif
jksoft 24:6ba1245bf049 109
jksoft 24:6ba1245bf049 110
jksoft 24:6ba1245bf049 111 #endif /* MQTTPACKET_H_ */