Skip to content

Commit

Permalink
Merge pull request #155 from dgarske/release_v1.6
Browse files Browse the repository at this point in the history
wolfMQTT Release v1.6 preparation
  • Loading branch information
embhorn authored Apr 27, 2020
2 parents 7fb3d4c + 3c8d752 commit 423f243
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 31 deletions.
18 changes: 18 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@

## Release Notes

### v1.6 (04/24/2020)

* Fixes to improve buffer size checking when using a small tx or rx buffer. (PR #137)
* Fix for MQTT v5 issue with using wrong property free. (PR #152)
* Refactor of the thread locking to use binary semaphore, which resolves issue with thread synchronization. (PR #146)
* Improved multi-thread example exit (ctrl+c). Use internal pipe to wake "select()" and use semaphore signal to "wake" ping thread. (PR #146)
* Adjust multi-threading use case to use separate thread for ping keep-alive. (PR #146)
* Added simple standalone MQTT client example. (PR #138)
* Added include for "user_settings.h" when `WOLFMQTT_USER_SETTINGS` is defined. (PR #138)
* Added broker compatibility list (PR #145)
* Added protocol version API's. (PR #152)
* Added multithread example for Windows and Visual Studio. (PR #146)
* Made protocol level a run time option (PR #147)
* Remove obsolete "sched_yield" call. (PR #146)
* Remove deprecated call to `wolfSSL_set_using_nonblock()` (PR #148)
* Sync automake fixes from wolfSSL to wolfMQTT. (PR #150)
* Moved `MAX_PACKET_ID` to library. (PR #138)

### v1.4 (12/27/19)

* Fixes for non-blocking and multi-threading edge cases. (PR #130)
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# All right reserved.

AC_COPYRIGHT([Copyright (C) 2014-2020 wolfSSL Inc.])
AC_INIT([wolfmqtt],[1.4.0],[https://github.com/wolfssl/wolfMQTT/issues],[wolfmqtt],[http://www.wolfssl.com])
AC_INIT([wolfmqtt],[1.6.0],[https://github.com/wolfssl/wolfMQTT/issues],[wolfmqtt],[http://www.wolfssl.com])

AC_PREREQ([2.63])
AC_CONFIG_AUX_DIR([build-aux])
Expand All @@ -23,7 +23,7 @@ AC_ARG_PROGRAM
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([src/config.h])

WOLFMQTT_LIBRARY_VERSION=5:1:0
WOLFMQTT_LIBRARY_VERSION=6:0:0
# | | |
# +------+ | +---+
# | | |
Expand Down
4 changes: 2 additions & 2 deletions examples/mqttclient/mqttclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static int mqtt_property_cb(MqttClient *client, MqttProp *head, void *ctx)
PRINTF("Reason String: %s", prop->data_str.str);
break;

case MQTT_PROP_PLAYLOAD_FORMAT_IND:
case MQTT_PROP_PAYLOAD_FORMAT_IND:
case MQTT_PROP_MSG_EXPIRY_INTERVAL:
case MQTT_PROP_CONTENT_TYPE:
case MQTT_PROP_RESP_TOPIC:
Expand Down Expand Up @@ -428,7 +428,7 @@ int mqttclient_test(MQTTCtx *mqttCtx)
{
/* Payload Format Indicator */
MqttProp* prop = MqttClient_PropsAdd(&mqttCtx->publish.props);
prop->type = MQTT_PROP_PLAYLOAD_FORMAT_IND;
prop->type = MQTT_PROP_PAYLOAD_FORMAT_IND;
prop->data_int = 1;
}
{
Expand Down
8 changes: 4 additions & 4 deletions examples/multithread/multithread.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ static void *subscribe_task(void *param)
{
int rc = MQTT_CODE_SUCCESS;
uint16_t i;
MQTTCtx *mqttCtx = param;
MQTTCtx *mqttCtx = (MQTTCtx*)param;

/* Build list of topics */
XMEMSET(&mqttCtx->subscribe, 0, sizeof(MqttSubscribe));
Expand Down Expand Up @@ -375,7 +375,7 @@ static void *waitMessage_task(void *param)
#endif
{
int rc;
MQTTCtx *mqttCtx = param;
MQTTCtx *mqttCtx = (MQTTCtx*)param;

/* Read Loop */
PRINTF("MQTT Waiting for message...");
Expand Down Expand Up @@ -453,7 +453,7 @@ static void *publish_task(void *param)
{
int rc;
char buf[7];
MQTTCtx *mqttCtx = param;
MQTTCtx *mqttCtx = (MQTTCtx*)param;
MqttPublish publish;

/* Publish Topic */
Expand Down Expand Up @@ -485,7 +485,7 @@ static void *ping_task(void *param)
#endif
{
int rc;
MQTTCtx *mqttCtx = param;
MQTTCtx *mqttCtx = (MQTTCtx*)param;
MqttPing ping;

XMEMSET(&ping, 0, sizeof(ping));
Expand Down
30 changes: 17 additions & 13 deletions src/mqtt_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ static int MqttClient_WaitType(MqttClient *client, void *packet_obj,
MqttPacket_TypeDesc(wait_type), wait_type, wait_packet_id);
#endif

switch (*mms_stat)
switch ((int)*mms_stat)
{
case MQTT_MSG_BEGIN:
{
Expand Down Expand Up @@ -776,8 +776,8 @@ static int MqttClient_WaitType(MqttClient *client, void *packet_obj,
pendResp = NULL;
rc = wm_SemLock(&client->lockClient);
if (rc == 0) {
if (MqttClient_RespList_Find(client, wait_type, wait_packet_id,
&pendResp)) {
if (MqttClient_RespList_Find(client, (MqttPacketType)wait_type,
wait_packet_id, &pendResp)) {
if (pendResp->packetDone) {
/* pending response is already done, so return */
rc = pendResp->packet_ret;
Expand Down Expand Up @@ -2336,19 +2336,23 @@ static int SN_Client_WaitType(MqttClient *client, void* packet_obj,
{
int rc;
SN_MsgType packet_type;
word16 packet_id = 0;
MqttMsgStat* stat;
word16 packet_id;
MqttMsgStat* mms_stat;

if (client == NULL || packet_obj == NULL) {
return MQTT_CODE_ERROR_BAD_ARG;
}

/* all packet type structures must have MqttMsgStat at top */
stat = (MqttMsgStat*)packet_obj;
mms_stat = (MqttMsgStat*)packet_obj;

wait_again:

switch ((int)*stat)
/* initialize variables */
packet_id = 0;
packet_type = SN_MSG_TYPE_RESERVED;

switch ((int)*mms_stat)
{
case MQTT_MSG_BEGIN:
{
Expand All @@ -2366,7 +2370,7 @@ static int SN_Client_WaitType(MqttClient *client, void* packet_obj,
return rc;
}

*stat = MQTT_MSG_WAIT;
*mms_stat = MQTT_MSG_WAIT;
client->packet.buf_len = rc;

/* Decode header */
Expand All @@ -2380,15 +2384,15 @@ static int SN_Client_WaitType(MqttClient *client, void* packet_obj,
client->packet.buf_len, packet_type);
#endif

*stat = MQTT_MSG_READ;
*mms_stat = MQTT_MSG_READ;

FALL_THROUGH;
}

case MQTT_MSG_READ:
case MQTT_MSG_READ_PAYLOAD:
{
if (*stat == MQTT_MSG_READ_PAYLOAD) {
if (*mms_stat == MQTT_MSG_READ_PAYLOAD) {
packet_type = SN_MSG_TYPE_PUBLISH;
}
rc = SN_Client_HandlePacket(client, packet_type, packet_obj,
Expand All @@ -2405,7 +2409,7 @@ static int SN_Client_WaitType(MqttClient *client, void* packet_obj,
break;
}

*stat = MQTT_MSG_BEGIN;
*mms_stat = MQTT_MSG_BEGIN;
goto wait_again;
}

Expand All @@ -2416,15 +2420,15 @@ static int SN_Client_WaitType(MqttClient *client, void* packet_obj,
default:
{
#ifdef WOLFMQTT_DEBUG_CLIENT
PRINTF("SN_Client_WaitType: Invalid state %d!", *stat);
PRINTF("SN_Client_WaitType: Invalid state %d!", *mms_stat);
#endif
rc = MQTT_CODE_ERROR_STAT;
break;
}
} /* switch (msg->stat) */

/* reset state */
*stat = MQTT_MSG_BEGIN;
*mms_stat = MQTT_MSG_BEGIN;

return rc;
}
Expand Down
12 changes: 6 additions & 6 deletions src/mqtt_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct MqttPropMatrix {
};
static const struct MqttPropMatrix gPropMatrix[] = {
{ MQTT_PROP_NONE, MQTT_DATA_TYPE_NONE, 0 },
{ MQTT_PROP_PLAYLOAD_FORMAT_IND, MQTT_DATA_TYPE_BYTE,
{ MQTT_PROP_PAYLOAD_FORMAT_IND, MQTT_DATA_TYPE_BYTE,
(1 << MQTT_PACKET_TYPE_PUBLISH) },
{ MQTT_PROP_MSG_EXPIRY_INTERVAL, MQTT_DATA_TYPE_INT,
(1 << MQTT_PACKET_TYPE_PUBLISH) },
Expand Down Expand Up @@ -837,8 +837,8 @@ int MqttEncode_Publish(byte *tx_buf, int tx_buf_len, MqttPublish *publish,
tx_payload += MqttEncode_Vbi(tx_payload, props_len);

/* Encode properties */
tx_payload += MqttEncode_Props(publish->type, publish->props,
tx_payload);
tx_payload += MqttEncode_Props((MqttPacketType)publish->type,
publish->props, tx_payload);
}
#endif

Expand Down Expand Up @@ -912,8 +912,8 @@ int MqttDecode_Publish(byte *rx_buf, int rx_buf_len, MqttPublish *publish)
variable_len += tmp + props_len;
if (props_len > 0) {
/* Decode the Properties */
rx_payload += MqttDecode_Props(publish->type, &publish->props,
rx_payload, props_len);
rx_payload += MqttDecode_Props((MqttPacketType)publish->type,
&publish->props, rx_payload, props_len);
if (publish->props != NULL) {
/* Parse properties. */
}
Expand Down Expand Up @@ -1854,7 +1854,7 @@ int SN_Decode_Header(byte *rx_buf, int rx_buf_len,
}

/* Message Type */
packet_type = *rx_buf++;
packet_type = (SN_MsgType)*rx_buf++;

if (p_packet_type)
*p_packet_type = packet_type;
Expand Down
8 changes: 6 additions & 2 deletions wolfmqtt/mqtt_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ typedef enum MqttDataType {
/* PROPERTIES */
typedef enum MqttPropertyType {
MQTT_PROP_NONE = 0,
MQTT_PROP_PLAYLOAD_FORMAT_IND = 1,
MQTT_PROP_PAYLOAD_FORMAT_IND = 1,
MQTT_PROP_MSG_EXPIRY_INTERVAL = 2,
MQTT_PROP_CONTENT_TYPE = 3,
MQTT_PROP_RESP_TOPIC = 8,
Expand Down Expand Up @@ -92,6 +92,9 @@ typedef enum MqttPropertyType {
MQTT_PROP_TYPE_MAX = 0xFF
} MqttPropertyType;

/* backwards compatibility for anyone using the typo name */
#define MQTT_PROP_PLAYLOAD_FORMAT_IND MQTT_PROP_PAYLOAD_FORMAT_IND

struct _MqttProp_Str {
word16 len;
char *str;
Expand Down Expand Up @@ -759,8 +762,9 @@ typedef enum _SN_MsgType {
SN_MSG_TYPE_WILLMSGUPD = 0x1C,
SN_MSG_TYPE_WILLMSGRESP = 0x1D,
/* 0x1E - 0xFD reserved */
SN_MSG_TYPE_ENCAPMSG = 0xFE /* Encapsulated message */
SN_MSG_TYPE_ENCAPMSG = 0xFE, /* Encapsulated message */
/* 0xFF reserved */
SN_MSG_TYPE_RESERVED = 0xFF
} SN_MsgType;

/* Topic ID types */
Expand Down
4 changes: 2 additions & 2 deletions wolfmqtt/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
extern "C" {
#endif

#define LIBWOLFMQTT_VERSION_STRING "1.4.0"
#define LIBWOLFMQTT_VERSION_HEX 0x01004000
#define LIBWOLFMQTT_VERSION_STRING "1.6.0"
#define LIBWOLFMQTT_VERSION_HEX 0x01006000

#ifdef __cplusplus
}
Expand Down

0 comments on commit 423f243

Please sign in to comment.