-
Notifications
You must be signed in to change notification settings - Fork 103
/
link_main.c
169 lines (145 loc) · 5.41 KB
/
link_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
164
165
166
167
168
169
/* ----------------------------------------------------------------------------
* Copyright (c) <2018>, <Huawei Technologies Co., Ltd>
* All rights reserved.
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------------
* Notice of Export Control Law
* ===============================================
* Huawei LiteOS may be subject to applicable export control laws and regulations, which might
* include those applicable to Huawei LiteOS of U.S. and the country in which you are located.
* Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such
* applicable export control laws and regulations.
* --------------------------------------------------------------------------- */
#include <stdio.h>
#include "iot_link_config.h"
#include "link_version.h"
// RTOS KERNEL
#include "osal.h"
#ifdef CONFIG_MACOS_ENABLE
#include <sys/select.h>
#endif
#define CN_LINK_VERSION_MAJOR 2
#define CN_LINK_VERSION_MINOR 2
#define CN_LINK_VERSION_FEATURE 2
static char s_link_mainversion[64];
const char *linkmain_version()
{
(void)snprintf(s_link_mainversion, 64, "V%d.%d.%d AT %s ON %s", CN_LINK_VERSION_MAJOR, CN_LINK_VERSION_MINOR,
CN_LINK_VERSION_FEATURE, __TIME__, __DATE__);
return s_link_mainversion;
}
static int s_link_start = 0;
int link_main(void *args)
{
// /< install the RTOS kernel for the link
if (s_link_start) {
return -1;
}
s_link_start = 1;
(void)osal_init();
LINK_LOG_DEBUG("linkmain:%s", linkmain_version());
#ifdef CONFIG_STIMER_ENABLE
#include "stimer.h"
stimer_init();
#endif
#ifdef CONFIG_SHELL_ENABLE
#include "shell.h"
shell_init();
#endif
/* add loader code here */
#ifdef CONFIG_OTA_ENABLE
#include "ota_init.h"
ota_init();
#endif
// /< install the driver framework
#ifdef CONFIG_DRIVER_ENABLE
#include "driver.h"
// /< install the driver framework for the link
(void)los_driv_init();
#endif
// /< install the at framework
#ifdef CONFIG_AT_ENABLE
#include "at.h"
(void)at_init();
#endif
// /< install the cJSON, for the oc mqtt agent need the cJSON
#ifdef CONFIG_CJSON_ENABLE
#include "cJSON.h"
cJSON_Hooks hook;
hook.free_fn = osal_free;
hook.malloc_fn = osal_malloc;
cJSON_InitHooks(&hook);
#endif
// //////////////////////// TCPIP PROTOCOL /////////////////////////////////////
#ifdef CONFIG_TCPIP_AL_ENABLE
#include "sal.h"
(void)link_tcpip_init();
#endif
// //////////////////////// DTLS PROTOCOL /////////////////////////////////////
#ifdef CONFIG_DTLS_AL_ENABLE
#include "dtls_al.h"
(void)dtls_al_init();
#endif
// //////////////////////// MQTT PROTOCOL /////////////////////////////////////
#ifdef CONFIG_MQTT_AL_ENABLE
#include "mqtt_al.h"
mqtt_al_init();
#endif
// //////////////////////// COAP PROTOCOL /////////////////////////////////
#ifdef CONFIG_COAP_AL_ENABLE
#include "coap_al.h"
(void)coap_al_init();
#endif
// //////////////////////// LWM2M PROTOCOL /////////////////////////////////
#ifdef CONFIG_LWM2M_AL_ENABLE
#include "lwm2m_al.h"
(void)lwm2m_al_init();
#endif
// //////////////////////// OC MQTT //////////////////////////////////
#ifdef CONFIG_OCMQTT_ENABLE
#include "oc_mqtt_al.h"
(void)oc_mqtt_init();
#endif
// ////////////////////////// OC LWM2M /////////////////////////////////////////
#ifdef CONFIG_OCLWM2M_ENABLE
#include "oc_lwm2m_al.h"
oc_lwm2m_init();
#endif
// ////////////////////////// OC COAP //////////////////////////////////////////
#ifdef CONFIG_OCCOAP_ENABLE
#include "oc_coap_al.h"
oc_coap_init();
#endif
// ////////////////////////// AUTO TEST ////////////////////////////////////////
#ifdef CONFIG_AUTO_TEST
#include "test_case.h"
autotest_start();
#endif
// ////////////////////////// LINK DEMO ////////////////////////////////////////
#ifdef CONFIG_LINKDEMO_ENABLE
extern int standard_app_demo_main(void);
(void)standard_app_demo_main();
#endif
return 0;
}