99#include "cmsis_utils.h"
1010#include "screen.h"
1111#include "sntp_client.h"
12+ #include "wwd_networking.h"
1213
1314#include "legacy/mqtt.h"
1415#include "nx_client.h"
15- #include "wwd_networking.h"
1616
1717#include "azure_config.h"
1818
2222TX_THREAD azure_thread ;
2323ULONG azure_thread_stack [AZURE_THREAD_STACK_SIZE / sizeof (ULONG )];
2424
25- void azure_thread_entry (ULONG parameter );
26- void tx_application_define (void * first_unused_memory );
27-
28- void azure_thread_entry (ULONG parameter )
25+ static void azure_thread_entry (ULONG parameter )
2926{
3027 UINT status ;
3128
3229 printf ("Starting Azure thread\r\n\r\n" );
3330
34- if (platform_init (WIFI_SSID , WIFI_PASSWORD , WIFI_MODE ) != NX_SUCCESS )
35- {
36- printf ("Failed to initialize platform.\r\n" );
37- return ;
38- }
39- screen_print ("WiFi ready" , L0 );
40-
41- // Start the SNTP client
42- status = sntp_start ();
43- if (status != NX_SUCCESS )
44- {
45- printf ("Failed to start the SNTP client (0x%02x)\r\n" , status );
46- return ;
47- }
48-
49- // Wait for an SNTP sync
50- status = sntp_sync_wait ();
51- if (status != NX_SUCCESS )
31+ // Initialize the network
32+ if ((status = wwd_network_init (WIFI_SSID , WIFI_PASSWORD , WIFI_MODE )))
5233 {
53- printf ("Failed to start sync SNTP time (0x%02x)\r\n" , status );
54- return ;
34+ printf ("ERROR: Failed to initialize the network (0x%08x)\r\n" , status );
5535 }
56- screen_print ("SNTP inited" , L0 );
5736
5837#ifdef ENABLE_LEGACY_MQTT
59- if ((status = azure_iot_mqtt_entry (& nx_ip , & nx_pool [0 ], & nx_dns_client , sntp_time_get )))
38+ else if ((status = azure_iot_mqtt_entry (& nx_ip , & nx_pool [0 ], & nx_dns_client , sntp_time_get )))
6039#else
61- if ((status = azure_iot_nx_client_entry (& nx_ip , & nx_pool [0 ], & nx_dns_client , sntp_time )))
40+ else if ((status = azure_iot_nx_client_entry (& nx_ip , & nx_pool [0 ], & nx_dns_client , sntp_time )))
6241#endif
6342 {
64- printf ("Failed to run Azure IoT (0x%04x)\r\n" , status );
65- return ;
43+ printf ("ERROR: Failed to run Azure IoT (0x%08x)\r\n" , status );
6644 }
6745}
6846
@@ -84,13 +62,13 @@ void tx_application_define(void* first_unused_memory)
8462
8563 if (status != TX_SUCCESS )
8664 {
87- printf ("Azure IoT application failed, please restart \r\n" );
65+ printf ("ERROR: Azure IoT thread creation failed \r\n" );
8866 }
8967}
9068
9169int main (void )
9270{
93- // Initialise the board
71+ // Initialize the board
9472 board_init ();
9573
9674 // Enter the ThreadX kernel
0 commit comments