Skip to content

Commit c69d9bb

Browse files
authored
Merge pull request pine64#32 from shchen-Lab/bledemo
huawei cloud
2 parents 432847e + b24b797 commit c69d9bb

File tree

2,986 files changed

+951319
-5
lines changed

Some content is hidden

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

2,986 files changed

+951319
-5
lines changed

components/3rdparty/hwcloud_iot_link/bouffalo.mk

Lines changed: 594 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* Standard includes. */
2+
#include <stdint.h>
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
6+
/* FreeRTOS includes. */
7+
#include "FreeRTOS.h"
8+
#include "task.h"
9+
// #include "queue.h"
10+
11+
extern int link_main(void *args);
12+
void vStartCLOUDTasks_hwcloud(uint16_t usTaskStackSize, UBaseType_t uxTaskPriority)
13+
{
14+
BaseType_t x = 0L;
15+
16+
xTaskCreate(link_main, /* The function that implements the task. */
17+
"link_main", /* Just a text name for the task to aid debugging. */
18+
usTaskStackSize, /* The stack size is defined in FreeRTOSIPConfig.h. */
19+
(void *)x, /* The task parameter, not used in this case. */
20+
uxTaskPriority, /* The priority assigned to the task is defined in FreeRTOSConfig.h. */
21+
NULL); /* The task handle is not used. */
22+
23+
}
24+
25+
void example_hwcloud_iot_link(void)
26+
{
27+
28+
vStartCLOUDTasks_hwcloud(1000, tskIDLE_PRIORITY + 16);
29+
30+
}
31+
/*-----------------------------------------------------------*/
32+
33+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef __EXAMPLE_HWCLOUD_IOT_LINK_H
2+
#define __EXAMPLE_HWCLOUD_IOT_LINK_H
3+
4+
void example_hwcloud_iot_link(void);
5+
6+
#endif /* __EXAMPLE_HWCLOUD_IOT_LINK_H */
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
2+
#HuaweiCloud iot link config
3+
4+
######### HWCloud IoTLink ########################
5+
#enable FREERTOS_BL OSAL
6+
CONFIG_FREERTOS_BL_ENABLE := 1
7+
#enable LinkLog
8+
CONFIG_LINKLOG_ENABLE := 1
9+
#enable TcpIP AL
10+
CONFIG_TCIP_AL_ENABLE := 1
11+
#enable Lwip_BL
12+
CONFIG_LWIP_BL_ENABLE := 1
13+
#enable linkqueue
14+
CONFIG_LINKQUEUE_ENABLE := 1
15+
#enable cJSON
16+
#Attention: use cJSON in BLSDK
17+
CONFIG_CJSON_ENABLE := 0
18+
######### OC-LWM2M ########################
19+
#enable LWM2M_AL
20+
CONFIG_LWM2M_AL_ENABLE := 0
21+
#enable WAKAAMALWM2M
22+
CONFIG_WAKAAMALWM2M_ENABLE := 0
23+
#enable OCLWM2M
24+
CONFIG_OCLWM2M_ENABLE := 0
25+
#enable OCLWM2MTINY
26+
CONFIG_OCLWM2MTINY_ENABLE := 0
27+
######### OC-MQTT ########################
28+
#enable DTLS AL
29+
CONFIG_DTLS_AL_ENABLE := 1
30+
#enable mbedtls
31+
CONFIG_MBEDTLS_ENABLE := 1
32+
#enable mbedtls psk
33+
CONFIG_MBEDTLS_PSK := 1
34+
#enable MQTT AL
35+
CONFIG_MQTT_AL_ENABLE := 1
36+
#enable paho mqtt
37+
CONFIG_PAHO_MQTT := 1
38+
#enable oc mqtt
39+
CONFIG_OCMQTT_ENABLE := 1
40+
#enable oc_mqttv5 profile
41+
CONFIG_OC_MQTTV5_PROFILE := 1
42+
#enable oc tiny mqttv5
43+
CONFIG_OC_TINYMQTTV5_ENABLE := 1
44+
######### OC-COAP ########################
45+
#enable COAP_AL
46+
CONFIG_COAP_AL_ENABLE := 0
47+
#enable LIBCOAP
48+
CONFIG_LIBCOAP_ENABLE := 0
49+
#enable OCCOAP
50+
CONFIG_OCCOAP_ENABLE := 0
51+
#enable OCCOAPTINY
52+
CONFIG_OCCOAPTINY_ENABLE := 0
53+
######### DEMOS ########################
54+
#enable link demo
55+
CONFIG_LINKDEMO_ENABLE := 1
56+
#enable user demo
57+
# Attention: Only one type of demo can be selected when compiling
58+
CONFIG_USERDEMO_LWM2M_ENABLE := 0
59+
CONFIG_USERDEMO_MQTT_ENABLE := 1
60+
CONFIG_USERDEMO_COAP_ENABLE := 0
61+
###
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#
2+
# Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved.
3+
#
4+
# LiteOS NOVA is licensed under the Mulan PSL v1.
5+
# You can use this software according to the terms and conditions of the Mulan PSL v1.
6+
# You may obtain a copy of Mulan PSL v1 at:
7+
#
8+
# http://license.coscl.org.cn/MulanPSL
9+
#
10+
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER
11+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR
12+
# FIT FOR A PARTICULAR PURPOSE.
13+
# See the Mulan PSL v1 for more details.
14+
#
15+
16+
menu "IoT link SDK configuration"
17+
comment "you should choose a os kernel first!"
18+
19+
rsource "./os/Kconfig"
20+
rsource "./at/Kconfig"
21+
config CJSON_ENABLE
22+
bool "Enable cJson library."
23+
default y
24+
25+
config DRIVER_ENABLE
26+
bool "Enable IoT Link driver management."
27+
default y
28+
depends on LITEOS_ENABLE || NOVAOS_ENABLE || NEW_OS
29+
30+
rsource "./link_log/Kconfig"
31+
32+
33+
config LINKQUEUE_ENABLE
34+
bool "Enable IoT Link Queue"
35+
default y
36+
37+
config LINKDEMO_ENABLE
38+
bool "Enable IoT Link Demo"
39+
default y
40+
41+
rsource "./stimer/Kconfig"
42+
43+
rsource "./link_ota/Kconfig"
44+
45+
rsource "./network/Kconfig"
46+
47+
rsource "./oc/Kconfig"
48+
49+
rsource "./shell/Kconfig"
50+
51+
config IOT_LINK_CONFIGFILE
52+
string "The specified Configuration Header"
53+
default "iot_config.h"
54+
55+
endmenu
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#
2+
# Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved.
3+
#
4+
# LiteOS NOVA is licensed under the Mulan PSL v1.
5+
# You can use this software according to the terms and conditions of the Mulan PSL v1.
6+
# You may obtain a copy of Mulan PSL v1 at:
7+
#
8+
# http://license.coscl.org.cn/MulanPSL
9+
#
10+
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER
11+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR
12+
# FIT FOR A PARTICULAR PURPOSE.
13+
# See the Mulan PSL v1 for more details.
14+
#
15+
menu "At configuration"
16+
depends on LITEOS_ENABLE || NOVAOS_ENABLE || NEW_OS
17+
18+
config AT_ENABLE
19+
bool "Enable AT framework. and we will select the driver"
20+
select DRIVER_ENABLE
21+
default y
22+
23+
if AT_ENABLE
24+
25+
config AT_DEVNAME
26+
string "The device for the at io"
27+
default "atdev"
28+
29+
config AT_OOBTABLEN
30+
int "How many oob functions could be hooked"
31+
default 6
32+
33+
config AT_RECVMAXLEN
34+
int "The maxlen could be received for the at components"
35+
default 1024
36+
37+
config AT_TASKPRIOR
38+
int "The at receive task priority"
39+
default 10
40+
endif
41+
42+
endmenu
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
### AT客户端框架说明
2+
3+
为了让AT框架和硬件做解耦,特优化或者说是更新以前的版本,让AT框架的本质回归到AT。
4+
5+
#### 编译配置
6+
7+
在使用at框架之前,需要系统的配置文件配置CONFIG_AT_ENABLE。
8+
9+
使用KEIL以及IAR以及GCC等,可以定义编译条件宏,如在makefile中定义:
10+
```
11+
gcc -D CONFIG_AT_ENABLE=1 xxx
12+
```
13+
14+
如果使用make工具,则建议在makefile文件中直接包含AT组件目录下的at.mk即可
15+
16+
#### 组件安装
17+
安装该组件必须调用los_at_init进行初始化,需要使用者提供相关的AT通道设备
18+
19+
```
20+
/**
21+
* @brief: use this function to do the at client framwork initialized
22+
*
23+
* @return:0 success while -1 failed
24+
* */
25+
int at_init(const char *devname);
26+
```
27+
28+
为了保证AT框架和具体的硬件驱动解耦,此处使用的注册的设备驱动,开发者配置驱动设备的名字时。同时应该注意到,at设备接口的特点:开发者需要在意的是读取的一定是一帧AT返回数据,如果使用串口,可以用串口的IDLE中断来区别不同的帧;其他的设备接口也会有自己的相应说明该帧的区分形式(一般是几个字节的时间没有数据到达),当调用该函数之后,我们就可以使用at的接口发送AT命令了,同时我们提供了shell端口的atcmd命令用作调试(如果shell已经被配置的话);
29+
30+
#### AT命令使用
31+
32+
```
33+
/**
34+
* @brief:use this function to register a function that monitor the URC message
35+
* @param[in]:cmd, the command to send
36+
* @param[in]:cmdlen, the command length
37+
* @param[in]:index, the command index, if you don't need the response, set it to NULL; this must be a string
38+
* @param[in]:respbuf, if you need the response, you should supply the buffer
39+
* @param[in]:respbuflen,the respbuf length
40+
* @param[in]:timeout, the time you may wait for the response;and the unit is ms
41+
*
42+
* @return:0 success while -1 failed
43+
* */
44+
45+
int at_command(const void *cmd, size_t cmdlen,const char *index,\
46+
void *respbuf,size_t respbuflen,uint32_t timeout);
47+
```
48+
49+
#### AT上报数据监控
50+
51+
对于AT设备而言,除了我们发送命令其会返回数据外,其有可能会主动上报数据。为了处理该情况,提供该接口给用户使用监听。
52+
53+
```
54+
typedef int (*fn_at_oob)(void *args,void *data,size_t datalen);
55+
/**
56+
* @brief:use this function to register a function that monitor the URC message
57+
* @param[in]:name, which used for the at framework debug
58+
* @param[in]:inxdex, used for match the out of band data
59+
* @param[in]:length, index length, this is match length
60+
* @param[in]:func, supply the function that will execute when the index is matched
61+
* @paarm[in]:args, supply for the registered function
62+
*
63+
* @return:0 success while -1 failed
64+
* */
65+
int at_oobregister(const char *name,const void *index,size_t len,fn_at_oob func,void *args);
66+
```
67+
68+
用户注册该接口之后,当收到的数据命中index时,则会回调注册的func,同时将注册的arg参数传递给func;
69+
70+
有两点需要注意:
71+
1,注册的OOB的匹配是从接收报文的头进行匹配的;
72+
73+
2,注册的OOB的index允许是非ascii字符串,因为要求注册时必须指定index的长度

0 commit comments

Comments
 (0)