-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #364 from AFunnyMan/iot_link
add NB476 support.
- Loading branch information
Showing
67 changed files
with
26,946 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#Generated by IoT Link Studio | ||
CONFIG_ARCH_CPU_TYPE="armv7-m" | ||
CONFIG_UARTAT_RCVMAX=2048 | ||
CONFIG_UARTAT_BAUDRATE=9600 | ||
CONFIG_UARTAT_DEVNAME="atdev" | ||
CONFIG_LITEOS_ENABLE=y | ||
# CONFIG_NOVAOS_ENABLE is not set | ||
# CONFIG_LINUXOS_ENABLE is not set | ||
# CONFIG_MACOS_ENABLE is not set | ||
# CONFIG_NEW_OS is not set | ||
CONFIG_AT_ENABLE=y | ||
CONFIG_AT_DEVNAME="atdev" | ||
CONFIG_AT_OOBTABLEN=6 | ||
CONFIG_AT_RECVMAXLEN=1024 | ||
CONFIG_AT_TASKPRIOR=10 | ||
# CONFIG_CJSON_ENABLE is not set | ||
CONFIG_DRIVER_ENABLE=y | ||
CONFIG_LINKLOG_ENABLE=y | ||
CONFIG_LINKQUEUE_ENABLE=y | ||
CONFIG_LINKDEMO_ENABLE=y | ||
CONFIG_STIMER_ENABLE=y | ||
CONFIG_STIMER_STACKSIZE=2048 | ||
CONFIG_STIMER_TASKPRIOR=10 | ||
# CONFIG_STIMER_DEMO_ENABLE is not set | ||
# CONFIG_TCIP_AL_ENABLE is not set | ||
# CONFIG_DTLS_AL_ENABLE is not set | ||
# CONFIG_COAP_AL_ENABLE is not set | ||
# CONFIG_LWM2M_AL_ENABLE is not set | ||
# CONFIG_MQTT_AL_ENABLE is not set | ||
CONFIG_OCSERVICES_ENABLE=y | ||
CONFIG_OCCOAP_ENABLE=y | ||
# CONFIG_OCCOAPTINY_ENABLE is not set | ||
CONFIG_BOUDICA120_ENABLE=y | ||
# CONFIG_OCCOAPNULL is not set | ||
# CONFIG_OCCOAP_DEMO_ENABLE is not set | ||
# CONFIG_OCLWM2M_ENABLE is not set | ||
# CONFIG_OCMQTT_ENABLE is not set | ||
CONFIG_SHELL_ENABLE=y | ||
CONFIG_SHELL_TASK_STACKSIZE=2048 | ||
CONFIG_SHELL_TASK_PRIOR=10 | ||
CONFIG_IOT_LINK_CONFIGFILE="iot_config.h" | ||
# CONFIG_Demo_None is not set | ||
CONFIG_Demo_Use_Coap=y | ||
CONFIG_USER_DEMO="use_coap_demo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
choice Demo | ||
optional | ||
prompt "User Defined Demo" | ||
config Demo_None | ||
bool "none" | ||
config Demo_Use_Coap | ||
bool "Report temperature" | ||
endchoice | ||
|
||
config USER_DEMO | ||
string | ||
default "use_coap_demo" if Demo_Use_Coap | ||
default "none" |
44 changes: 44 additions & 0 deletions
44
targets/STM32L476RG_NB476/Demos/use_coap_demo/defaults.sdkconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#Generated by IoT Link Studio | ||
CONFIG_ARCH_CPU_TYPE="armv7-m" | ||
CONFIG_UARTAT_RCVMAX=2048 | ||
CONFIG_UARTAT_BAUDRATE=9600 | ||
CONFIG_UARTAT_DEVNAME="atdev" | ||
CONFIG_LITEOS_ENABLE=y | ||
# CONFIG_NOVAOS_ENABLE is not set | ||
# CONFIG_LINUXOS_ENABLE is not set | ||
# CONFIG_MACOS_ENABLE is not set | ||
# CONFIG_NEW_OS is not set | ||
CONFIG_AT_ENABLE=y | ||
CONFIG_AT_DEVNAME="atdev" | ||
CONFIG_AT_OOBTABLEN=6 | ||
CONFIG_AT_RECVMAXLEN=1024 | ||
CONFIG_AT_TASKPRIOR=10 | ||
# CONFIG_CJSON_ENABLE is not set | ||
CONFIG_DRIVER_ENABLE=y | ||
CONFIG_LINKLOG_ENABLE=y | ||
CONFIG_LINKQUEUE_ENABLE=y | ||
CONFIG_LINKDEMO_ENABLE=y | ||
CONFIG_STIMER_ENABLE=y | ||
CONFIG_STIMER_STACKSIZE=2048 | ||
CONFIG_STIMER_TASKPRIOR=10 | ||
# CONFIG_STIMER_DEMO_ENABLE is not set | ||
# CONFIG_TCIP_AL_ENABLE is not set | ||
# CONFIG_DTLS_AL_ENABLE is not set | ||
# CONFIG_COAP_AL_ENABLE is not set | ||
# CONFIG_LWM2M_AL_ENABLE is not set | ||
# CONFIG_MQTT_AL_ENABLE is not set | ||
CONFIG_OCSERVICES_ENABLE=y | ||
CONFIG_OCCOAP_ENABLE=y | ||
# CONFIG_OCCOAPTINY_ENABLE is not set | ||
CONFIG_BOUDICA120_ENABLE=y | ||
# CONFIG_OCCOAPNULL is not set | ||
# CONFIG_OCCOAP_DEMO_ENABLE is not set | ||
# CONFIG_OCLWM2M_ENABLE is not set | ||
# CONFIG_OCMQTT_ENABLE is not set | ||
CONFIG_SHELL_ENABLE=y | ||
CONFIG_SHELL_TASK_STACKSIZE=2048 | ||
CONFIG_SHELL_TASK_PRIOR=10 | ||
CONFIG_IOT_LINK_CONFIGFILE="iot_config.h" | ||
# CONFIG_Demo_None is not set | ||
CONFIG_Demo_Use_Coap=y | ||
CONFIG_USER_DEMO="use_coap_demo" |
47 changes: 47 additions & 0 deletions
47
targets/STM32L476RG_NB476/Demos/use_coap_demo/defaults.sdkconfig.back
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#Generated by Huawei IoT Studio | ||
CONFIG_ARCH_CPU_TYPE="armv7-m" | ||
CONFIG_UARTAT_RCVMAX=2048 | ||
CONFIG_UARTAT_BAUDRATE=9600 | ||
CONFIG_UARTAT_DEVNAME="atdev" | ||
CONFIG_LITEOS_ENABLE=y | ||
# CONFIG_NOVAOS_ENABLE is not set | ||
# CONFIG_LINUXOS_ENABLE is not set | ||
# CONFIG_MACOS_ENABLE is not set | ||
# CONFIG_NEW_OS is not set | ||
CONFIG_AT_ENABLE=y | ||
CONFIG_AT_DEVNAME="atdev" | ||
CONFIG_AT_OOBTABLEN=6 | ||
CONFIG_AT_RECVMAXLEN=1024 | ||
CONFIG_AT_TASKPRIOR=10 | ||
# CONFIG_CJSON_ENABLE is not set | ||
CONFIG_DRIVER_ENABLE=y | ||
CONFIG_LINKLOG_ENABLE=y | ||
CONFIG_LINKQUEUE_ENABLE=y | ||
CONFIG_LINKDEMO_ENABLE=y | ||
# CONFIG_STIMER_ENABLE=y | ||
# CONFIG_STIMER_STACKSIZE=2048 | ||
# CONFIG_STIMER_TASKPRIOR=10 | ||
# CONFIG_STIMER_DEMO_ENABLE is not set | ||
# CONFIG_TCIP_AL_ENABLE is not set | ||
# CONFIG_DTLS_AL_ENABLE is not set | ||
# CONFIG_COAP_AL_ENABLE is not set | ||
# CONFIG_LWM2M_AL_ENABLE is not set | ||
# CONFIG_MQTT_AL_ENABLE is not set | ||
CONFIG_OCSERVICES_ENABLE=y | ||
CONFIG_OCCOAP_ENABLE=y | ||
#CONFIG_OCLWM2M_ENABLE is not set | ||
# CONFIG_OCLWM2MTINY_ENABLE is not set | ||
CONFIG_BOUDICA120_ENABLE=y | ||
# CONFIG_OCLWM2MNULL is not set | ||
# CONFIG_OCLWM2M_DEMO_ENABLE is not set | ||
# CONFIG_OCMQTT_ENABLE is not set | ||
# CONFIG_OC_MQTTV1_PROFILE is not set | ||
# CONFIG_OC_MQTTV1_DEMO is not set | ||
# CONFIG_OC_MQTTV1_DEMO_BS is not set | ||
CONFIG_SHELL_ENABLE=y | ||
CONFIG_SHELL_TASK_STACKSIZE=2048 | ||
CONFIG_SHELL_TASK_PRIOR=10 | ||
CONFIG_IOT_LINK_CONFIGFILE="iot_config.h" | ||
# CONFIG_Demo_None is not set | ||
CONFIG_Demo_Use_Coap=y | ||
CONFIG_USER_DEMO="use_coap_demo" |
149 changes: 149 additions & 0 deletions
149
targets/STM32L476RG_NB476/Demos/use_coap_demo/use_coap_demo.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/*---------------------------------------------------------------------------- | ||
* 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. | ||
*---------------------------------------------------------------------------*/ | ||
/** | ||
* DATE AUTHOR INSTRUCTION | ||
* 2020-04-21 FanXinhao The first version | ||
* | ||
*/ | ||
#include <stdint.h> | ||
#include <stddef.h> | ||
#include <string.h> | ||
#include <los_typedef.h> | ||
#include <los_task.h> | ||
#include <boudica120_oc.h> | ||
#include <osal.h> | ||
#include <oc_coap_al.h> | ||
|
||
#include "dht11.h" | ||
#include "oled.h" | ||
|
||
//DHT11 Data Struct | ||
DHT11_Data_TypeDef dht11_data; | ||
unsigned char DHT11_str[10] = {0}; | ||
|
||
|
||
/* LWM2M server information */ | ||
#define cn_endpoint_id "coap_001" | ||
#define cn_app_server "119.3.250.80" | ||
#define cn_app_port "5683" | ||
|
||
//if your command is very fast,please use a queue here--TODO | ||
#define cn_app_rcv_buf_len 128 | ||
static int8_t s_rcv_buffer[cn_app_rcv_buf_len]; | ||
static int s_rcv_datalen; | ||
static osal_semp_t s_rcv_sync; | ||
|
||
//use this function to push all the message to the buffer | ||
static int app_msg_deal(void *msg, int len) | ||
{ | ||
int ret = -1; | ||
|
||
if(len <= cn_app_rcv_buf_len) | ||
{ | ||
memcpy(s_rcv_buffer,msg,len); | ||
s_rcv_datalen = len; | ||
|
||
osal_semp_post(s_rcv_sync); | ||
|
||
ret = 0; | ||
|
||
} | ||
return ret; | ||
} | ||
|
||
int coap_report_task(void *args) | ||
{ | ||
int* handle = NULL; | ||
oc_config_param_t oc_param; | ||
char Temp[10] = {00, 22}; | ||
oc_coap_imp_init(); | ||
|
||
memset(&oc_param,0,sizeof(oc_param)); | ||
|
||
oc_param.app_server.address = cn_app_server; | ||
oc_param.app_server.port = cn_app_port; | ||
oc_param.app_server.ep_id = cn_endpoint_id; | ||
oc_param.boot_mode = en_oc_boot_strap_mode_factory; | ||
oc_param.rcv_func = app_msg_deal; | ||
|
||
handle = oc_coap_config(&oc_param); | ||
if (NULL == handle) | ||
{ | ||
printf("config_init fail!\r\n"); | ||
} | ||
else | ||
{ | ||
printf("start send message to CDP server!\r\n"); | ||
} | ||
while(1) | ||
{ | ||
memset(DHT11_str, 0, 6); | ||
sprintf(Temp,"%02d",(int)dht11_data.temperature); | ||
oc_coap_report(handle, Temp, 2); | ||
osal_task_sleep(10*1000); | ||
} | ||
} | ||
|
||
int Read_DHT11_task(void *args) | ||
{ | ||
|
||
while(1) | ||
{ | ||
DHT11_Read_TempAndHumidity(&dht11_data);//read DHT11 | ||
/* oled display */ | ||
OLED_Clear(); | ||
OLED_ShowString(9, 0, "DHT11 Data", 10); | ||
memset(DHT11_str, 0, 6); | ||
sprintf(DHT11_str,"temp %5.2f",dht11_data.temperature); | ||
OLED_ShowString(9, 2, DHT11_str, 5); | ||
memset(DHT11_str, 0, 6); | ||
sprintf(DHT11_str,"humid %5.2f",dht11_data.humidity); | ||
OLED_ShowString(9, 4, DHT11_str, 5); | ||
|
||
osal_task_sleep(5*1000); | ||
|
||
} | ||
} | ||
|
||
int standard_app_demo_main() | ||
{ | ||
osal_task_create("coap_report",coap_report_task, NULL, 0x1000, NULL, 3); | ||
osal_task_create("Read_DHT11",Read_DHT11_task, NULL, 0x500, NULL, 3); | ||
return 0; | ||
} | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
################################################################################ | ||
# this is used for compile the user defined oc demo | ||
################################################################################ | ||
|
||
#if you have defined multiple demos by yourself, modify this file to compile the chosen demo. | ||
|
||
#example for LiteOS func | ||
|
||
|
||
#example for report temperature | ||
ifeq ($(CONFIG_USER_DEMO), "use_coap_demo") | ||
user_demo_src = ${wildcard $(TARGET_DIR)/Demos/use_coap_demo/*.c} | ||
user_demo_defs = -D CONFIG_USE_COAP_ENABLE=1 | ||
endif | ||
|
||
|
||
C_SOURCES += $(user_demo_src) | ||
C_INCLUDES += $(user_demo_inc) | ||
C_DEFS += $(user_demo_defs) |
Oops, something went wrong.