This repository has been archived by the owner on Dec 8, 2022. It is now read-only.
/
main.c
163 lines (138 loc) · 4.67 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
FreeRTOS
Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
http://aws.amazon.com/freertos
http://www.FreeRTOS.org
*/
/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "task.h"
/* System init includes. */
#include "iot_system_init.h"
/* Logging includes. */
#include "iot_logging_task.h"
/* Key provisioning includes. */
#include "aws_dev_mode_key_provisioning.h"
/* FreeRTOS+TCP includes. */
#include "FreeRTOS_IP.h"
/* Demo includes */
#include "aws_demo.h"
#include "aws_clientcredential.h"
#define mainLOGGING_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 6 )
#define mainLOGGING_MESSAGE_QUEUE_LENGTH ( 15 )
#define mainTEST_RUNNER_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 8 )
/* The MAC address array is not declared const as the MAC address will
normally be read from an EEPROM and not hard coded (in real deployed
applications).*/
static uint8_t ucMACAddress[ 6 ] =
{
configMAC_ADDR0,
configMAC_ADDR1,
configMAC_ADDR2,
configMAC_ADDR3,
configMAC_ADDR4,
configMAC_ADDR5
}; //XXX
/* Define the network addressing. These parameters will be used if either
ipconfigUDE_DHCP is 0 or if ipconfigUSE_DHCP is 1 but DHCP auto configuration
failed. */
static const uint8_t ucIPAddress[ 4 ] =
{
configIP_ADDR0,
configIP_ADDR1,
configIP_ADDR2,
configIP_ADDR3
};
static const uint8_t ucNetMask[ 4 ] =
{
configNET_MASK0,
configNET_MASK1,
configNET_MASK2,
configNET_MASK3
};
static const uint8_t ucGatewayAddress[ 4 ] =
{
configGATEWAY_ADDR0,
configGATEWAY_ADDR1,
configGATEWAY_ADDR2,
configGATEWAY_ADDR3
};
/* The following is the address of an OpenDNS server. */
static const uint8_t ucDNSServerAddress[ 4 ] =
{
configDNS_SERVER_ADDR0,
configDNS_SERVER_ADDR1,
configDNS_SERVER_ADDR2,
configDNS_SERVER_ADDR3
};
/**
* @brief Application task startup hook.
*/
void vApplicationDaemonTaskStartupHook( void );
/**
* @brief Initializes the board.
*/
static void prvMiscInitialization( void );
/*-----------------------------------------------------------*/
/**
* @brief The application entry point from a power on reset is PowerON_Reset_PC()
* in resetprg.c.
*/
void main( void )
{
while(1)
{
vTaskDelay(10000);
}
}
/*-----------------------------------------------------------*/
static void prvMiscInitialization( void )
{
/* Initialize UART for serial terminal. */
uart_config();
/* Start logging task. */
xLoggingTaskInitialize( mainLOGGING_TASK_STACK_SIZE,
tskIDLE_PRIORITY,
mainLOGGING_MESSAGE_QUEUE_LENGTH );
}
/*-----------------------------------------------------------*/
void vApplicationDaemonTaskStartupHook( void )
{
prvMiscInitialization();
if( SYSTEM_Init() == pdPASS )
{
/* Initialise the RTOS's TCP/IP stack. The tasks that use the network
are created in the vApplicationIPNetworkEventHook() hook function
below. The hook function is called when the network connects. */
FreeRTOS_IPInit( ucIPAddress,
ucNetMask,
ucGatewayAddress,
ucDNSServerAddress,
ucMACAddress );
/* We should wait for the network to be up before we run any demos. */
while( FreeRTOS_IsNetworkUp() == pdFALSE )
{
vTaskDelay(300);
}
FreeRTOS_printf( ( "The network is up and running\n" ) );
/* Provision the device with AWS certificate and private key. */
vDevModeKeyProvisioning();
/* Run all demos. */
DEMO_RUNNER_RunDemos();
}
}
/*-----------------------------------------------------------*/