From 14b1d77bfb4aa1b8a75ef514b9491bc4a3f5da48 Mon Sep 17 00:00:00 2001 From: David Garske Date: Wed, 7 Nov 2018 09:05:40 -0800 Subject: [PATCH] Release prep for v1.2 release (#97) * Release prep for v1.2 release. Fixes for some minor build warnings. Fix to ensure all ./configure options populate into `wolmqtt/options.h`. Fix for sn-client to build correctly without WOLMQTT_SN defined. Added VS project for sn-client. Added new Visual Studio settings file at `wolfmqtt/vs_settings.h`. * Remove execute bit on code files. --- README.md | 35 +++++- configure.ac | 10 +- examples/aws/awsiot.c | 0 examples/aws/awsiot.h | 0 examples/aws/awsiot.vcxproj | 12 +- examples/azure/azureiothub.c | 2 +- examples/azure/azureiothub.h | 0 examples/azure/azureiothub.vcxproj | 12 +- examples/firmware/firmware.h | 0 examples/firmware/fwclient.c | 2 +- examples/firmware/fwclient.h | 0 examples/firmware/fwclient.vcxproj | 12 +- examples/firmware/fwpush.c | 2 +- examples/firmware/fwpush.h | 0 examples/firmware/fwpush.vcxproj | 12 +- examples/include.am | 3 +- examples/mqttclient/mqttclient.c | 4 +- examples/mqttclient/mqttclient.h | 0 examples/mqttclient/mqttclient.vcxproj | 12 +- examples/mqttnet.c | 2 +- examples/mqttuart.c | 0 examples/nbclient/nbclient.h | 0 examples/nbclient/nbclient.vcxproj | 9 +- examples/sn-client/sn-client.c | 16 ++- examples/sn-client/sn-client.h | 0 examples/sn-client/sn-client.vcxproj | 152 +++++++++++++++++++++++++ examples/wiot/wiot.vcxproj | 62 +++++----- src/mqtt_client.c | 10 +- src/mqtt_packet.c | 72 ++++++++++-- wolfmqtt.sln | 10 ++ wolfmqtt.vcxproj | 14 +-- wolfmqtt/include.am | 3 +- wolfmqtt/mqtt_types.h | 15 +++ wolfmqtt/version.h | 4 +- wolfmqtt/visibility.h | 0 wolfmqtt/vs_settings.h | 53 +++++++++ 36 files changed, 433 insertions(+), 107 deletions(-) mode change 100755 => 100644 examples/aws/awsiot.c mode change 100755 => 100644 examples/aws/awsiot.h mode change 100755 => 100644 examples/azure/azureiothub.c mode change 100755 => 100644 examples/azure/azureiothub.h mode change 100755 => 100644 examples/firmware/firmware.h mode change 100755 => 100644 examples/firmware/fwclient.c mode change 100755 => 100644 examples/firmware/fwclient.h mode change 100755 => 100644 examples/firmware/fwpush.h mode change 100755 => 100644 examples/mqttclient/mqttclient.h mode change 100755 => 100644 examples/mqttnet.c mode change 100755 => 100644 examples/mqttuart.c mode change 100755 => 100644 examples/nbclient/nbclient.h mode change 100755 => 100644 examples/sn-client/sn-client.h create mode 100644 examples/sn-client/sn-client.vcxproj mode change 100755 => 100644 src/mqtt_packet.c mode change 100644 => 100755 wolfmqtt/mqtt_types.h mode change 100755 => 100644 wolfmqtt/visibility.h create mode 100644 wolfmqtt/vs_settings.h diff --git a/README.md b/README.md index 0f6c5e36d..543d5f08b 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ This is an implementation of the MQTT Client written in C for embedded use, whic 1. `./autogen.sh` (if cloned from GitHub) 2. `./configure` (to see a list of build options use `./configure --help`) 3. `make` +4. `sudo make install` If `wolfssl` was recently installed run `sudo ldconfig` to update the linker cache. @@ -29,7 +30,8 @@ For building wolfMQTT with TLS support in Visual Studio: 6. Open the `/wolfmqtt.sln` solution. 7. Make sure you have the same architecture (`x86` or `x64` selected) as used in wolfSSL above. 8. By default the include path for the wolfssl headers is `./../wolfssl/`. If your wolfssl root location is different you can go into the project settings and adjust this in `C/C++` -> `General` -> `Additional Include Directories`. -9. Build the wolfMQTT solution. +9. Configure your Visual Studio build settings using `wolfmqtt/vs_settings.h`. +10. Build the wolfMQTT solution. ### Arduino @@ -120,10 +122,21 @@ We setup an AWS IoT endpoint and testing device certificate for testing. The AWS ### Watson IoT Example This example enables the wolfMQTT client to connect to the IBM Watson Internet of Things (WIOT) Platform. The WIOT Platform has a limited test broker called "Quickstart" that allows non-secure connections to exercise the component. The example is located in `/examples/wiot/`. Works with MQTT v5 support enabled. -### Mqtt-SN Example +### MQTT-SN Example The Sensor Network client implements the MQTT-SN protocol for low-bandwidth networks. There are several differences from MQTT, including the ability to use a two byte Topic ID instead the full topic during subscribe and publish. The SN client requires an MQTT-SN gateway. The gateway acts as an intermediary between the SN clients and the broker. This client was tested with the Eclipse Paho MQTT-SN Gateway, which connects by default to the public Eclipse broker, much like our wolfMQTT Client example. The address of the gateway must be configured as the host. The example is located in `/examples/sn-client/`. -## v5.0 Specification Support + +## Specification Support + +### MQTT v3.1.1 Specification Support + +The initially supported version with full specification support for all features and packets type such as: +* QoS 0-2 +* Last Will and Testament (LWT) +* Client examples for: AWS, Azure IoT, IBM Watson, Firmware update, non-blocking and generic. + +### MQTT v5.0 Specification Support + The wolfMQTT client supports connecting to v5 enabled brokers when configured with the `--enable-mqtt5` option. Handling properties received from the server is accomplished via a callback when the `--enable-propcb` option is set. The following v5.0 specification features are supported by the wolfMQTT client: * AUTH packet * User properties @@ -149,7 +162,8 @@ The v5 enabled wolfMQTT client was tested with the following MQTT v5 brokers: * Watson IoT Quickserver ** `./examples/wiot/wiot` -## Sensor Network Specification Support +### MQTT Sensor Network (MQTT-SN) Specification Support + The wolfMQTT SN Client implementation is based on the OASIS MQTT-SN v1.2 specification. The SN API is configured with the `--enable-sn` option. There is a separate API for the sensor network API, which all begin with the "SN_" prefix. The wolfMQTT SN Client operates over UDP, which is distinct from the wolfMQTT clients that use TCP. The following features are supported by the wolfMQTT SN Client: * Register * Will topic and message set up @@ -163,8 +177,21 @@ Unsupported features: The SN client was tested using the Eclipse Paho MQTT-SN Gateway (https://github.com/eclipse/paho.mqtt-sn.embedded-c) running locally and on a separate network node. Instructions for building and running the gateway are in the project README. + ## Release Notes +### v1.2 (11/07/18) + +* Added MQTT Sensor Network (SN) client support (`--enable-sn` or `WOLFMQTT_SN`). (PR #96) +* Added MQTT v5.0 support with (`--enable-mqtt5` or `WOLFMQTT_V5`). (PR #87) +* Added property callback support (MQTT v5.0 only). Enabled with `--enable-propcb` or `WOLFMQTT_PROPERTY_CB`). (PR #87) +* Fix for Harmony NetConnect function incorrectly checking `EWOULDBLOCK`. Fixes issue #88. (PR #89) +* Fix to reset the TLS ctx and ssl pointers when they have been free'd. (PR #85) +* Add way to pass custom context to the wolfMQTT TLS verify callback example `mqtt_tls_verify_cb`. PR #94) +* Create nonblocking mqttclient example `./examples/nbclient/nbclient`. (PR #93) +* Add support for publishing in smaller chunks using new API `MqttClient_Publish_ex`. (PR #92) +* Added simplified Microchip Harmony wolfMQTT network callback example. (PR #83) + ### v1.1 (06/21/18) * Fixed case when `use_tls` was requested but TLS feature not compiled in. (PR #57) * Fixed non-blocking issue that caused out of buffer error if not all of packet were received. (PR #65) diff --git a/configure.ac b/configure.ac index f2519baf5..d450cc392 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ # All right reserved. AC_COPYRIGHT([Copyright (C) 2014-2018 wolfSSL Inc.]) -AC_INIT([wolfmqtt],[1.1.0],[https://github.com/wolfssl/wolfMQTT/issues],[wolfmqtt],[http://www.wolfssl.com]) +AC_INIT([wolfmqtt],[1.2.0],[https://github.com/wolfssl/wolfMQTT/issues],[wolfmqtt],[http://www.wolfssl.com]) AC_PREREQ([2.63]) AC_CONFIG_AUX_DIR([build-aux]) @@ -23,7 +23,7 @@ AC_ARG_PROGRAM AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADERS([src/config.h]) -WOLFMQTT_LIBRARY_VERSION=3:0:0 +WOLFMQTT_LIBRARY_VERSION=4:0:0 # | | | # +------+ | +---+ # | | | @@ -190,7 +190,7 @@ AC_ARG_ENABLE([sn], if test "x$ENABLED_SN" = "xyes" then - AM_CPPFLAGS="$AM_CPPFLAGS -DWOLFMQTT_SN" + AM_CFLAGS="$AM_CFLAGS -DWOLFMQTT_SN" fi AM_CONDITIONAL([BUILD_SN], [test "x$ENABLED_SN" = "xyes"]) @@ -204,7 +204,7 @@ AC_ARG_ENABLE([mqtt5], if test "x$ENABLED_MQTTV50" = "xyes" then - AM_CPPFLAGS="$AM_CPPFLAGS -DWOLFMQTT_V5" + AM_CFLAGS="$AM_CFLAGS -DWOLFMQTT_V5" fi AM_CONDITIONAL([BUILD_MQTT5], [test "x$ENABLED_MQTTV50" = "xyes"]) @@ -222,7 +222,7 @@ then then AC_MSG_ERROR([cannot enable propcb without enabling mqtt5.]) fi - AM_CPPFLAGS="$AM_CPPFLAGS -DWOLFMQTT_PROPERTY_CB" + AM_CFLAGS="$AM_CFLAGS -DWOLFMQTT_PROPERTY_CB" fi diff --git a/examples/aws/awsiot.c b/examples/aws/awsiot.c old mode 100755 new mode 100644 diff --git a/examples/aws/awsiot.h b/examples/aws/awsiot.h old mode 100755 new mode 100644 diff --git a/examples/aws/awsiot.vcxproj b/examples/aws/awsiot.vcxproj index 4d0d7b537..ceaf3c6fb 100755 --- a/examples/aws/awsiot.vcxproj +++ b/examples/aws/awsiot.vcxproj @@ -79,8 +79,8 @@ Level3 Disabled true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS - ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) + _MBCS;%(PreprocessorDefinitions) + ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) true @@ -92,8 +92,8 @@ Level3 Disabled true - ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) + _MBCS;%(PreprocessorDefinitions) true @@ -107,7 +107,7 @@ true true true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + _MBCS;%(PreprocessorDefinitions) true @@ -122,7 +122,7 @@ true true true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + _MBCS;%(PreprocessorDefinitions) true diff --git a/examples/azure/azureiothub.c b/examples/azure/azureiothub.c old mode 100755 new mode 100644 index 56ce0f10a..c7c8af24d --- a/examples/azure/azureiothub.c +++ b/examples/azure/azureiothub.c @@ -347,7 +347,7 @@ int azureiothub_test(MQTTCtx *mqttCtx) /* Authentication */ mqttCtx->connect.username = AZURE_USERNAME; - mqttCtx->connect.password = mqttCtx->app_ctx; + mqttCtx->connect.password = (const char *)mqttCtx->app_ctx; FALL_THROUGH; } diff --git a/examples/azure/azureiothub.h b/examples/azure/azureiothub.h old mode 100755 new mode 100644 diff --git a/examples/azure/azureiothub.vcxproj b/examples/azure/azureiothub.vcxproj index cabb970bf..2b6ae0013 100755 --- a/examples/azure/azureiothub.vcxproj +++ b/examples/azure/azureiothub.vcxproj @@ -79,8 +79,8 @@ Level3 Disabled true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS - ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) + _MBCS;%(PreprocessorDefinitions) + ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) true @@ -92,8 +92,8 @@ Level3 Disabled true - ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) + _MBCS;%(PreprocessorDefinitions) true @@ -107,7 +107,7 @@ true true true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + _MBCS;%(PreprocessorDefinitions) true @@ -122,7 +122,7 @@ true true true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + _MBCS;%(PreprocessorDefinitions) true diff --git a/examples/firmware/firmware.h b/examples/firmware/firmware.h old mode 100755 new mode 100644 diff --git a/examples/firmware/fwclient.c b/examples/firmware/fwclient.c old mode 100755 new mode 100644 index 16ca3bf78..fbc83f924 --- a/examples/firmware/fwclient.c +++ b/examples/firmware/fwclient.c @@ -162,7 +162,7 @@ static int mqtt_message_cb(MqttClient *client, MqttMessage *msg, /* Verify this message is for the firmware topic */ if (msg_new && - memcmp(msg->topic_name, FIRMWARE_TOPIC_NAME, + XMEMCMP(msg->topic_name, FIRMWARE_TOPIC_NAME, msg->topic_name_len) == 0 && !mFwBuf) { diff --git a/examples/firmware/fwclient.h b/examples/firmware/fwclient.h old mode 100755 new mode 100644 diff --git a/examples/firmware/fwclient.vcxproj b/examples/firmware/fwclient.vcxproj index 301ff2de7..592c340c1 100755 --- a/examples/firmware/fwclient.vcxproj +++ b/examples/firmware/fwclient.vcxproj @@ -79,8 +79,8 @@ Level3 Disabled true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS - ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) + _MBCS;%(PreprocessorDefinitions) + ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) true @@ -92,8 +92,8 @@ Level3 Disabled true - ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) + _MBCS;%(PreprocessorDefinitions) true @@ -107,7 +107,7 @@ true true true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + _MBCS;%(PreprocessorDefinitions) true @@ -122,7 +122,7 @@ true true true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + _MBCS;%(PreprocessorDefinitions) true diff --git a/examples/firmware/fwpush.c b/examples/firmware/fwpush.c index 606e56981..28e1db83c 100644 --- a/examples/firmware/fwpush.c +++ b/examples/firmware/fwpush.c @@ -440,7 +440,7 @@ int fwpush_test(MQTTCtx *mqttCtx) mqttCtx->publish.topic_name = mqttCtx->topic_name; mqttCtx->publish.packet_id = mqtt_get_packetid(); mqttCtx->publish.buffer_len = FIRMWARE_MAX_BUFFER; - mqttCtx->publish.buffer = WOLFMQTT_MALLOC(FIRMWARE_MAX_BUFFER); + mqttCtx->publish.buffer = (byte*)WOLFMQTT_MALLOC(FIRMWARE_MAX_BUFFER); /* Calculate the total payload length and store the FirmwareHeader, signature, and key in publish->ctx to be used by the callback. diff --git a/examples/firmware/fwpush.h b/examples/firmware/fwpush.h old mode 100755 new mode 100644 diff --git a/examples/firmware/fwpush.vcxproj b/examples/firmware/fwpush.vcxproj index cd66f05fc..8aff02bf2 100755 --- a/examples/firmware/fwpush.vcxproj +++ b/examples/firmware/fwpush.vcxproj @@ -79,8 +79,8 @@ Level3 Disabled true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS - ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) + _MBCS;%(PreprocessorDefinitions) + ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) true @@ -92,8 +92,8 @@ Level3 Disabled true - ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) + _MBCS;%(PreprocessorDefinitions) true @@ -107,7 +107,7 @@ true true true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + _MBCS;%(PreprocessorDefinitions) true @@ -122,7 +122,7 @@ true true true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + _MBCS;%(PreprocessorDefinitions) true diff --git a/examples/include.am b/examples/include.am index bac18d142..74af8439a 100644 --- a/examples/include.am +++ b/examples/include.am @@ -123,4 +123,5 @@ EXTRA_DIST+= examples/mqttuart.c \ examples/firmware/fwpush.vcxproj \ examples/azure/azureiothub.vcxproj \ examples/aws/awsiot.vcxproj \ - examples/wiot/wiot.vcxproj + examples/wiot/wiot.vcxproj \ + examples/sn-client/sn-client.vcxproj diff --git a/examples/mqttclient/mqttclient.c b/examples/mqttclient/mqttclient.c index a7270e845..0983e5710 100644 --- a/examples/mqttclient/mqttclient.c +++ b/examples/mqttclient/mqttclient.c @@ -307,7 +307,7 @@ int mqttclient_test(MQTTCtx *mqttCtx) MqttProp* prop = MqttClient_PropsAdd(&mqttCtx->connect.props); prop->type = MQTT_PROP_AUTH_METHOD; prop->data_str.str = (char*)DEFAULT_AUTH_METHOD; - prop->data_str.len = XSTRLEN(prop->data_str.str); + prop->data_str.len = (word16)XSTRLEN(prop->data_str.str); } { /* Request Response Information */ @@ -432,7 +432,7 @@ int mqttclient_test(MQTTCtx *mqttCtx) MqttProp* prop = MqttClient_PropsAdd(&mqttCtx->publish.props); prop->type = MQTT_PROP_CONTENT_TYPE; prop->data_str.str = (char*)"wolf_type"; - prop->data_str.len = XSTRLEN(prop->data_str.str); + prop->data_str.len = (word16)XSTRLEN(prop->data_str.str); } if ((mqttCtx->topic_alias_max > 0) && (mqttCtx->topic_alias > 0) && diff --git a/examples/mqttclient/mqttclient.h b/examples/mqttclient/mqttclient.h old mode 100755 new mode 100644 diff --git a/examples/mqttclient/mqttclient.vcxproj b/examples/mqttclient/mqttclient.vcxproj index 23214f57c..bad7d3b3a 100755 --- a/examples/mqttclient/mqttclient.vcxproj +++ b/examples/mqttclient/mqttclient.vcxproj @@ -79,8 +79,8 @@ Level3 Disabled true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS - ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) + _MBCS;%(PreprocessorDefinitions) + ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) true @@ -92,8 +92,8 @@ Level3 Disabled true - ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS + ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) + _MBCS;%(PreprocessorDefinitions) true @@ -107,7 +107,7 @@ true true true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS + _MBCS;%(PreprocessorDefinitions) true @@ -122,7 +122,7 @@ true true true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS + _MBCS;%(PreprocessorDefinitions) true diff --git a/examples/mqttnet.c b/examples/mqttnet.c old mode 100755 new mode 100644 index d0a68a6f4..e1d7f8b2f --- a/examples/mqttnet.c +++ b/examples/mqttnet.c @@ -717,7 +717,7 @@ static int SN_NetConnect(void *context, const char* host, word16 port, /* Show error */ if (rc != 0) { - close(sock->fd); + SOCK_CLOSE(sock->fd); PRINTF("NetConnect: Rc=%d, SoErr=%d", rc, so_error); } diff --git a/examples/mqttuart.c b/examples/mqttuart.c old mode 100755 new mode 100644 diff --git a/examples/nbclient/nbclient.h b/examples/nbclient/nbclient.h old mode 100755 new mode 100644 diff --git a/examples/nbclient/nbclient.vcxproj b/examples/nbclient/nbclient.vcxproj index b9a7c8dd0..669a15da9 100644 --- a/examples/nbclient/nbclient.vcxproj +++ b/examples/nbclient/nbclient.vcxproj @@ -81,7 +81,7 @@ Disabled true true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS + _MBCS;%(PreprocessorDefinitions) ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) @@ -96,7 +96,7 @@ true true ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS + _MBCS;%(PreprocessorDefinitions) true @@ -141,6 +141,11 @@ + + + {d42405ee-238f-4560-8b49-e70948ec9100} + + diff --git a/examples/sn-client/sn-client.c b/examples/sn-client/sn-client.c index 0ea36fb97..ff99b4f62 100644 --- a/examples/sn-client/sn-client.c +++ b/examples/sn-client/sn-client.c @@ -26,6 +26,8 @@ #include "wolfmqtt/mqtt_client.h" +#ifdef WOLFMQTT_SN + #include "sn-client.h" #include "examples/mqttnet.h" @@ -33,11 +35,11 @@ static int mStopRead = 0; /* Configuration */ - /* Maximum size for network read/write callbacks. */ #define MAX_BUFFER_SIZE 1024 #define TEST_MESSAGE "test" + static int sn_message_cb(MqttClient *client, MqttMessage *msg, byte msg_new, byte msg_done) { @@ -284,6 +286,9 @@ int sn_test(MQTTCtx *mqttCtx) PRINTF("MQTT-SN Publish: topic id = %d, msg = \"%s\", rc = %d", (word16)*mqttCtx->publish.topic_name, mqttCtx->publish.buffer, mqttCtx->publish.return_code); + if (rc != MQTT_CODE_SUCCESS) { + break; + } } } #endif @@ -361,6 +366,7 @@ int sn_test(MQTTCtx *mqttCtx) return rc; } +#endif /* WOLFMQTT_SN */ /* so overall tests can pull in test function */ #if !defined(NO_MAIN_DRIVER) && !defined(MICROCHIP_MPLAB_HARMONY) @@ -390,7 +396,7 @@ int sn_test(MQTTCtx *mqttCtx) int main(int argc, char** argv) { int rc; -#ifndef WOLFMQTT_NONBLOCK +#ifdef WOLFMQTT_SN MQTTCtx mqttCtx; /* init defaults */ @@ -419,14 +425,14 @@ int main(int argc, char** argv) } #endif -#ifndef WOLFMQTT_NONBLOCK +#ifdef WOLFMQTT_SN rc = sn_test(&mqttCtx); #else (void)argc; (void)argv; - /* This example requires non-blocking mode to be disabled - ./configure --disable-nonblock */ + /* This example requires MQTT-SN mode to be enabled + ./configure --enable-sn */ PRINTF("Example not compiled in!"); rc = EXIT_FAILURE; #endif diff --git a/examples/sn-client/sn-client.h b/examples/sn-client/sn-client.h old mode 100755 new mode 100644 diff --git a/examples/sn-client/sn-client.vcxproj b/examples/sn-client/sn-client.vcxproj new file mode 100644 index 000000000..051d8d4bc --- /dev/null +++ b/examples/sn-client/sn-client.vcxproj @@ -0,0 +1,152 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {CBA36D33-BBC1-458B-BDB5-E8A4FEBE6A8C} + sn-client + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + false + v141 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + $(Configuration)\$(ProjectName)\ + + + $(Platform)\$(Configuration)\$(ProjectName)\ + + + + Level3 + Disabled + true + true + _MBCS;%(PreprocessorDefinitions) + ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) + + + Ws2_32.lib;$(SolutionDir)wolfssl.lib;%(AdditionalDependencies) + true + + + + + Level3 + Disabled + true + true + ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) + _MBCS;%(PreprocessorDefinitions) + + + true + Ws2_32.lib;$(SolutionDir)wolfssl.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + + + + + + + + + + + + + {d42405ee-238f-4560-8b49-e70948ec9100} + + + + + + \ No newline at end of file diff --git a/examples/wiot/wiot.vcxproj b/examples/wiot/wiot.vcxproj index 99d9b0724..c8bc6119b 100755 --- a/examples/wiot/wiot.vcxproj +++ b/examples/wiot/wiot.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -21,32 +21,32 @@ {CDC51BE2-B7AB-4E17-9B5D-68820411E6CD} WatsonIoT - 8.1 - - - - Application - true - v140 - MultiByte - - - Application - false - v140 - true - MultiByte - - - Application - true - v140 - MultiByte - - - Application - false - v140 + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 true MultiByte @@ -79,7 +79,7 @@ Level3 Disabled true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + _MBCS;%(PreprocessorDefinitions) ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) @@ -93,7 +93,7 @@ Disabled true ..\..\;..\..\..\wolfssl;%(AdditionalIncludeDirectories) - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + _MBCS;%(PreprocessorDefinitions) true @@ -107,7 +107,7 @@ true true true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + _MBCS;%(PreprocessorDefinitions) true @@ -122,7 +122,7 @@ true true true - _MBCS;%(PreprocessorDefinitions);ENABLE_MQTT_TLS;_CRT_SECURE_NO_WARNINGS + _MBCS;%(PreprocessorDefinitions) true diff --git a/src/mqtt_client.c b/src/mqtt_client.c index 936176fa2..6f8ec32ce 100644 --- a/src/mqtt_client.c +++ b/src/mqtt_client.c @@ -1046,12 +1046,12 @@ int MqttClient_Auth(MqttClient *client, MqttAuth* auth) MqttProp* MqttClient_PropsAdd(MqttProp **head) { - return(MqttProps_Add(head)); + return MqttProps_Add(head); } void MqttClient_PropsFree(MqttProp *head) { - return(MqttProps_Free(head)); + MqttProps_Free(head); } #endif /* WOLFMQTT_V5 */ @@ -1380,6 +1380,9 @@ static int SN_Client_WaitType(MqttClient *client, MqttMessage* msg, goto wait_again; } + #ifdef WOLFMQTT_V5 + case MQTT_MSG_AUTH: + #endif case MQTT_MSG_WRITE: default: { @@ -1693,6 +1696,9 @@ int SN_Client_Publish(MqttClient *client, SN_Publish *publish) break; } + #ifdef WOLFMQTT_V5 + case MQTT_MSG_AUTH: + #endif case MQTT_MSG_READ: case MQTT_MSG_READ_PAYLOAD: #ifdef WOLFMQTT_DEBUG_CLIENT diff --git a/src/mqtt_packet.c b/src/mqtt_packet.c old mode 100755 new mode 100644 index 57fefc5c7..056aaa472 --- a/src/mqtt_packet.c +++ b/src/mqtt_packet.c @@ -760,6 +760,8 @@ int MqttDecode_ConnectAck(byte *rx_buf, int rx_buf_len, #endif } + (void)rx_payload; + /* Return total length of packet */ return header_len + remain_len; } @@ -961,7 +963,6 @@ int MqttEncode_PublishResp(byte* tx_buf, int tx_buf_len, byte type, /* Encode variable header */ tx_payload += MqttEncode_Num(&tx_buf[header_len], publish_resp->packet_id); - (void)tx_payload; #ifdef WOLFMQTT_V5 if ((publish_resp->reason_code != MQTT_REASON_SUCCESS) || @@ -979,6 +980,8 @@ int MqttEncode_PublishResp(byte* tx_buf, int tx_buf_len, byte type, } #endif + (void)tx_payload; + /* Return total length of packet */ return header_len + remain_len; } @@ -1339,6 +1342,8 @@ int MqttEncode_Disconnect(byte *tx_buf, int tx_buf_len, /* Encode properties */ tx_payload += MqttEncode_Props(MQTT_PACKET_TYPE_CONNECT, disconnect->props, tx_payload); + + (void)tx_payload; } #else (void)disconnect; @@ -1382,6 +1387,9 @@ int MqttDecode_Disconnect(byte *rx_buf, int rx_buf_len, MqttDisconnect *disc) } } } + + (void)rx_payload; + /* Return total length of packet */ return header_len + remain_len; } @@ -1433,6 +1441,7 @@ int MqttEncode_Auth(byte *tx_buf, int tx_buf_len, MqttAuth *auth) return MQTT_CODE_ERROR_MALFORMED_DATA; } + (void)tx_payload; /* Return total length of packet */ return header_len + remain_len; @@ -1492,6 +1501,8 @@ int MqttDecode_Auth(byte *rx_buf, int rx_buf_len, MqttAuth *auth) return MQTT_CODE_ERROR_MALFORMED_DATA; } + (void)rx_payload; + /* Return total length of packet */ return header_len + remain_len; } @@ -1724,6 +1735,7 @@ int SN_Decode_Advertise(byte *rx_buf, int rx_buf_len, SN_Advertise *gw_info) rx_payload += MqttDecode_Num(rx_payload, &gw_info->duration); } + (void)rx_payload; /* Return total length of packet */ return total_len; @@ -1750,6 +1762,7 @@ int SN_Encode_SearchGW(byte *tx_buf, int tx_buf_len, byte hops) /* Encode radius */ *tx_payload++ = hops; + (void)tx_payload; /* Return total length of packet */ return total_len; @@ -1794,6 +1807,7 @@ int SN_Decode_GWInfo(byte *rx_buf, int rx_buf_len, SN_GwInfo *gw_info) XMEMCPY(gw_info->gwAddr, rx_payload, total_len - 3); } } + (void)rx_payload; /* Return total length of packet */ return total_len; @@ -1816,7 +1830,7 @@ int SN_Encode_Connect(byte *tx_buf, int tx_buf_len, SN_Connect *connect) total_len = 6; /* Len + Message Type + Flags + ProtocolID + Duration(2) */ /* Client ID size */ - id_len = (int)XSTRLEN(connect->client_id); + id_len = (word16)XSTRLEN(connect->client_id); id_len = (id_len <= SN_CLIENTID_MAX_LEN) ? id_len : SN_CLIENTID_MAX_LEN; total_len += id_len; @@ -1831,7 +1845,7 @@ int SN_Encode_Connect(byte *tx_buf, int tx_buf_len, SN_Connect *connect) /* Encode length */ if (total_len <= SN_PACKET_MAX_SMALL_SIZE) { - *tx_payload++ = total_len; + *tx_payload++ = (byte)total_len; } else { *tx_payload++ = SN_PACKET_LEN_IND; @@ -1858,6 +1872,8 @@ int SN_Encode_Connect(byte *tx_buf, int tx_buf_len, SN_Connect *connect) /* Encode Client ID */ XMEMCPY(tx_payload, connect->client_id, id_len); + tx_payload += id_len; + (void)tx_payload; /* Return total length of packet */ return total_len; @@ -1883,6 +1899,7 @@ int SN_Decode_WillTopicReq(byte *rx_buf, int rx_buf_len) if (type != SN_MSG_TYPE_WILLTOPICREQ) { return MQTT_CODE_ERROR_PACKET_TYPE; } + (void)rx_payload; /* Return total length of packet */ return total_len; @@ -1938,6 +1955,8 @@ int SN_Encode_WillTopic(byte *tx_buf, int tx_buf_len, SN_Will *willTopic) *tx_payload++ = SN_MSG_TYPE_WILLTOPIC; if (willTopic != NULL) { + int will_len; + /* Encode flags */ flags |= ((willTopic->qos << SN_PACKET_FLAG_QOS_SHIFT) & SN_PACKET_FLAG_QOS_MASK); @@ -1945,8 +1964,11 @@ int SN_Encode_WillTopic(byte *tx_buf, int tx_buf_len, SN_Will *willTopic) *tx_payload++ = flags; /* Encode Will Topic */ - XMEMCPY(tx_payload, willTopic->willTopic, XSTRLEN(willTopic->willTopic)); + will_len = (int)XSTRLEN(willTopic->willTopic); + XMEMCPY(tx_payload, willTopic->willTopic, will_len); + tx_payload += will_len; } + (void)tx_payload; return total_len; } @@ -1974,6 +1996,7 @@ int SN_Decode_WillMsgReq(byte *rx_buf, int rx_buf_len) if (type != SN_MSG_TYPE_WILLMSGREQ) { return MQTT_CODE_ERROR_PACKET_TYPE; } + (void)rx_payload; /* Return total length of packet */ return total_len; @@ -2022,6 +2045,8 @@ int SN_Encode_WillMsg(byte *tx_buf, int tx_buf_len, SN_Will *willMsg) /* Encode Will Message */ XMEMCPY(tx_payload, willMsg->willMsg, willMsg->willMsgLen); + tx_payload += willMsg->willMsgLen; + (void)tx_payload; return total_len; } @@ -2073,6 +2098,8 @@ int SN_Encode_WillTopicUpdate(byte *tx_buf, int tx_buf_len, SN_Will *willTopic) *tx_payload++ = SN_MSG_TYPE_WILLTOPICUPD; if (willTopic != NULL) { + int will_len; + /* Encode flags */ flags |= ((willTopic->qos << SN_PACKET_FLAG_QOS_SHIFT) & SN_PACKET_FLAG_QOS_MASK); @@ -2080,8 +2107,11 @@ int SN_Encode_WillTopicUpdate(byte *tx_buf, int tx_buf_len, SN_Will *willTopic) *tx_payload++ = flags; /* Encode Will Topic */ - XMEMCPY(tx_payload, willTopic->willTopic, XSTRLEN(willTopic->willTopic)); + will_len = (int)XSTRLEN(willTopic->willTopic); + XMEMCPY(tx_payload, willTopic->willTopic, will_len); + tx_payload += will_len; } + (void)tx_payload; return total_len; @@ -2107,6 +2137,7 @@ int SN_Decode_WillTopicResponse(byte *rx_buf, int rx_buf_len) if (type != SN_MSG_TYPE_WILLTOPICRESP) { return MQTT_CODE_ERROR_PACKET_TYPE; } + (void)rx_payload; /* Return total length of packet */ return total_len; @@ -2155,6 +2186,8 @@ int SN_Encode_WillMsgUpdate(byte *tx_buf, int tx_buf_len, SN_Will *willMsg) /* Encode Will Message */ XMEMCPY(tx_payload, willMsg->willMsg, willMsg->willMsgLen); + tx_payload += willMsg->willMsgLen; + (void)tx_payload; return total_len; } @@ -2179,6 +2212,7 @@ int SN_Decode_WillMsgResponse(byte *rx_buf, int rx_buf_len) if (type != SN_MSG_TYPE_WILLMSGRESP) { return MQTT_CODE_ERROR_PACKET_TYPE; } + (void)rx_payload; /* Return total length of packet */ return total_len; @@ -2210,6 +2244,7 @@ int SN_Decode_ConnectAck(byte *rx_buf, int rx_buf_len, if (connect_ack) { connect_ack->return_code = *rx_payload++; } + (void)rx_payload; /* Return total length of packet */ return total_len; @@ -2217,7 +2252,7 @@ int SN_Decode_ConnectAck(byte *rx_buf, int rx_buf_len, int SN_Encode_Register(byte *tx_buf, int tx_buf_len, SN_Register *regist) { - int total_len; + int total_len, topic_len; byte *tx_payload; /* Validate required arguments */ @@ -2263,7 +2298,10 @@ int SN_Encode_Register(byte *tx_buf, int tx_buf_len, SN_Register *regist) tx_payload += MqttEncode_Num(tx_payload, regist->packet_id); /* Encode Topic Name */ - XMEMCPY(tx_payload, regist->topicName, XSTRLEN(regist->topicName)); + topic_len = (int)XSTRLEN(regist->topicName); + XMEMCPY(tx_payload, regist->topicName, topic_len); + tx_payload += topic_len; + (void)tx_payload; return total_len; } @@ -2299,6 +2337,7 @@ int SN_Decode_RegAck(byte *rx_buf, int rx_buf_len, SN_RegAck *regack) /* Decode return code */ regack->return_code = *rx_payload++; } + (void)rx_payload; /* Return total length of packet */ return total_len; @@ -2370,12 +2409,12 @@ int SN_Encode_Subscribe(byte *tx_buf, int tx_buf_len, SN_Subscribe *subscribe) /* Topic name is a string */ XMEMCPY(tx_payload, subscribe->topicNameId, XSTRLEN(subscribe->topicNameId)); } - else - { + else { /* Topic ID */ tx_payload += MqttEncode_Num(tx_payload, (word16)subscribe->topicNameId[0]); } + (void)tx_payload; /* Return total length of packet */ return total_len; @@ -2410,6 +2449,7 @@ int SN_Decode_SubscribeAck(byte* rx_buf, int rx_buf_len, rx_payload += MqttDecode_Num(rx_payload, &subscribe_ack->packet_id); subscribe_ack->return_code = *rx_payload++; } + (void)rx_payload; /* Return total length of packet */ return total_len; @@ -2444,7 +2484,7 @@ int SN_Encode_Publish(byte *tx_buf, int tx_buf_len, MqttPublish *publish) /* Encode header */ if (total_len <= SN_PACKET_MAX_SMALL_SIZE) { - *tx_payload++ = total_len; + *tx_payload++ = (byte)total_len; } else { *tx_payload++ = SN_PACKET_LEN_IND; @@ -2469,6 +2509,9 @@ int SN_Encode_Publish(byte *tx_buf, int tx_buf_len, MqttPublish *publish) /* Encode payload */ XMEMCPY(tx_payload, publish->buffer, publish->total_len); + tx_payload += publish->total_len; + + (void)tx_payload; /* Return length of packet placed into tx_buf */ return total_len; @@ -2515,7 +2558,7 @@ int SN_Decode_Publish(byte *rx_buf, int rx_buf_len, MqttPublish *publish) /* Set flags */ publish->duplicate = flags & SN_PACKET_FLAG_DUPLICATE; - publish->qos = (flags >> SN_PACKET_FLAG_QOS_SHIFT) & SN_PACKET_FLAG_QOS_MASK; + publish->qos = (MqttQoS)((flags >> SN_PACKET_FLAG_QOS_SHIFT) & SN_PACKET_FLAG_QOS_MASK); publish->retain = flags & SN_PACKET_FLAG_RETAIN; @@ -2563,6 +2606,7 @@ int SN_Encode_PublishResp(byte* tx_buf, int tx_buf_len, byte type, if (type == SN_MSG_TYPE_PUBACK) { *tx_payload++ = publish_resp->return_code; } + (void)tx_payload; /* Return total length of packet */ return total_len; @@ -2604,6 +2648,7 @@ int SN_Decode_PublishResp(byte* rx_buf, int rx_buf_len, byte type, publish_resp->return_code = *rx_payload++; } } + (void)rx_payload; /* Return total length of packet */ return total_len; @@ -2679,6 +2724,7 @@ int SN_Encode_Unsubscribe(byte *tx_buf, int tx_buf_len, tx_payload += MqttEncode_Num(tx_payload, (word16)unsubscribe->topicNameId[0]); } + (void)tx_payload; /* Return total length of packet */ return total_len; @@ -2710,6 +2756,7 @@ int SN_Decode_UnsubscribeAck(byte *rx_buf, int rx_buf_len, if (unsubscribe_ack) { rx_payload += MqttDecode_Num(rx_payload, &unsubscribe_ack->packet_id); } + (void)rx_payload; /* Return total length of packet */ return total_len; @@ -2742,6 +2789,7 @@ int SN_Encode_Disconnect(byte *tx_buf, int tx_buf_len, if ((disconnect != NULL) && (disconnect->sleepTmr > 0)) { tx_payload += MqttEncode_Num(tx_payload, disconnect->sleepTmr); } + (void)tx_payload; /* Return total length of packet */ return total_len; @@ -2771,7 +2819,9 @@ int SN_Encode_Ping(byte *tx_buf, int tx_buf_len, SN_PingReq *ping) if (clientId_len > 0) { XMEMCPY(tx_payload, ping->clientId, clientId_len); + tx_payload += clientId_len; } + (void)tx_payload; /* Return total length of packet */ return total_len; diff --git a/wolfmqtt.sln b/wolfmqtt.sln index 302a219ea..1fa757067 100755 --- a/wolfmqtt.sln +++ b/wolfmqtt.sln @@ -22,6 +22,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wiot", "examples\wiot\wiot. EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nbclient", "examples\nbclient\nbclient.vcxproj", "{9BD647D2-683B-4BBD-97F9-C19EB2851FE3}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sn-client", "examples\sn-client\sn-client.vcxproj", "{CBA36D33-BBC1-458B-BDB5-E8A4FEBE6A8C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -94,6 +96,14 @@ Global {9BD647D2-683B-4BBD-97F9-C19EB2851FE3}.Release|x64.Build.0 = Release|x64 {9BD647D2-683B-4BBD-97F9-C19EB2851FE3}.Release|x86.ActiveCfg = Release|Win32 {9BD647D2-683B-4BBD-97F9-C19EB2851FE3}.Release|x86.Build.0 = Release|Win32 + {CBA36D33-BBC1-458B-BDB5-E8A4FEBE6A8C}.Debug|x64.ActiveCfg = Debug|x64 + {CBA36D33-BBC1-458B-BDB5-E8A4FEBE6A8C}.Debug|x64.Build.0 = Debug|x64 + {CBA36D33-BBC1-458B-BDB5-E8A4FEBE6A8C}.Debug|x86.ActiveCfg = Debug|Win32 + {CBA36D33-BBC1-458B-BDB5-E8A4FEBE6A8C}.Debug|x86.Build.0 = Debug|Win32 + {CBA36D33-BBC1-458B-BDB5-E8A4FEBE6A8C}.Release|x64.ActiveCfg = Release|x64 + {CBA36D33-BBC1-458B-BDB5-E8A4FEBE6A8C}.Release|x64.Build.0 = Release|x64 + {CBA36D33-BBC1-458B-BDB5-E8A4FEBE6A8C}.Release|x86.ActiveCfg = Release|Win32 + {CBA36D33-BBC1-458B-BDB5-E8A4FEBE6A8C}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/wolfmqtt.vcxproj b/wolfmqtt.vcxproj index c101eb370..ec429b286 100755 --- a/wolfmqtt.vcxproj +++ b/wolfmqtt.vcxproj @@ -25,7 +25,7 @@ - DynamicLibrary + DynamicLibrary true v140 MultiByte @@ -80,12 +80,12 @@ Disabled true .;./../wolfssl/;%(AdditionalIncludeDirectories) - BUILDING_WOLFMQTT;ENABLE_MQTT_TLS;_WINDLL;%(PreprocessorDefinitions) + BUILDING_WOLFMQTT;_WINDLL;%(PreprocessorDefinitions) true Ws2_32.lib;wolfssl.lib;%(AdditionalDependencies) - Windows + Windows @@ -94,12 +94,12 @@ Disabled true .;./../wolfssl/;%(AdditionalIncludeDirectories) - BUILDING_WOLFMQTT;ENABLE_MQTT_TLS;_WINDLL;%(PreprocessorDefinitions) + BUILDING_WOLFMQTT;_WINDLL;%(PreprocessorDefinitions) true Ws2_32.lib;wolfssl.lib;%(AdditionalDependencies) - Windows + Windows @@ -110,7 +110,7 @@ true true .;./../wolfssl/;%(AdditionalIncludeDirectories) - BUILDING_WOLFMQTT;ENABLE_MQTT_TLS;%(PreprocessorDefinitions) + BUILDING_WOLFMQTT;%(PreprocessorDefinitions) true @@ -127,7 +127,7 @@ true true .;./../wolfssl/;%(AdditionalIncludeDirectories) - BUILDING_WOLFMQTT;ENABLE_MQTT_TLS;;%(PreprocessorDefinitions) + BUILDING_WOLFMQTT;%(PreprocessorDefinitions) true diff --git a/wolfmqtt/include.am b/wolfmqtt/include.am index a97690651..0096389b2 100644 --- a/wolfmqtt/include.am +++ b/wolfmqtt/include.am @@ -9,4 +9,5 @@ nobase_include_HEADERS+= \ wolfmqtt/mqtt_packet.h \ wolfmqtt/mqtt_socket.h \ wolfmqtt/visibility.h \ - wolfmqtt/options.h + wolfmqtt/options.h \ + wolfmqtt/vs_settings.h diff --git a/wolfmqtt/mqtt_types.h b/wolfmqtt/mqtt_types.h old mode 100644 new mode 100755 index 1febdd1f1..6a2a4bf38 --- a/wolfmqtt/mqtt_types.h +++ b/wolfmqtt/mqtt_types.h @@ -69,6 +69,14 @@ #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0501 #endif + + /* Allow "unsafe" strncpy */ + #ifndef _CRT_SECURE_NO_WARNINGS + #define _CRT_SECURE_NO_WARNINGS + #endif + + /* Visual Studio build settings from wolfmqtt/vs_settings.h */ + #include "wolfmqtt/vs_settings.h" #endif #ifndef WOLFMQTT_NO_STDIO @@ -115,6 +123,7 @@ enum MqttPacketResponseCodes { /* Standard wrappers */ #ifndef WOLFMQTT_CUSTOM_STRING #include + #ifndef XSTRLEN #define XSTRLEN(s1) strlen((s1)) #endif @@ -124,12 +133,18 @@ enum MqttPacketResponseCodes { #ifndef XSTRNCMP #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n)) #endif + #ifndef XSTRNCPY + #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n)) + #endif #ifndef XMEMCPY #define XMEMCPY(d,s,l) memcpy((d),(s),(l)) #endif #ifndef XMEMSET #define XMEMSET(b,c,l) memset((b),(c),(l)) #endif + #ifndef XMEMCMP + #define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n)) + #endif #ifndef XATOI #define XATOI(s) atoi((s)) #endif diff --git a/wolfmqtt/version.h b/wolfmqtt/version.h index 7c766ae1e..e3e54c1f7 100644 --- a/wolfmqtt/version.h +++ b/wolfmqtt/version.h @@ -34,8 +34,8 @@ extern "C" { #endif -#define LIBWOLFMQTT_VERSION_STRING "1.1.0" -#define LIBWOLFMQTT_VERSION_HEX 0x01001000 +#define LIBWOLFMQTT_VERSION_STRING "1.2.0" +#define LIBWOLFMQTT_VERSION_HEX 0x01002000 #ifdef __cplusplus } diff --git a/wolfmqtt/visibility.h b/wolfmqtt/visibility.h old mode 100755 new mode 100644 diff --git a/wolfmqtt/vs_settings.h b/wolfmqtt/vs_settings.h new file mode 100644 index 000000000..5ee7b2d29 --- /dev/null +++ b/wolfmqtt/vs_settings.h @@ -0,0 +1,53 @@ +/* Template build settings for Visual Studio projects */ +/* This is meant to be customized */ + +#ifndef _WOLFMQTT_VS_SETTINGS_ +#define _WOLFMQTT_VS_SETTINGS_ + + +/* TLS Support */ +#undef ENABLE_MQTT_TLS +#define ENABLE_MQTT_TLS + +/* MQTT-SN Support */ +#undef WOLFMQTT_SN +#define WOLFMQTT_SN + +/* MQTT v5.0 support */ +#undef WOLFMQTT_V5 +#define WOLFMQTT_V5 + +/* Enable property callback support */ +#ifdef WOLFMQTT_V5 + #undef WOLFMQTT_PROPERTY_CB + #define WOLFMQTT_PROPERTY_CB +#endif + +/* Non-blocking support */ +#undef WOLFMQTT_NONBLOCK +#define WOLFMQTT_NONBLOCK + +/* Disable socket timeout code */ +#undef WOLFMQTT_NO_TIMEOUT +//#define WOLFMQTT_NO_TIMEOUT + +/* Disconnect callback support */ +#undef WOLFMQTT_DISCONNECT_CB +#define WOLFMQTT_DISCONNECT_CB + +/* Debugging */ +#undef DEBUG_WOLFMQTT +#define DEBUG_WOLFMQTT + +#undef WOLFMQTT_DEBUG_CLIENT +#define WOLFMQTT_DEBUG_CLIENT + +#undef WOLFMQTT_DEBUG_SOCKET +#define WOLFMQTT_DEBUG_SOCKET + +/* Disable error strings */ +#undef WOLFMQTT_NO_ERROR_STRINGS +//#define WOLFMQTT_NO_ERROR_STRINGS + + +#endif /* _WOLFMQTT_VS_SETTINGS_ */