Skip to content

Commit 9c03561

Browse files
song-fthjunyoun-kim
authored andcommitted
support bsp bl602
1 parent 37613e7 commit 9c03561

Some content is hidden

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

45 files changed

+3972
-1
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "bsp/esp32"]
55
path = bsp/esp32
66
url = https://github.com/espressif/esp-idf.git
7+
[submodule "bsp/bl602"]
8+
path = bsp/bl602
9+
url = https://github.com/bouffalolab/bl_iot_sdk.git

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Install the toolchain defined in the chipset SDK you use according to the direct
5151
ex) python setup.py esp32
5252
ex) python setup.py esp32c3
5353
ex) python setup.py esp32s3
54+
ex) python setup.py bl602
5455
```
5556

5657
2. Check the build configuration of a sample device application (`apps` folder). If you want to use specific build options, you can directly modify the each chipset build configuration file (e.g. `sdkconfig.esp32`, `sdkconfig.esp32c3`,`sdkconfig.esp32s3`) at the root directory of a sample device application. On the Espressif chipset, you can additionally use the `menuconfig` option for configuration.
@@ -76,12 +77,16 @@ Install the toolchain defined in the chipset SDK you use according to the direct
7677
7778
```sh
7879
$ python build.py apps/esp32/switch_example # python build.py {app_path}
80+
7981
or
8082
$ python build.py esp32 switch_example # python build.py {bsp_name} {app_name}
8183
8284
# For other esp32 chipset series.
8385
$ python build.py esp32c3 switch_example
8486
$ python build.py esp32s3 switch_example
87+
88+
# For other bl602 chipset series.
89+
$ python build.py apps/bl602/switch_example
8590
```
8691
8792
### Flash and Monitor
@@ -92,6 +97,7 @@ The serial port of your device must to be matched to the computer environment fo
9297
|Chipset|Buad Rate for Flashing|Baud Rate for Monitoring|Data Bit|Parity|Stop Bits|
9398
|-------|----------------------|------------------------|--------|------|---|
9499
|ESP32|115200|74880|8|None|1|
100+
|BL602|2000000|2000000|8|None|1|
95101
96102
#### Flashing
97103
@@ -116,13 +122,25 @@ Available Options:
116122
# For other esp32 chipset series.
117123
$ python build.py esp32c3 switch_example clean
118124
$ python build.py esp32s3 switch_example clean
125+
126+
# For bl602 chipset series.
127+
$ python build.py apps/bl602/switch_example clean
119128
```
120129
- **flash**: download executable binaries to the device
130+
131+
# python build.py {app_path} {flash} {port}
132+
133+
# For bl602 chipset series.
134+
$ python build.py apps/bl602/switch_example flash /dev/ttyACM0
121135
- **monitor**: monitor the serial output of device. this option can be used with flash option.
122136
```sh
123137
# python build.py {app_path} {options}
124138
$ python build.py apps/esp32/switch_example flash monitor
125139
or
140+
141+
# For bl602 chipset series.
142+
$ python build.py apps/bl602/switch_example monitor /dev/ttyACM0
143+
126144
# python build.py {bsp_name} {app_name} {options}
127145
$ python build.py esp32 switch_example flash monitor
128146

apps/bl602/light_example/Makefile

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#
2+
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
3+
# project subdirectory.
4+
#
5+
6+
PROJECT_NAME := light_example
7+
PROJECT_PATH := $(abspath .)
8+
IOT_CORE_PATH := $(abspath ${PROJECT_PATH}/../../../iot-core)
9+
PROJECT_BOARD := evb
10+
export PROJECT_PATH PROJECT_BOARD IOT_CORE_PATH
11+
#CONFIG_TOOLPREFIX :=
12+
13+
BLECONTROLLER_LIBS := m1s1 m0s1 m0s1s
14+
BLECONTROLLER_LIB_DEFAULT := m1s1
15+
BLECONTROLLER_LIB_PREFIX := blecontroller_602_
16+
17+
CPPFLAGS += -I$(PROJECT_PATH)
18+
19+
-include ./proj_config.mk
20+
IOT_CORE_COMPONENTS := src
21+
IOT_CORE_COMPONENTS_REAL_PATH = $(abspath ${IOT_CORE_PATH}/src/)
22+
23+
ifeq ($(origin BL60X_SDK_PATH), undefined)
24+
BL60X_SDK_PATH_GUESS ?= $(shell pwd)
25+
BL60X_SDK_PATH ?= $(BL60X_SDK_PATH_GUESS)/../../../bsp/bl602
26+
$(info ****** Please SET BL60X_SDK_PATH ******)
27+
$(info ****** Trying SDK PATH [$(BL60X_SDK_PATH)])
28+
endif
29+
30+
COMPONENTS_NETWORK := sntp dns_server
31+
COMPONENTS_BLSYS := bltime blfdt blmtd blota bloop loopadc looprt loopset
32+
COMPONENTS_VFS := romfs
33+
34+
ifeq ($(CONFIG_BLECONTROLLER_LIB),all)
35+
COMPONENTS_BLECONTROLLER := $(addprefix $(BLECONTROLLER_LIB_PREFIX), $(BLECONTROLLER_LIBS))
36+
else
37+
ifeq ($(findstring $(CONFIG_BLECONTROLLER_LIB), $(BLECONTROLLER_LIBS)),)
38+
COMPONENTS_BLECONTROLLER := $(addprefix $(BLECONTROLLER_LIB_PREFIX), $(BLECONTROLLER_LIB_DEFAULT))
39+
else
40+
COMPONENTS_BLECONTROLLER := $(addprefix $(BLECONTROLLER_LIB_PREFIX), $(CONFIG_BLECONTROLLER_LIB))
41+
endif
42+
endif
43+
44+
ifeq ($(CONFIG_BT_TL),1)
45+
COMPONENTS_BLE := $(COMPONENTS_BLECONTROLLER)
46+
else
47+
COMPONENTS_BLE := $(COMPONENTS_BLECONTROLLER) blestack
48+
endif
49+
50+
INCLUDE_COMPONENTS += freertos_riscv_ram newlibc bl602 bl602_std newlibc wifi blcrypto_suite wifi_manager wpa_supplicant bl_os_adapter wifi_hosal hosal lwip lwip_dhcpd mbedtls_lts vfs yloop utils cli httpc netutils blog wifi_bt_coex
51+
INCLUDE_COMPONENTS += easyflash4 lwip_altcp_tls_mbedtls coredump rfparam_adapter_tmp
52+
INCLUDE_COMPONENTS += $(COMPONENTS_NETWORK)
53+
INCLUDE_COMPONENTS += $(COMPONENTS_BLSYS)
54+
INCLUDE_COMPONENTS += $(COMPONENTS_VFS)
55+
INCLUDE_COMPONENTS += $(PROJECT_NAME)
56+
57+
EXTRA_COMPONENT_DIRS ?= $(IOT_CORE_PATH)
58+
INCLUDE_COMPONENTS += src
59+
60+
ifeq ($(CONFIG_COMPONENT_BUGKILLER_ENABLE),1)
61+
INCLUDE_COMPONENTS += bugkiller_freertos
62+
endif
63+
64+
ifeq ($(CONFIG_BT),1)
65+
INCLUDE_COMPONENTS += $(COMPONENTS_BLE)
66+
ifeq ($(CONFIG_BT_MESH),1)
67+
INCLUDE_COMPONENTS += blemesh
68+
ifeq ($(CONFIG_BT_MESH_MODEL),1)
69+
INCLUDE_COMPONENTS += blemesh_model
70+
endif
71+
endif
72+
73+
ifeq ($(CONFIG_BT_MESH_SYNC),1)
74+
INCLUDE_COMPONENTS += blsync_ble
75+
endif
76+
ifeq ($(CONFIG_AUTO_PTS),1)
77+
INCLUDE_COMPONENTS += bleptstest
78+
endif
79+
endif
80+
CPPFLAGS += -include $(IOT_CORE_PATH)/src/include/iot_common.h
81+
include $(BL60X_SDK_PATH)/make_scripts_riscv/project.mk
82+
$(info !************ $(CFLAGS))
83+
84+
ifeq ($(CONFIG_BLECONTROLLER_LIB),all)
85+
LDFLAGS := $(filter-out $(addprefix -l$(BLECONTROLLER_LIB_PREFIX), $(filter-out $(BLECONTROLLER_LIB_DEFAULT), $(BLECONTROLLER_LIBS))), $(LDFLAGS))
86+
endif

apps/bl602/light_example/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# SmartThings SDK for Direct Connected Devices for C - Switch Example
2+
3+
## Introduction
4+
5+
SmartThings direct-connected device is Wi-Fi enabled device that uses the SmartThings cloud as its primary cloud infrastructure. And this device will use the MQTT protocol for communication.
6+
7+
## Getting started
8+
9+
For information on detailed workflow, please refer to the [Getting Started](../../../doc/getting_started.md)
10+
11+
## Components and Capabilities
12+
13+
SmartThings Device is defined using components and capabilities. Capabilities define the features of the device, and capabilities are grouped into components.
14+
Components and Capabilities are contained in device profile. You can create a device profile in Developer Workspace and associate it with an integration.
15+
16+
This example assumes the following component and capabilities are used. :
17+
18+
`main` component
19+
- `healthCheck` capability
20+
- `switch` capability
21+
- `switchLevel` capability
22+
- `colorTemperature` capability
23+
- `activityLightingMode` capability
24+
25+
`monitor` component
26+
- `dustSensor` capability
27+
28+
(`healthCheck` capability is automatically added by Developer Workspace. It doesn't need handler at device side)
29+
30+
## SmartThings SDK for Direct Connected Devices - Config
31+
If you want to use specific SmartThings Device SDK build options, you can directly modify the build configuration file. For this example, SmartThings Device SDK config is saved in 'proj_config.mk' file. If you want to change this, please execute the following :
32+
```sh
33+
$ cd ~/st-device-sdk-c-ref/
34+
$ vim apps/bl602/light_example/proj_config.mk
35+
```
36+
37+
## Test device schematics
38+
This example uses BL602 GPIO like below.
39+
Please refer below picture for __BL602-IoT-DVK-3S__.
40+
> Note: If your device's schematics doesn't match with belows.
41+
> Please modify GPIO defines for your device at [device_control.h](main/device_control.h)
42+
> ```c
43+
> #define GPIO_INPUT_BUTTON 1
44+
> #define GPIO_OUTPUT_COLORLED_R 4
45+
> #define GPIO_OUTPUT_COLORLED_G 5
46+
> #define GPIO_OUTPUT_COLORLED_B 3
47+
> ```
48+
49+
### BL602-IoT-DVK-3S
50+
| BL602-IoT-DVK-3S |
51+
|-------------------------------------------------------------------|
52+
|![BL602-IoT-DVK-3S](../../../doc/res/BL602-IoT-DVK-3S.jpg) |
53+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# "main" pseudo-component makefile.
3+
#
4+
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
5+
6+
include $(BL60X_SDK_PATH)/components/network/ble/ble_common.mk
7+
8+
ifeq ($(CONFIG_ENABLE_PSM_RAM),1)
9+
CPPFLAGS += -DCONF_USER_ENABLE_PSRAM
10+
endif
11+
12+
ifeq ($(CONFIG_ENABLE_CAMERA),1)
13+
CPPFLAGS += -DCONF_USER_ENABLE_CAMERA
14+
endif
15+
16+
ifeq ($(CONFIG_ENABLE_BLSYNC),1)
17+
CPPFLAGS += -DCONF_USER_ENABLE_BLSYNC
18+
endif
19+
20+
ifeq ($(CONFIG_ENABLE_VFS_SPI),1)
21+
CPPFLAGS += -DCONF_USER_ENABLE_VFS_SPI
22+
endif
23+
24+
ifeq ($(CONFIG_ENABLE_VFS_ROMFS),1)
25+
CPPFLAGS += -DCONF_USER_ENABLE_VFS_ROMFS
26+
endif
27+
28+
ifeq ($(CONFIG_TD_DIAGNOSIS_STA),1)
29+
CPPFLAGS += -DTD_DIAGNOSIS_STA
30+
endif
31+
32+
33+
# define json files list
34+
COMPONENT_EMBED_TXTFILES := onboarding_config.json device_info.json
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/* ***************************************************************************
2+
*
3+
* Copyright 2019-2020 Samsung Electronics All Rights Reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14+
* either express or implied. See the License for the specific
15+
* language governing permissions and limitations under the License.
16+
*
17+
****************************************************************************/
18+
19+
#include <string.h>
20+
#include <stdio.h>
21+
#include <stdlib.h>
22+
23+
#include "st_dev.h"
24+
#include "caps_activityLightingMode.h"
25+
26+
static int caps_activityLightingMode_attr_lightingMode_str2idx(const char *value)
27+
{
28+
int index;
29+
30+
for (index = 0; index < CAP_ENUM_ACTIVITYLIGHTINGMODE_LIGHTINGMODE_VALUE_MAX; index++) {
31+
if (!strcmp(value, caps_helper_activityLightingMode.attr_lightingMode.values[index])) {
32+
return index;
33+
}
34+
}
35+
return -1;
36+
}
37+
38+
static const char *caps_activityLightingMode_get_lightingMode_value(caps_activityLightingMode_data_t *caps_data)
39+
{
40+
if (!caps_data) {
41+
printf("caps_data is NULL\n");
42+
return NULL;
43+
}
44+
return caps_data->lightingMode_value;
45+
}
46+
47+
static void caps_activityLightingMode_set_lightingMode_value(caps_activityLightingMode_data_t *caps_data, const char *value)
48+
{
49+
if (!caps_data) {
50+
printf("caps_data is NULL\n");
51+
return;
52+
}
53+
if (caps_data->lightingMode_value) {
54+
free(caps_data->lightingMode_value);
55+
}
56+
caps_data->lightingMode_value = strdup(value);
57+
}
58+
59+
static void caps_activityLightingMode_attr_lightingMode_send(caps_activityLightingMode_data_t *caps_data)
60+
{
61+
int sequence_no = -1;
62+
63+
if (!caps_data || !caps_data->handle) {
64+
printf("fail to get handle\n");
65+
return;
66+
}
67+
if (!caps_data->lightingMode_value) {
68+
printf("value is NULL\n");
69+
return;
70+
}
71+
72+
ST_CAP_SEND_ATTR_STRING(caps_data->handle,
73+
(char *)caps_helper_activityLightingMode.attr_lightingMode.name,
74+
caps_data->lightingMode_value,
75+
NULL,
76+
NULL,
77+
sequence_no);
78+
79+
if (sequence_no < 0)
80+
printf("fail to send lightingMode value\n");
81+
else
82+
printf("Sequence number return : %d\n", sequence_no);
83+
84+
}
85+
86+
87+
static void caps_activityLightingMode_cmd_setLightingMode_cb(IOT_CAP_HANDLE *handle, iot_cap_cmd_data_t *cmd_data, void *usr_data)
88+
{
89+
caps_activityLightingMode_data_t *caps_data = (caps_activityLightingMode_data_t *)usr_data;
90+
char *value;
91+
int index;
92+
93+
printf("called [%s] func with num_args:%u\n", __func__, cmd_data->num_args);
94+
95+
index = caps_activityLightingMode_attr_lightingMode_str2idx(cmd_data->cmd_data[0].string);
96+
if (index < 0) {
97+
printf("%s is not supported value for setLightingMode\n", cmd_data->cmd_data[0].string);
98+
return;
99+
}
100+
value = (char *)caps_helper_activityLightingMode.attr_lightingMode.values[index];
101+
102+
caps_activityLightingMode_set_lightingMode_value(caps_data, value);
103+
if (caps_data && caps_data->cmd_setLightingMode_usr_cb)
104+
caps_data->cmd_setLightingMode_usr_cb(caps_data);
105+
caps_activityLightingMode_attr_lightingMode_send(caps_data);
106+
}
107+
108+
static void caps_activityLightingMode_init_cb(IOT_CAP_HANDLE *handle, void *usr_data)
109+
{
110+
caps_activityLightingMode_data_t *caps_data = usr_data;
111+
if (caps_data && caps_data->init_usr_cb)
112+
caps_data->init_usr_cb(caps_data);
113+
caps_activityLightingMode_attr_lightingMode_send(caps_data);
114+
}
115+
116+
caps_activityLightingMode_data_t *caps_activityLightingMode_initialize(IOT_CTX *ctx, const char *component, void *init_usr_cb, void *usr_data)
117+
{
118+
caps_activityLightingMode_data_t *caps_data = NULL;
119+
int err;
120+
121+
caps_data = malloc(sizeof(caps_activityLightingMode_data_t));
122+
if (!caps_data) {
123+
printf("fail to malloc for caps_activityLightingMode_data\n");
124+
return NULL;
125+
}
126+
127+
memset(caps_data, 0, sizeof(caps_activityLightingMode_data_t));
128+
129+
caps_data->init_usr_cb = init_usr_cb;
130+
caps_data->usr_data = usr_data;
131+
132+
caps_data->get_lightingMode_value = caps_activityLightingMode_get_lightingMode_value;
133+
caps_data->set_lightingMode_value = caps_activityLightingMode_set_lightingMode_value;
134+
caps_data->attr_lightingMode_str2idx = caps_activityLightingMode_attr_lightingMode_str2idx;
135+
caps_data->attr_lightingMode_send = caps_activityLightingMode_attr_lightingMode_send;
136+
if (ctx) {
137+
caps_data->handle = st_cap_handle_init(ctx, component, caps_helper_activityLightingMode.id, caps_activityLightingMode_init_cb, caps_data);
138+
}
139+
if (caps_data->handle) {
140+
err = st_cap_cmd_set_cb(caps_data->handle, caps_helper_activityLightingMode.cmd_setLightingMode.name, caps_activityLightingMode_cmd_setLightingMode_cb, caps_data);
141+
if (err) {
142+
printf("fail to set cmd_cb for setLightingMode of activityLightingMode\n");
143+
}
144+
} else {
145+
printf("fail to init activityLightingMode handle\n");
146+
}
147+
148+
return caps_data;
149+
}

0 commit comments

Comments
 (0)