mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-18 09:08:33 -04:00
Continued to work on the MQTT demo project.
A few review comments added into the MQTT implementation.
This commit is contained in:
parent
53842d4cac
commit
fe4511b35e
21 changed files with 244 additions and 166 deletions
|
@ -140,31 +140,31 @@ static void prvMQTTDemoTask( void *pvParameters );
|
|||
/**
|
||||
* @brief The callback invoked by the MQTT library when the MQTT connection gets
|
||||
* disconnected.
|
||||
*
|
||||
*
|
||||
* @param[in] pvCallbackContext Callback context as provided at the time of
|
||||
* connect.
|
||||
* @param[in] pxCallbackParams Contains the reason why the MQTT connection was
|
||||
* disconnected.
|
||||
*/
|
||||
static void prvExample_DisconnectCallback( void * pvCallbackContext,
|
||||
IotMqttCallbackParam_t * pxCallbackParams );
|
||||
static void prvExample_OnDisconnect( void * pvCallbackContext,
|
||||
IotMqttCallbackParam_t * pxCallbackParams );
|
||||
|
||||
/**
|
||||
* @brief The callback invoked by the MQTT library when a message is received on
|
||||
* a subscribed topic from the MQTT broker.
|
||||
*
|
||||
*
|
||||
* @param[in] pvCallbackContext Callback context as provided at the time of
|
||||
* subscribe.
|
||||
* @param[in] pxCallbackParams Contain the details about the received message -
|
||||
* @param[in] pxCallbackParams Contain the details about the received message -
|
||||
* topic on which the message was received, the received message.
|
||||
*/
|
||||
static void prvExample_PublishCallback( void * pvCallbackContext,
|
||||
IotMqttCallbackParam_t * pxCallbackParams );
|
||||
static void prvExample_OnMessageReceived( void * pvCallbackContext,
|
||||
IotMqttCallbackParam_t * pxCallbackParams );
|
||||
|
||||
/**
|
||||
* @brief Connects to the MQTT broker as specified in mqttexampleMQTT_BROKER_ENDPOINT
|
||||
* and mqttexampleMQTT_BROKER_PORT.
|
||||
*
|
||||
*
|
||||
* @note This example does not use TLS and therefore will not work with MQTT.
|
||||
*/
|
||||
static void prvMQTTConnect( void );
|
||||
|
@ -191,7 +191,7 @@ static void prvMQTTUnsubscribe( void );
|
|||
static void prvMQTTDisconnect( void );
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvExample_DisconnectCallback( void * pvCallbackContext,
|
||||
static void prvExample_OnDisconnect( void * pvCallbackContext,
|
||||
IotMqttCallbackParam_t * pxCallbackParams )
|
||||
{
|
||||
TaskHandle_t xDemoTaskHandle = ( TaskHandle_t ) pvCallbackContext;
|
||||
|
@ -207,7 +207,7 @@ TaskHandle_t xDemoTaskHandle = ( TaskHandle_t ) pvCallbackContext;
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvExample_PublishCallback( void * pvCallbackContext,
|
||||
static void prvExample_OnMessageReceived( void * pvCallbackContext,
|
||||
IotMqttCallbackParam_t * pxCallbackParams )
|
||||
{
|
||||
TaskHandle_t xDemoTaskHandle = ( TaskHandle_t ) pvCallbackContext;
|
||||
|
@ -227,6 +227,12 @@ TaskHandle_t xDemoTaskHandle = ( TaskHandle_t ) pvCallbackContext;
|
|||
/* Ensure that the message QoS is as expected. */
|
||||
configASSERT( pxCallbackParams->u.message.info.qos == IOT_MQTT_QOS_1 );
|
||||
|
||||
/* Although this print uses the constants rather than the data from the
|
||||
message payload the asserts above have already checked the message payload
|
||||
equals the constants, and it is more efficient not to have to worry about
|
||||
lengths in the print. */
|
||||
configPRINTF( ( "Received %s from topic %s\r\n", mqttexampleMESSAGE, mqttexampleTOPIC ) );
|
||||
|
||||
/* Inform the demo task about the message received from the MQTT broker. */
|
||||
xTaskNotify( xDemoTaskHandle,
|
||||
mqttexampleMESSAGE_RECEIVED_BIT,
|
||||
|
@ -252,7 +258,8 @@ void vStartSimpleMQTTDemo( void )
|
|||
static void prvMQTTDemoTask( void *pvParameters )
|
||||
{
|
||||
IotMqttError_t xResult;
|
||||
uint32_t ulNotificationValue = 0;
|
||||
uint32_t ulNotificationValue = 0, ulIterations;
|
||||
const uint32_t ulMaxIterations = 5UL;
|
||||
const TickType_t xNoDelay = ( TickType_t ) 0;
|
||||
|
||||
/* Remove compiler warnings about unused parameters. */
|
||||
|
@ -272,55 +279,77 @@ const TickType_t xNoDelay = ( TickType_t ) 0;
|
|||
/* Don't expect any notifications to be pending yet. */
|
||||
configASSERT( ulTaskNotifyTake( pdTRUE, xNoDelay ) == 0 );
|
||||
|
||||
|
||||
/******************** CONNECT ****************************************/
|
||||
|
||||
/* Establish a connection to the MQTT broker. This example connects to
|
||||
* the MQTT broker as specified in mqttexampleMQTT_BROKER_ENDPOINT and
|
||||
* mqttexampleMQTT_BROKER_PORT at the top of this file. Please change
|
||||
* it to the MQTT broker you want to connect to. Note that this example
|
||||
* does not use TLS and therefore will not work with AWS IoT. */
|
||||
prvMQTTConnect();
|
||||
configPRINTF( ( "Connected to %s\r\n", mqttexampleMQTT_BROKER_ENDPOINT ) );
|
||||
|
||||
/* Subscribe to the topic as specified in mqttexampleTOPIC at the top
|
||||
* of this file. */
|
||||
|
||||
/******************* SUBSCRIBE ***************************************/
|
||||
|
||||
/* The client is now connected to the broker. Subscribe to the topic
|
||||
as specified in mqttexampleTOPIC at the top of this file. This client
|
||||
will then publish to the same topic it subscribed to, so will expect
|
||||
all the messages it sends to the broker to be sent back to it from the
|
||||
broker. */
|
||||
prvMQTTSubscribe();
|
||||
configPRINTF( ( "Subscribed to %s\r\n", mqttexampleTOPIC ) );
|
||||
|
||||
/* Publish a message on the mqttexampleTOPIC topic as specified at the
|
||||
* top of this file. */
|
||||
prvMQTTPublish();
|
||||
|
||||
/* Since we are subscribed on the same topic, we will get the same
|
||||
* message back from the MQTT broker. Wait for the message to be
|
||||
* received which is informed to us by the publish callback
|
||||
* (prvExample_PublishCallback) by setting the mqttexampleMESSAGE_RECEIVED_BIT
|
||||
* in this task's notification value. */
|
||||
xTaskNotifyWait( 0UL, /* Don't clear any bits on entry. */
|
||||
0UL, /* Don't clear any bits on exit. */
|
||||
&( ulNotificationValue ), /* Obtain the notification value. */
|
||||
pdMS_TO_TICKS( mqttexampleMQTT_TIMEOUT_MS ) );
|
||||
configASSERT( ( ulNotificationValue & mqttexampleMESSAGE_RECEIVED_BIT ) == mqttexampleMESSAGE_RECEIVED_BIT );
|
||||
/******************* PUBLISH 5 TIMES *********************************/
|
||||
|
||||
/* Unsubscribe from the topic mqttexampleTOPIC. */
|
||||
/* Publish a few messages while connected. */
|
||||
for( ulIterations = 0; ulIterations < ulMaxIterations; ulIterations++ )
|
||||
{
|
||||
/* Publish a message on the mqttexampleTOPIC topic as specified at the
|
||||
* top of this file. */
|
||||
prvMQTTPublish();
|
||||
configPRINTF( ( "Published %s to %s\r\n", mqttexampleMESSAGE, mqttexampleTOPIC ) );
|
||||
|
||||
/* Since we are subscribed on the same topic, we will get the same
|
||||
* message back from the MQTT broker. Wait for the message to be
|
||||
* received which is informed to us by the publish callback
|
||||
* (prvExample_OnMessageReceived) by setting the
|
||||
* mqttexampleMESSAGE_RECEIVED_BIT in this task's notification
|
||||
value. */
|
||||
xTaskNotifyWait( 0UL, /* Don't clear any bits on entry. */
|
||||
mqttexampleMESSAGE_RECEIVED_BIT, /* Clear bit on exit. */
|
||||
&( ulNotificationValue ), /* Obtain the notification value. */
|
||||
pdMS_TO_TICKS( mqttexampleMQTT_TIMEOUT_MS ) );
|
||||
configASSERT( ( ulNotificationValue & mqttexampleMESSAGE_RECEIVED_BIT ) == mqttexampleMESSAGE_RECEIVED_BIT );
|
||||
}
|
||||
|
||||
|
||||
/******************* UNSUBSCRIBE AND DISCONNECT **********************/
|
||||
|
||||
/* Unsubscribe from the topic mqttexampleTOPIC the disconnect
|
||||
gracefully. */
|
||||
prvMQTTUnsubscribe();
|
||||
|
||||
/* Gracefully disconnect from the MQTT broker by sending an MQTT
|
||||
* DISCONNECT message. */
|
||||
prvMQTTDisconnect();
|
||||
configPRINTF( ( "Disconnected from from %s\r\n\r\n", mqttexampleMQTT_BROKER_ENDPOINT ) );
|
||||
|
||||
/* Wait for the disconnect operation to complete which is informed to us
|
||||
* by the disconnect callback (prvExample_DisconnectCallback)by setting
|
||||
* by the disconnect callback (prvExample_OnDisconnect)by setting
|
||||
* the mqttexampleDISCONNECTED_BIT in this task's notification value.
|
||||
* Note that all bits are cleared in the task's notification value to
|
||||
* ensure that it is ready for the next run. */
|
||||
xTaskNotifyWait( 0UL, /* Don't clear any bits on entry. */
|
||||
portMAX_DELAY, /* Clear all bits on exit - portMAX_DELAY is used as it is a portable way of having all bits set. */
|
||||
mqttexampleDISCONNECTED_BIT, /* Clear bit again on exit. */
|
||||
&( 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. */
|
||||
configPRINTF( ( "prvMQTTDemoTask() completed an iteration without hitting an assert. Total free heap is %u\r\n\r\n", xPortGetFreeHeapSize() ) );
|
||||
vTaskDelay( pdMS_TO_TICKS( 5000 ) );
|
||||
}
|
||||
}
|
||||
|
@ -351,11 +380,12 @@ IotMqttConnectInfo_t xConnectInfo = IOT_MQTT_CONNECT_INFO_INITIALIZER;
|
|||
xNetworkInfo.pNetworkInterface = IOT_NETWORK_INTERFACE_FREERTOS;
|
||||
|
||||
/* Setup the callback which is called when the MQTT connection is disconnected. */
|
||||
xNetworkInfo.disconnectCallback.pCallbackContext = ( void * ) xTaskGetCurrentTaskHandle();
|
||||
xNetworkInfo.disconnectCallback.function = prvExample_DisconnectCallback;
|
||||
xNetworkInfo.disconnectCallback.pCallbackContext = ( void * ) xTaskGetCurrentTaskHandle();//_RB_ Why the task handle?
|
||||
xNetworkInfo.disconnectCallback.function = prvExample_OnDisconnect;
|
||||
|
||||
/****************** MQTT Connection information setup. ********************/
|
||||
/* This example does not use TLS and therefore won't work with AWS IoT. */
|
||||
/* Set this flag to true if connecting to the AWS IoT MQTT broker. This
|
||||
example does not use TLS and therefore won't work with AWS IoT. */
|
||||
xConnectInfo.awsIotMqttMode = false;
|
||||
|
||||
/* Start with a clean session i.e. direct the MQTT broker to discard any
|
||||
|
@ -373,11 +403,13 @@ IotMqttConnectInfo_t xConnectInfo = IOT_MQTT_CONNECT_INFO_INITIALIZER;
|
|||
* client gets disconnected. */
|
||||
xConnectInfo.pWillInfo = NULL;
|
||||
|
||||
/* Send an MQTT PING request every minute. */
|
||||
/* Send an MQTT PING request every minute to keep the connection open if
|
||||
there is no other MQTT trafic. */
|
||||
xConnectInfo.keepAliveSeconds = mqttexampleKEEP_ALIVE_SECONDS;
|
||||
|
||||
/* The client identifier is used to uniquely identify this MQTT client to
|
||||
* the MQTT broker. */
|
||||
* the MQTT broker. In a production device the identifier can be something
|
||||
unique, such as a device serial number. */
|
||||
xConnectInfo.pClientIdentifier = mqttexampleCLIENT_IDENTIFIER;
|
||||
xConnectInfo.clientIdentifierLength = ( uint16_t ) strlen( mqttexampleCLIENT_IDENTIFIER );
|
||||
|
||||
|
@ -389,7 +421,7 @@ IotMqttConnectInfo_t xConnectInfo = IOT_MQTT_CONNECT_INFO_INITIALIZER;
|
|||
xConnectInfo.passwordLength = 0;
|
||||
|
||||
/* Establish the connection to the MQTT broker - It is a blocking call and
|
||||
will return only when connection is complete. */
|
||||
will return only when connection is complete or a timeout occurrs. */
|
||||
xResult = IotMqtt_Connect( &( xNetworkInfo ),
|
||||
&( xConnectInfo ),
|
||||
mqttexampleMQTT_TIMEOUT_MS,
|
||||
|
@ -408,7 +440,7 @@ IotMqttSubscription_t xMQTTSubscription;
|
|||
xMQTTSubscription.pTopicFilter = mqttexampleTOPIC;
|
||||
xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC );
|
||||
xMQTTSubscription.callback.pCallbackContext = ( void * ) xTaskGetCurrentTaskHandle();
|
||||
xMQTTSubscription.callback.function = prvExample_PublishCallback;
|
||||
xMQTTSubscription.callback.function = prvExample_OnMessageReceived;
|
||||
|
||||
/* Use the synchronous API to subscribe - It is a blocking call and only
|
||||
* returns when the subscribe operation is complete. */
|
||||
|
|
|
@ -138,10 +138,8 @@ configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
|
|||
used. */
|
||||
#define configNETWORK_INTERFACE_TO_USE 3L
|
||||
|
||||
/* The address of an echo server that will be used by the two demo echo client
|
||||
tasks.
|
||||
http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Echo_Clients.html
|
||||
http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/UDP_Echo_Clients.html */
|
||||
/* The address of an echo server is only left in this project as it douples as
|
||||
the address to which logging is sent should UDP logging be enabled. */
|
||||
#define configECHO_SERVER_ADDR0 192
|
||||
#define configECHO_SERVER_ADDR1 168
|
||||
#define configECHO_SERVER_ADDR2 0
|
||||
|
@ -154,9 +152,9 @@ configNETWORK_INTERFACE_TO_USE definition above for information on how to
|
|||
configure the real network connection to use. */
|
||||
#define configMAC_ADDR0 0x00
|
||||
#define configMAC_ADDR1 0x11
|
||||
#define configMAC_ADDR2 0x22
|
||||
#define configMAC_ADDR3 0x33
|
||||
#define configMAC_ADDR4 0x44
|
||||
#define configMAC_ADDR2 0x11
|
||||
#define configMAC_ADDR3 0x11
|
||||
#define configMAC_ADDR4 0x11
|
||||
#define configMAC_ADDR5 0x41
|
||||
|
||||
/* Default IP address configuration. Used in ipconfigUSE_DNS is set to 0, or
|
||||
|
@ -202,5 +200,11 @@ ipconfigUSE_DNS is set to 1 but a DNS server cannot be contacted. */
|
|||
#define strncasecmp _strnicmp
|
||||
#define strcmpi _strcmpi
|
||||
|
||||
/* Prototype for the function used to print out. In this case it prints to the
|
||||
console before the network is connected then a UDP port after the network has
|
||||
connected. */
|
||||
extern void vLoggingPrintf( const char *pcFormatString, ... );
|
||||
#define configPRINTF( X ) vLoggingPrintf X
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ extern void vLoggingPrintf( const char *pcFormatString, ... );
|
|||
/* Set to 1 to print out debug messages. If ipconfigHAS_DEBUG_PRINTF is set to
|
||||
1 then FreeRTOS_debug_printf should be defined to the function used to print
|
||||
out the debugging messages. */
|
||||
#define ipconfigHAS_DEBUG_PRINTF 0
|
||||
#define ipconfigHAS_DEBUG_PRINTF 1
|
||||
#if( ipconfigHAS_DEBUG_PRINTF == 1 )
|
||||
#define FreeRTOS_debug_printf(X) vLoggingPrintf X
|
||||
#endif
|
||||
|
|
|
@ -168,7 +168,6 @@
|
|||
<ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\portable\BufferManagement\BufferAllocation_2.c" />
|
||||
<ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\portable\NetworkInterface\WinPCap\NetworkInterface.c" />
|
||||
<ClCompile Include="DemoTasks\SimpleMQTTExamples.c" />
|
||||
<ClCompile Include="DemoTasks\SimpleUDPClientAndServer.c" />
|
||||
<ClCompile Include="demo_logging.c" />
|
||||
<ClCompile Include="main.c">
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
|
|
|
@ -110,9 +110,6 @@
|
|||
<ClCompile Include="..\..\..\..\FreeRTOS\Source\tasks.c">
|
||||
<Filter>FreeRTOS\Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="DemoTasks\SimpleUDPClientAndServer.c">
|
||||
<Filter>DemoTasks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\Source\FreeRTOS-Plus-TCP\FreeRTOS_UDP_IP.c">
|
||||
<Filter>FreeRTOS+\FreeRTOS+TCP</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
#ifndef IOT_CONFIG_H_
|
||||
#define IOT_CONFIG_H_
|
||||
|
||||
/* Use platform types on FreeRTOS. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "platform/iot_platform_types_freertos.h" //_RB_Makes common config file FreeRTOS specific
|
||||
|
||||
/**
|
||||
* @brief The number of recyclable jobs for the task pool to cache.
|
||||
|
@ -49,7 +46,7 @@
|
|||
|
||||
/**
|
||||
* @brief Enable/Disable asserts for the task pool library.
|
||||
*
|
||||
*
|
||||
* Set this to 1 to perform sanity checks when using the task pool library.
|
||||
* Asserts are useful for debugging, but should be disabled in production code.
|
||||
* If this is set to 1, IotTaskPool_Assert can be defined to set the assertion
|
||||
|
@ -82,12 +79,12 @@
|
|||
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
|
||||
* then IOT_LOG_NONE.
|
||||
*/
|
||||
#define IOT_LOG_LEVEL_TASKPOOL IOT_LOG_INFO
|
||||
#define IOT_LOG_LEVEL_TASKPOOL IOT_LOG_WARN
|
||||
|
||||
|
||||
/**
|
||||
* @brief The stack size (in bytes) for each worker task in the task pool.
|
||||
*
|
||||
*
|
||||
* The minimal version of the of task pool library only supports one task pool
|
||||
* and the configuration of each worker task fixed at the compile time.
|
||||
*/
|
||||
|
@ -107,6 +104,18 @@
|
|||
*/
|
||||
#define AWS_IOT_MQTT_ENABLE_METRICS 0
|
||||
|
||||
/*
|
||||
* @brief Set the log level of the task pool library.
|
||||
*
|
||||
* Log messages from the task pool library at or below this setting will be
|
||||
* printed.
|
||||
*
|
||||
* Possible values: One of the Log levels.
|
||||
* Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined,
|
||||
* then IOT_LOG_NONE.
|
||||
*/
|
||||
#define IOT_LOG_LEVEL_MQTT IOT_LOG_WARN
|
||||
|
||||
/* Include the common configuration file for FreeRTOS. */
|
||||
#include "iot_config_common.h"
|
||||
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
/* Use platform types on FreeRTOS. */
|
||||
#include "platform/iot_platform_types_freertos.h" //_RB_Makes common config file FreeRTOS specific
|
||||
|
||||
/* Used to get the cloud broker endpoint for FreeRTOS. */
|
||||
//_RB_#include "aws_clientcredential.h"
|
||||
|
||||
/* SDK version. */
|
||||
#define IOT_SDK_VERSION "4.0.0"
|
||||
|
||||
|
|
|
@ -136,30 +136,6 @@ int main( void )
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vAssertCalled( const char *pcFile, uint32_t ulLine )
|
||||
{
|
||||
volatile uint32_t ulBlockVariable = 0UL;
|
||||
volatile char *pcFileName = ( volatile char * ) pcFile;
|
||||
volatile uint32_t ulLineNumber = ulLine;
|
||||
|
||||
( void ) pcFileName;
|
||||
( void ) ulLineNumber;
|
||||
|
||||
printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );
|
||||
|
||||
/* Setting ulBlockVariable to a non-zero value in the debugger will allow
|
||||
this function to be exited. */
|
||||
taskDISABLE_INTERRUPTS();
|
||||
{
|
||||
while( ulBlockVariable == 0UL )
|
||||
{
|
||||
__debugbreak();
|
||||
}
|
||||
}
|
||||
taskENABLE_INTERRUPTS();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
|
||||
events are only received if implemented in the MAC driver. */
|
||||
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
|
||||
|
@ -199,6 +175,30 @@ static BaseType_t xTasksAlreadyCreated = pdFALSE;
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vAssertCalled( const char *pcFile, uint32_t ulLine )
|
||||
{
|
||||
volatile uint32_t ulBlockVariable = 0UL;
|
||||
volatile char *pcFileName = ( volatile char * ) pcFile;
|
||||
volatile uint32_t ulLineNumber = ulLine;
|
||||
|
||||
( void ) pcFileName;
|
||||
( void ) ulLineNumber;
|
||||
|
||||
printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );
|
||||
|
||||
/* Setting ulBlockVariable to a non-zero value in the debugger will allow
|
||||
this function to be exited. */
|
||||
taskDISABLE_INTERRUPTS();
|
||||
{
|
||||
while( ulBlockVariable == 0UL )
|
||||
{
|
||||
__debugbreak();
|
||||
}
|
||||
}
|
||||
taskENABLE_INTERRUPTS();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
UBaseType_t uxRand( void )
|
||||
{
|
||||
const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
|
||||
|
@ -230,7 +230,13 @@ uint32_t ulLoggingIPAddress;
|
|||
ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 );
|
||||
vLoggingInit( xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT );
|
||||
|
||||
/* Seed the random number generator. */
|
||||
/*
|
||||
* Seed random number generator.
|
||||
*
|
||||
* !!!NOTE!!!
|
||||
* This is not a secure method of generating a random number. Production
|
||||
* devices should use a True Random Number Generator (TRNG).
|
||||
*/
|
||||
time( &xTimeNow );
|
||||
FreeRTOS_debug_printf( ( "Seed for randomiser: %lu\n", xTimeNow ) );
|
||||
prvSRand( ( uint32_t ) xTimeNow );
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
#ifndef IOT_CONFIG_H_
|
||||
#define IOT_CONFIG_H_
|
||||
|
||||
/* Use platform types on FreeRTOS. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "platform/iot_platform_types_freertos.h" //_RB_Makes common config file FreeRTOS specific
|
||||
|
||||
/*
|
||||
* Set this to the number of recyclable tasks for the task pool to cache.
|
||||
|
|
|
@ -28,6 +28,12 @@
|
|||
#ifndef IOT_CONFIG_COMMON_H_
|
||||
#define IOT_CONFIG_COMMON_H_
|
||||
|
||||
/* FreeRTOS include. */
|
||||
#include "FreeRTOS.h" //_RB_Makes common config file FreeRTOS specific
|
||||
|
||||
/* Use platform types on FreeRTOS. */
|
||||
#include "platform/iot_platform_types_freertos.h" //_RB_Makes common config file FreeRTOS specific
|
||||
|
||||
/* SDK version. */
|
||||
#define IOT_SDK_VERSION "4.0.0"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue