diff --git a/examples/aws/awsiot.c b/examples/aws/awsiot.c index cd77c3807..09c3a05ad 100644 --- a/examples/aws/awsiot.c +++ b/examples/aws/awsiot.c @@ -60,7 +60,9 @@ static int mTestDone = 0; #define APP_HARDWARE "wolf_aws_iot_demo" #define APP_FIRMWARE_VERSION LIBWOLFMQTT_VERSION_STRING +#ifndef MAX_BUFFER_SIZE #define MAX_BUFFER_SIZE 512 /* Maximum size for network read/write callbacks */ +#endif #define AWSIOT_HOST "a2dujmi05ideo2-ats.iot.us-west-2.amazonaws.com" #define AWSIOT_DEVICE_ID "demoDevice" #define AWSIOT_QOS MQTT_QOS_1 diff --git a/examples/azure/azureiothub.c b/examples/azure/azureiothub.c index 463e67256..dc8205b65 100644 --- a/examples/azure/azureiothub.c +++ b/examples/azure/azureiothub.c @@ -76,7 +76,9 @@ static int mTestDone = 0; * https://azure.microsoft.com/en-us/documentation/articles/iot-hub-sas-tokens/#using-sas-tokens-as-a-device * https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support */ +#ifndef MAX_BUFFER_SIZE #define MAX_BUFFER_SIZE 1024 /* Maximum size for network read/write callbacks */ +#endif #define AZURE_API_VERSION "?api-version=2018-06-30" #define AZURE_HOST "wolfMQTT.azure-devices.net" #define AZURE_DEVICE_ID "demoDevice" diff --git a/examples/firmware/fwclient.c b/examples/firmware/fwclient.c index 351eaf4b4..22259fd8d 100644 --- a/examples/firmware/fwclient.c +++ b/examples/firmware/fwclient.c @@ -55,7 +55,9 @@ #include "examples/mqttnet.h" /* Configuration */ +#ifndef MAX_BUFFER_SIZE #define MAX_BUFFER_SIZE FIRMWARE_MAX_PACKET +#endif /* Locals */ static int mStopRead = 0; diff --git a/examples/firmware/fwpush.c b/examples/firmware/fwpush.c index 7b2ee2ad6..676ee95e7 100644 --- a/examples/firmware/fwpush.c +++ b/examples/firmware/fwpush.c @@ -56,7 +56,9 @@ #include "examples/mqttnet.h" /* Configuration */ +#ifndef MAX_BUFFER_SIZE #define MAX_BUFFER_SIZE FIRMWARE_MAX_PACKET +#endif /* Locals */ static int mStopRead = 0; diff --git a/examples/mqttclient/mqttclient.c b/examples/mqttclient/mqttclient.c index 8c65813a2..e390b94b7 100644 --- a/examples/mqttclient/mqttclient.c +++ b/examples/mqttclient/mqttclient.c @@ -34,7 +34,9 @@ static int mStopRead = 0; /* Maximum size for network read/write callbacks. There is also a v5 define that describes the max MQTT control packet size, DEFAULT_MAX_PKT_SZ. */ +#ifndef MAX_BUFFER_SIZE #define MAX_BUFFER_SIZE 1024 +#endif #ifdef WOLFMQTT_PROPERTY_CB #define MAX_CLIENT_ID_LEN 64 @@ -504,6 +506,8 @@ int mqttclient_test(MQTTCtx *mqttCtx) if ((mqttCtx->pub_file) && (mqttCtx->publish.buffer)) { WOLFMQTT_FREE(mqttCtx->publish.buffer); + mqttCtx->publish.buffer = NULL; + mqttCtx->pub_file = NULL; /* don't try and send file again */ } PRINTF("MQTT Publish: Topic %s, %s (%d)", diff --git a/examples/multithread/multithread.c b/examples/multithread/multithread.c index 4114d4549..da4939802 100644 --- a/examples/multithread/multithread.c +++ b/examples/multithread/multithread.c @@ -42,7 +42,9 @@ /* Maximum size for network read/write callbacks. There is also a v5 define that describes the max MQTT control packet size, DEFAULT_MAX_PKT_SZ. */ +#ifndef MAX_BUFFER_SIZE #define MAX_BUFFER_SIZE 1024 +#endif /* Total size of test message to build */ #define TEST_MESSAGE_SIZE 1048 /* span more than one max packet */ diff --git a/examples/nbclient/nbclient.c b/examples/nbclient/nbclient.c index cf337310d..ed438aa89 100644 --- a/examples/nbclient/nbclient.c +++ b/examples/nbclient/nbclient.c @@ -38,7 +38,9 @@ static int mTestDone = 0; /* Configuration */ /* Maximum size for network read/write callbacks. */ +#ifndef MAX_BUFFER_SIZE #define MAX_BUFFER_SIZE 1024 +#endif #ifdef WOLFMQTT_PROPERTY_CB #define MAX_CLIENT_ID_LEN 64 @@ -444,6 +446,8 @@ int mqttclient_test(MQTTCtx *mqttCtx) if ((mqttCtx->pub_file) && (mqttCtx->publish.buffer)) { WOLFMQTT_FREE(mqttCtx->publish.buffer); + mqttCtx->publish.buffer = NULL; + mqttCtx->pub_file = NULL; /* don't try and send file again */ } PRINTF("MQTT Publish: Topic %s, %s (%d)", diff --git a/examples/pub-sub/mqtt-pub.c b/examples/pub-sub/mqtt-pub.c index 467fccee5..b6d220d39 100644 --- a/examples/pub-sub/mqtt-pub.c +++ b/examples/pub-sub/mqtt-pub.c @@ -30,8 +30,10 @@ /* Configuration */ /* Maximum size for network read/write callbacks. There is also a v5 define that - describes the max MQTT control packet size, DEFAULT_MAX_PKT_SZ. */ + * describes the max MQTT control packet size, DEFAULT_MAX_PKT_SZ. */ +#ifndef MAX_BUFFER_SIZE #define MAX_BUFFER_SIZE 1024 +#endif #ifdef WOLFMQTT_PROPERTY_CB #define MAX_CLIENT_ID_LEN 64 @@ -381,6 +383,8 @@ int pub_client(MQTTCtx *mqttCtx) if ((mqttCtx->pub_file) && (mqttCtx->publish.buffer)) { WOLFMQTT_FREE(mqttCtx->publish.buffer); + mqttCtx->publish.buffer = NULL; + mqttCtx->pub_file = NULL; /* don't try and send file again */ } if (mqttCtx->debug_on) { PRINTF("MQTT Publish: Topic %s, %s (%d)", diff --git a/examples/pub-sub/mqtt-sub.c b/examples/pub-sub/mqtt-sub.c index cbace383c..84d791e10 100644 --- a/examples/pub-sub/mqtt-sub.c +++ b/examples/pub-sub/mqtt-sub.c @@ -33,8 +33,10 @@ static int mStopRead = 0; /* Configuration */ /* Maximum size for network read/write callbacks. There is also a v5 define that - describes the max MQTT control packet size, DEFAULT_MAX_PKT_SZ. */ + * describes the max MQTT control packet size, DEFAULT_MAX_PKT_SZ. */ +#ifndef MAX_BUFFER_SIZE #define MAX_BUFFER_SIZE 1024 +#endif #ifdef WOLFMQTT_PROPERTY_CB #define MAX_CLIENT_ID_LEN 64 diff --git a/examples/sn-client/sn-client.c b/examples/sn-client/sn-client.c index e60c1f5af..15b5a9bf1 100644 --- a/examples/sn-client/sn-client.c +++ b/examples/sn-client/sn-client.c @@ -36,7 +36,9 @@ static int mStopRead = 0; /* Configuration */ /* Maximum size for network read/write callbacks. */ +#ifndef MAX_BUFFER_SIZE #define MAX_BUFFER_SIZE 1024 +#endif #define TEST_MESSAGE "test" #define SHORT_TOPIC_NAME "s1" @@ -215,11 +217,11 @@ int sn_test(MQTTCtx *mqttCtx) /* Send Connect and wait for Connect Ack */ rc = SN_Client_Connect(&mqttCtx->client, connect); - if (rc != MQTT_CODE_SUCCESS) { - PRINTF("MQTT-SN Connect: %s (%d)", - MqttClient_ReturnCodeToString(rc), rc); - goto disconn; - } + if (rc != MQTT_CODE_SUCCESS) { + PRINTF("MQTT-SN Connect: %s (%d)", + MqttClient_ReturnCodeToString(rc), rc); + goto disconn; + } /* Validate Connect Ack info */ PRINTF("....MQTT-SN Connect Ack: Return Code %u", diff --git a/examples/sn-client/sn-client_qos-1.c b/examples/sn-client/sn-client_qos-1.c index cee87110a..ed57b09b2 100644 --- a/examples/sn-client/sn-client_qos-1.c +++ b/examples/sn-client/sn-client_qos-1.c @@ -40,7 +40,9 @@ static int mStopRead = 0; /* Configuration */ /* Maximum size for network read/write callbacks. */ +#ifndef MAX_BUFFER_SIZE #define MAX_BUFFER_SIZE 1024 +#endif #define TEST_MESSAGE "QoS-1 test message" char SHORT_TOPIC_NAME[] = {1}; diff --git a/examples/sn-client/sn-multithread.c b/examples/sn-client/sn-multithread.c index 4e7d934ee..7ca310201 100644 --- a/examples/sn-client/sn-multithread.c +++ b/examples/sn-client/sn-multithread.c @@ -36,7 +36,9 @@ /* Configuration */ /* Maximum size for network read/write callbacks. */ +#ifndef MAX_BUFFER_SIZE #define MAX_BUFFER_SIZE 1024 +#endif #define TEST_MESSAGE "test00" /* Number of publish tasks. Each will send a unique message to the broker. */ #define NUM_PUB_TASKS 10 diff --git a/examples/wiot/wiot.c b/examples/wiot/wiot.c index 9c4e59da8..96b6348cc 100644 --- a/examples/wiot/wiot.c +++ b/examples/wiot/wiot.c @@ -41,7 +41,9 @@ static int mStopRead = 0; static int mTestDone = 0; /* Configuration */ +#ifndef MAX_BUFFER_SIZE #define MAX_BUFFER_SIZE 1024 /* Maximum size for network read/write callbacks */ +#endif /* Undefine if using an IBM WIOT Platform account that you created. */ #define WIOT_USE_QUICKSTART