Basic C library for MQTT packet serialization and deserialization
Dependents: MQTT MQTT MQTT MQTT ... more
Fork of MQTTPacket by
This library is part of the EclipseTM Paho project; specifically the embedded client.
A basic MQTT library in C for packet serialization and deserialization
Diff: MQTTConnect.h
- Revision:
- 22:1af97b41bc9d
- Parent:
- 20:63c71eeb4183
--- a/MQTTConnect.h Mon Aug 03 12:38:58 2015 +0000 +++ b/MQTTConnect.h Mon Sep 25 12:03:27 2017 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2015 IBM Corp. + * Copyright (c) 2014, 2017 IBM Corp. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -13,6 +13,8 @@ * Contributors: * Ian Craggs - initial API and implementation and/or initial documentation * Ian Craggs - add connack return code definitions + * Xiang Rong - 442039 Add makefile to Embedded C client + * Ian Craggs - fix for issue #64, bit order in connack response *******************************************************************************/ #ifndef MQTTCONNECT_H_ @@ -20,14 +22,21 @@ enum connack_return_codes { - MQTT_CONNECTION_ACCEPTED = 0, - MQTT_UNNACCEPTABLE_PROTOCOL = 1, - MQTT_CLIENTID_REJECTED = 2, - MQTT_SERVER_UNAVAILABLE = 3, - MQTT_BAD_USERNAME_OR_PASSWORD = 4, - MQTT_NOT_AUTHORIZED = 5, + MQTT_CONNECTION_ACCEPTED = 0, + MQTT_UNNACCEPTABLE_PROTOCOL = 1, + MQTT_CLIENTID_REJECTED = 2, + MQTT_SERVER_UNAVAILABLE = 3, + MQTT_BAD_USERNAME_OR_PASSWORD = 4, + MQTT_NOT_AUTHORIZED = 5, }; - + +#if !defined(DLLImport) + #define DLLImport +#endif +#if !defined(DLLExport) + #define DLLExport +#endif + typedef union { @@ -112,14 +121,14 @@ #if defined(REVERSED) struct { + unsigned int reserved : 7; /**< unused */ unsigned int sessionpresent : 1; /**< session present flag */ - unsigned int : y; /**< unused */ } bits; #else struct { - unsigned int : 7; /**< unused */ unsigned int sessionpresent : 1; /**< session present flag */ + unsigned int reserved: 7; /**< unused */ } bits; #endif } MQTTConnackFlags; /**< connack flags byte */ @@ -127,13 +136,14 @@ #define MQTTPacket_connectData_initializer { {'M', 'Q', 'T', 'C'}, 0, 4, {NULL, {0, NULL}}, 60, 1, 0, \ MQTTPacket_willOptions_initializer, {NULL, {0, NULL}}, {NULL, {0, NULL}} } -int MQTTSerialize_connect(unsigned char* buf, int buflen, MQTTPacket_connectData* options); -int MQTTDeserialize_connect(MQTTPacket_connectData* data, unsigned char* buf, int len); +DLLExport int MQTTSerialize_connect(unsigned char* buf, int buflen, MQTTPacket_connectData* options); +DLLExport int MQTTDeserialize_connect(MQTTPacket_connectData* data, unsigned char* buf, int len); -int MQTTSerialize_connack(unsigned char* buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent); -int MQTTDeserialize_connack(unsigned char* sessionPresent, unsigned char* connack_rc, unsigned char* buf, int buflen); +DLLExport int MQTTSerialize_connack(unsigned char* buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent); +DLLExport int MQTTDeserialize_connack(unsigned char* sessionPresent, unsigned char* connack_rc, unsigned char* buf, int buflen); -int MQTTSerialize_disconnect(unsigned char* buf, int buflen); -int MQTTSerialize_pingreq(unsigned char* buf, int buflen); +DLLExport int MQTTSerialize_disconnect(unsigned char* buf, int buflen); +DLLExport int MQTTSerialize_pingreq(unsigned char* buf, int buflen); #endif /* MQTTCONNECT_H_ */ +