Skip to content

Commit 543d438

Browse files
authored
Merge pull request #364 from AFunnyMan/iot_link
add NB476 support.
2 parents 7eca489 + f070ae1 commit 543d438

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+26946
-0
lines changed

targets/STM32L476RG_NB476/.config

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#Generated by IoT Link Studio
2+
CONFIG_ARCH_CPU_TYPE="armv7-m"
3+
CONFIG_UARTAT_RCVMAX=2048
4+
CONFIG_UARTAT_BAUDRATE=9600
5+
CONFIG_UARTAT_DEVNAME="atdev"
6+
CONFIG_LITEOS_ENABLE=y
7+
# CONFIG_NOVAOS_ENABLE is not set
8+
# CONFIG_LINUXOS_ENABLE is not set
9+
# CONFIG_MACOS_ENABLE is not set
10+
# CONFIG_NEW_OS is not set
11+
CONFIG_AT_ENABLE=y
12+
CONFIG_AT_DEVNAME="atdev"
13+
CONFIG_AT_OOBTABLEN=6
14+
CONFIG_AT_RECVMAXLEN=1024
15+
CONFIG_AT_TASKPRIOR=10
16+
# CONFIG_CJSON_ENABLE is not set
17+
CONFIG_DRIVER_ENABLE=y
18+
CONFIG_LINKLOG_ENABLE=y
19+
CONFIG_LINKQUEUE_ENABLE=y
20+
CONFIG_LINKDEMO_ENABLE=y
21+
CONFIG_STIMER_ENABLE=y
22+
CONFIG_STIMER_STACKSIZE=2048
23+
CONFIG_STIMER_TASKPRIOR=10
24+
# CONFIG_STIMER_DEMO_ENABLE is not set
25+
# CONFIG_TCIP_AL_ENABLE is not set
26+
# CONFIG_DTLS_AL_ENABLE is not set
27+
# CONFIG_COAP_AL_ENABLE is not set
28+
# CONFIG_LWM2M_AL_ENABLE is not set
29+
# CONFIG_MQTT_AL_ENABLE is not set
30+
CONFIG_OCSERVICES_ENABLE=y
31+
CONFIG_OCCOAP_ENABLE=y
32+
# CONFIG_OCCOAPTINY_ENABLE is not set
33+
CONFIG_BOUDICA120_ENABLE=y
34+
# CONFIG_OCCOAPNULL is not set
35+
# CONFIG_OCCOAP_DEMO_ENABLE is not set
36+
# CONFIG_OCLWM2M_ENABLE is not set
37+
# CONFIG_OCMQTT_ENABLE is not set
38+
CONFIG_SHELL_ENABLE=y
39+
CONFIG_SHELL_TASK_STACKSIZE=2048
40+
CONFIG_SHELL_TASK_PRIOR=10
41+
CONFIG_IOT_LINK_CONFIGFILE="iot_config.h"
42+
# CONFIG_Demo_None is not set
43+
CONFIG_Demo_Use_Coap=y
44+
CONFIG_USER_DEMO="use_coap_demo"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
choice Demo
2+
optional
3+
prompt "User Defined Demo"
4+
config Demo_None
5+
bool "none"
6+
config Demo_Use_Coap
7+
bool "Report temperature"
8+
endchoice
9+
10+
config USER_DEMO
11+
string
12+
default "use_coap_demo" if Demo_Use_Coap
13+
default "none"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#Generated by IoT Link Studio
2+
CONFIG_ARCH_CPU_TYPE="armv7-m"
3+
CONFIG_UARTAT_RCVMAX=2048
4+
CONFIG_UARTAT_BAUDRATE=9600
5+
CONFIG_UARTAT_DEVNAME="atdev"
6+
CONFIG_LITEOS_ENABLE=y
7+
# CONFIG_NOVAOS_ENABLE is not set
8+
# CONFIG_LINUXOS_ENABLE is not set
9+
# CONFIG_MACOS_ENABLE is not set
10+
# CONFIG_NEW_OS is not set
11+
CONFIG_AT_ENABLE=y
12+
CONFIG_AT_DEVNAME="atdev"
13+
CONFIG_AT_OOBTABLEN=6
14+
CONFIG_AT_RECVMAXLEN=1024
15+
CONFIG_AT_TASKPRIOR=10
16+
# CONFIG_CJSON_ENABLE is not set
17+
CONFIG_DRIVER_ENABLE=y
18+
CONFIG_LINKLOG_ENABLE=y
19+
CONFIG_LINKQUEUE_ENABLE=y
20+
CONFIG_LINKDEMO_ENABLE=y
21+
CONFIG_STIMER_ENABLE=y
22+
CONFIG_STIMER_STACKSIZE=2048
23+
CONFIG_STIMER_TASKPRIOR=10
24+
# CONFIG_STIMER_DEMO_ENABLE is not set
25+
# CONFIG_TCIP_AL_ENABLE is not set
26+
# CONFIG_DTLS_AL_ENABLE is not set
27+
# CONFIG_COAP_AL_ENABLE is not set
28+
# CONFIG_LWM2M_AL_ENABLE is not set
29+
# CONFIG_MQTT_AL_ENABLE is not set
30+
CONFIG_OCSERVICES_ENABLE=y
31+
CONFIG_OCCOAP_ENABLE=y
32+
# CONFIG_OCCOAPTINY_ENABLE is not set
33+
CONFIG_BOUDICA120_ENABLE=y
34+
# CONFIG_OCCOAPNULL is not set
35+
# CONFIG_OCCOAP_DEMO_ENABLE is not set
36+
# CONFIG_OCLWM2M_ENABLE is not set
37+
# CONFIG_OCMQTT_ENABLE is not set
38+
CONFIG_SHELL_ENABLE=y
39+
CONFIG_SHELL_TASK_STACKSIZE=2048
40+
CONFIG_SHELL_TASK_PRIOR=10
41+
CONFIG_IOT_LINK_CONFIGFILE="iot_config.h"
42+
# CONFIG_Demo_None is not set
43+
CONFIG_Demo_Use_Coap=y
44+
CONFIG_USER_DEMO="use_coap_demo"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#Generated by Huawei IoT Studio
2+
CONFIG_ARCH_CPU_TYPE="armv7-m"
3+
CONFIG_UARTAT_RCVMAX=2048
4+
CONFIG_UARTAT_BAUDRATE=9600
5+
CONFIG_UARTAT_DEVNAME="atdev"
6+
CONFIG_LITEOS_ENABLE=y
7+
# CONFIG_NOVAOS_ENABLE is not set
8+
# CONFIG_LINUXOS_ENABLE is not set
9+
# CONFIG_MACOS_ENABLE is not set
10+
# CONFIG_NEW_OS is not set
11+
CONFIG_AT_ENABLE=y
12+
CONFIG_AT_DEVNAME="atdev"
13+
CONFIG_AT_OOBTABLEN=6
14+
CONFIG_AT_RECVMAXLEN=1024
15+
CONFIG_AT_TASKPRIOR=10
16+
# CONFIG_CJSON_ENABLE is not set
17+
CONFIG_DRIVER_ENABLE=y
18+
CONFIG_LINKLOG_ENABLE=y
19+
CONFIG_LINKQUEUE_ENABLE=y
20+
CONFIG_LINKDEMO_ENABLE=y
21+
# CONFIG_STIMER_ENABLE=y
22+
# CONFIG_STIMER_STACKSIZE=2048
23+
# CONFIG_STIMER_TASKPRIOR=10
24+
# CONFIG_STIMER_DEMO_ENABLE is not set
25+
# CONFIG_TCIP_AL_ENABLE is not set
26+
# CONFIG_DTLS_AL_ENABLE is not set
27+
# CONFIG_COAP_AL_ENABLE is not set
28+
# CONFIG_LWM2M_AL_ENABLE is not set
29+
# CONFIG_MQTT_AL_ENABLE is not set
30+
CONFIG_OCSERVICES_ENABLE=y
31+
CONFIG_OCCOAP_ENABLE=y
32+
#CONFIG_OCLWM2M_ENABLE is not set
33+
# CONFIG_OCLWM2MTINY_ENABLE is not set
34+
CONFIG_BOUDICA120_ENABLE=y
35+
# CONFIG_OCLWM2MNULL is not set
36+
# CONFIG_OCLWM2M_DEMO_ENABLE is not set
37+
# CONFIG_OCMQTT_ENABLE is not set
38+
# CONFIG_OC_MQTTV1_PROFILE is not set
39+
# CONFIG_OC_MQTTV1_DEMO is not set
40+
# CONFIG_OC_MQTTV1_DEMO_BS is not set
41+
CONFIG_SHELL_ENABLE=y
42+
CONFIG_SHELL_TASK_STACKSIZE=2048
43+
CONFIG_SHELL_TASK_PRIOR=10
44+
CONFIG_IOT_LINK_CONFIGFILE="iot_config.h"
45+
# CONFIG_Demo_None is not set
46+
CONFIG_Demo_Use_Coap=y
47+
CONFIG_USER_DEMO="use_coap_demo"
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/*----------------------------------------------------------------------------
2+
* Copyright (c) <2018>, <Huawei Technologies Co., Ltd>
3+
* All rights reserved.
4+
* Redistribution and use in source and binary forms, with or without modification,
5+
* are permitted provided that the following conditions are met:
6+
* 1. Redistributions of source code must retain the above copyright notice, this list of
7+
* conditions and the following disclaimer.
8+
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
9+
* of conditions and the following disclaimer in the documentation and/or other materials
10+
* provided with the distribution.
11+
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
12+
* to endorse or promote products derived from this software without specific prior written
13+
* permission.
14+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
18+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21+
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22+
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23+
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
*---------------------------------------------------------------------------*/
26+
/*----------------------------------------------------------------------------
27+
* Notice of Export Control Law
28+
* ===============================================
29+
* Huawei LiteOS may be subject to applicable export control laws and regulations, which might
30+
* include those applicable to Huawei LiteOS of U.S. and the country in which you are located.
31+
* Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such
32+
* applicable export control laws and regulations.
33+
*---------------------------------------------------------------------------*/
34+
/**
35+
* DATE AUTHOR INSTRUCTION
36+
* 2020-04-21 FanXinhao The first version
37+
*
38+
*/
39+
#include <stdint.h>
40+
#include <stddef.h>
41+
#include <string.h>
42+
#include <los_typedef.h>
43+
#include <los_task.h>
44+
#include <boudica120_oc.h>
45+
#include <osal.h>
46+
#include <oc_coap_al.h>
47+
48+
#include "dht11.h"
49+
#include "oled.h"
50+
51+
//DHT11 Data Struct
52+
DHT11_Data_TypeDef dht11_data;
53+
unsigned char DHT11_str[10] = {0};
54+
55+
56+
/* LWM2M server information */
57+
#define cn_endpoint_id "coap_001"
58+
#define cn_app_server "119.3.250.80"
59+
#define cn_app_port "5683"
60+
61+
//if your command is very fast,please use a queue here--TODO
62+
#define cn_app_rcv_buf_len 128
63+
static int8_t s_rcv_buffer[cn_app_rcv_buf_len];
64+
static int s_rcv_datalen;
65+
static osal_semp_t s_rcv_sync;
66+
67+
//use this function to push all the message to the buffer
68+
static int app_msg_deal(void *msg, int len)
69+
{
70+
int ret = -1;
71+
72+
if(len <= cn_app_rcv_buf_len)
73+
{
74+
memcpy(s_rcv_buffer,msg,len);
75+
s_rcv_datalen = len;
76+
77+
osal_semp_post(s_rcv_sync);
78+
79+
ret = 0;
80+
81+
}
82+
return ret;
83+
}
84+
85+
int coap_report_task(void *args)
86+
{
87+
int* handle = NULL;
88+
oc_config_param_t oc_param;
89+
char Temp[10] = {00, 22};
90+
oc_coap_imp_init();
91+
92+
memset(&oc_param,0,sizeof(oc_param));
93+
94+
oc_param.app_server.address = cn_app_server;
95+
oc_param.app_server.port = cn_app_port;
96+
oc_param.app_server.ep_id = cn_endpoint_id;
97+
oc_param.boot_mode = en_oc_boot_strap_mode_factory;
98+
oc_param.rcv_func = app_msg_deal;
99+
100+
handle = oc_coap_config(&oc_param);
101+
if (NULL == handle)
102+
{
103+
printf("config_init fail!\r\n");
104+
}
105+
else
106+
{
107+
printf("start send message to CDP server!\r\n");
108+
}
109+
while(1)
110+
{
111+
memset(DHT11_str, 0, 6);
112+
sprintf(Temp,"%02d",(int)dht11_data.temperature);
113+
oc_coap_report(handle, Temp, 2);
114+
osal_task_sleep(10*1000);
115+
}
116+
}
117+
118+
int Read_DHT11_task(void *args)
119+
{
120+
121+
while(1)
122+
{
123+
DHT11_Read_TempAndHumidity(&dht11_data);//read DHT11
124+
/* oled display */
125+
OLED_Clear();
126+
OLED_ShowString(9, 0, "DHT11 Data", 10);
127+
memset(DHT11_str, 0, 6);
128+
sprintf(DHT11_str,"temp %5.2f",dht11_data.temperature);
129+
OLED_ShowString(9, 2, DHT11_str, 5);
130+
memset(DHT11_str, 0, 6);
131+
sprintf(DHT11_str,"humid %5.2f",dht11_data.humidity);
132+
OLED_ShowString(9, 4, DHT11_str, 5);
133+
134+
osal_task_sleep(5*1000);
135+
136+
}
137+
}
138+
139+
int standard_app_demo_main()
140+
{
141+
osal_task_create("coap_report",coap_report_task, NULL, 0x1000, NULL, 3);
142+
osal_task_create("Read_DHT11",Read_DHT11_task, NULL, 0x500, NULL, 3);
143+
return 0;
144+
}
145+
146+
147+
148+
149+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
################################################################################
2+
# this is used for compile the user defined oc demo
3+
################################################################################
4+
5+
#if you have defined multiple demos by yourself, modify this file to compile the chosen demo.
6+
7+
#example for LiteOS func
8+
9+
10+
#example for report temperature
11+
ifeq ($(CONFIG_USER_DEMO), "use_coap_demo")
12+
user_demo_src = ${wildcard $(TARGET_DIR)/Demos/use_coap_demo/*.c}
13+
user_demo_defs = -D CONFIG_USE_COAP_ENABLE=1
14+
endif
15+
16+
17+
C_SOURCES += $(user_demo_src)
18+
C_INCLUDES += $(user_demo_inc)
19+
C_DEFS += $(user_demo_defs)

0 commit comments

Comments
 (0)