summaryrefslogtreecommitdiff
path: root/FreeRTOS-Plus/Demo
diff options
context:
space:
mode:
authorGaurav Aggarwal <aggarg@amazon.com>2019-07-21 23:26:54 +0000
committerGaurav Aggarwal <aggarg@amazon.com>2019-07-21 23:26:54 +0000
commit06f9278de3ac2733a73f6e8f37fb37caa321bcdc (patch)
treeb716c858ecab08ff16b32ae442f9d911786f1128 /FreeRTOS-Plus/Demo
parenta7ef9c3b6149338f73998fa0ff1144191fb6b449 (diff)
downloadfreertos-git-06f9278de3ac2733a73f6e8f37fb37caa321bcdc.tar.gz
The MQTT example now works with the local MQTT broker.
It still needs to be tested with the public mosquitto broker.
Diffstat (limited to 'FreeRTOS-Plus/Demo')
-rw-r--r--FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/DemoTasks/SimpleMQTTExamples.c46
-rw-r--r--FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/WIN32.vcxproj2
2 files changed, 43 insertions, 5 deletions
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/DemoTasks/SimpleMQTTExamples.c b/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/DemoTasks/SimpleMQTTExamples.c
index d0c9e0b6e..648999eb6 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/DemoTasks/SimpleMQTTExamples.c
+++ b/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/DemoTasks/SimpleMQTTExamples.c
@@ -27,15 +27,15 @@
/* Standard inclues. */
#include <string.h>
+#include <stdio.h>
/* Kernel includes. */
#include "FreeRTOS.h"
#include "task.h"
-/* MQTT include. */
+/* IoT SDK includes. */
#include "iot_mqtt.h"
-
-/* Platform FreeRTOS network include. */
+#include "iot_taskpool.h"
#include "platform/iot_network_freertos.h"
/**
@@ -59,8 +59,9 @@
* @brief Details of the MQTT broker to connect to.
*
* @note This example does not use TLS and therefore won't work with AWS IoT.
+ *
*/
-#define mqttexampleMQTT_BROKER_ENDPOINT "10.60.214.105"
+#define mqttexampleMQTT_BROKER_ENDPOINT "test.mosquitto.org"
#define mqttexampleMQTT_BROKER_PORT 1883
/**
@@ -100,6 +101,32 @@
* @brief The MQTT connection handle used in this example.
*/
static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER;
+
+/**
+ * @brief Parameters used to create the system task pool.
+ */
+static const IotTaskPoolInfo_t xTaskPoolParameters = {
+ /* Minimum number of threads in a task pool.
+ * Note the slimmed down version of the task
+ * pool used by this library does not autoscale
+ * the number of tasks in the pool so in this
+ * case this sets the number of tasks in the
+ * pool. */
+ 2,
+ /* Maximum number of threads in a task pool.
+ * Note the slimmed down version of the task
+ * pool used by this library does not autoscale
+ * the number of tasks in the pool so in this
+ * case this parameter is just ignored. */
+ 2,
+ /* Stack size for every task pool thread - in
+ * bytes, hence multiplying by the number of bytes
+ * in a word as configMINIMAL_STACK_SIZE is
+ * specified in words. */
+ configMINIMAL_STACK_SIZE * sizeof( portSTACK_TYPE ),
+ /* Priority for every task pool thread. */
+ tskIDLE_PRIORITY,
+ };
/*-----------------------------------------------------------*/
/**
@@ -231,6 +258,10 @@ const TickType_t xNoDelay = ( TickType_t ) 0;
/* Remove compiler warnings about unused parameters. */
( void ) pvParameters;
+ /* The MQTT library needs a task pool, so create the system task pool. */
+ xResult = IotTaskPool_CreateSystemTaskPool( &( xTaskPoolParameters ) );
+ configASSERT( xResult == IOT_TASKPOOL_SUCCESS );
+
/* MQTT library must be initialized before it can be used. This is just one
* time initialization. */
xResult = IotMqtt_Init();
@@ -284,6 +315,13 @@ const TickType_t xNoDelay = ( TickType_t ) 0;
&( ulNotificationValue ), /* Obtain the notification value. */
pdMS_TO_TICKS( mqttexampleMQTT_TIMEOUT_MS ) );
configASSERT( ( ulNotificationValue & mqttexampleDISCONNECTED_BIT ) == mqttexampleDISCONNECTED_BIT );
+
+ printf( "prvMQTTDemoTask() completed an iteration without hitting an assert.\r\n" );
+ fflush( stdout );
+
+ /* Wait for some time between two iterations to ensure that we do not
+ * bombard the public test mosquitto broker. */
+ vTaskDelay( pdMS_TO_TICKS( 5000 ) );
}
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/WIN32.vcxproj b/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/WIN32.vcxproj
index 2c5202e2e..62df0590a 100644
--- a/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/WIN32.vcxproj
+++ b/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/WIN32.vcxproj
@@ -60,7 +60,7 @@
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\Source\FreeRTOS-Plus-IoT-SDK\c_sdk\standard\mqtt\include;..\..\..\Source\FreeRTOS-Plus-TCP\include;..\..\..\Source\FreeRTOS-Plus-TCP\portable\BufferManagement;..\..\..\Source\FreeRTOS-Plus-TCP\portable\Compiler\MSVC;.\DemoTasks\include;.\WinPCap;..\..\..\..\FreeRTOS\Source\include;..\..\..\..\FreeRTOS\Source\portable\MSVC-MingW;..\..\..\Source\FreeRTOS-Plus-IoT-SDK\c_sdk\standard\common\include\private;..\..\..\Source\FreeRTOS-Plus-IoT-SDK\c_sdk\standard\common\include;..\..\..\Source\FreeRTOS-Plus-IoT-SDK\abstractions\platform\include;..\..\..\Source\FreeRTOS-Plus-IoT-SDK\abstractions\platform\freertos\include;..\..\..\Source\FreeRTOS-Plus-IoT-SDK\abstractions\secure_sockets\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <MinimalRebuild>true</MinimalRebuild>
+ <MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeaderOutputFile>.\Debug/WIN32.pch</PrecompiledHeaderOutputFile>