Skip to content

Commit f4effe5

Browse files
jczhang777wy-hh
andauthored
[BL602] Update flash tool, add mac os flash tool,add ipv6 get addr ho… (#22897)
* [BL602] Update flash tool, add mac os flash tool,add ipv6 get addr hook,update readme ,add board link,update ble impl, fix support phone commission (#22798) * Update SDK repo and turn on light when power up with un-commission state Co-authored-by: wyhong <[email protected]>
1 parent 4f7669b commit f4effe5

Some content is hidden

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

58 files changed

+1024
-568
lines changed

.github/workflows/examples-bouffalolab.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ jobs:
5656
timeout-minutes: 30
5757
run: |
5858
./scripts/run_in_build_env.sh \
59-
"./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light build"
59+
"./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-light build"
6060
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl702 bl702 lighting-app \
61-
out/bouffalolab-BL706-IoT-DVK-BL706C-22-light/chip-bl702-lighting-example.out /tmp/bloat_reports/
61+
out/bouffalolab-BL706-IoT-DVK-light/chip-bl702-lighting-example.out /tmp/bloat_reports/
6262
6363
- name: Build example BL702 Lighting App with RPCs
6464
timeout-minutes: 30
6565
run: |
6666
./scripts/run_in_build_env.sh \
67-
"./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc build"
67+
"./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-light-rpc build"
6868
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl702 bl702+rpc lighting-app \
69-
out/bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc/chip-bl702-lighting-example.out /tmp/bloat_reports/
69+
out/bouffalolab-BL706-IoT-DVK-light-rpc/chip-bl702-lighting-example.out /tmp/bloat_reports/
7070
7171
- name: Uploading Size Reports
7272
uses: actions/upload-artifact@v2

examples/lighting-app/bouffalolab/bl602/BUILD.gn

+3
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ bl602_executable("lighting_app") {
8181
sources = [
8282
#"${bl602_project_dir}/include/CHIPProjectConfig.h",
8383
"${examples_plat_dir}/InitPlatform.cpp",
84+
"${examples_plat_dir}/route_hook/bl_route_hook.c",
85+
"${examples_plat_dir}/route_hook/bl_route_table.c",
8486
"include/CHIPProjectConfig.h",
8587
"src/AppTask.cpp",
8688
"src/CHIPDeviceManager.cpp",
@@ -162,6 +164,7 @@ bl602_executable("lighting_app") {
162164
include_dirs += [
163165
"${chip_root}/examples/common",
164166
"${chip_root}/examples/common/pigweed/bouffalolab/bl602",
167+
"${examples_plat_dir}/route_hook",
165168
]
166169
}
167170

examples/lighting-app/bouffalolab/bl602/README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
This example functions as a wifi light bulb device type, with on/off
44
capabilities. The steps were verified on BL602-IoT-Matter-V1 board.
55

6-
BL602-IoT-Matter-V1 board:
6+
BL602-IoT-Matter-V1 board and
7+
[purchase link](https://www.amazon.com/dp/B0B9ZVGXD8):
78
<img src="../../../platform/bouffalolab/bl602/doc/images/BL602-IoT-Matter_V1.png" style="zoom:25%;" />
89

910
## Initial setup
@@ -66,7 +67,7 @@ The steps in this document were validated on Ubuntu 18.04 and 20.04.
6667
```
6768
cd third_party/bouffalolab/repo/tools/flash_tool
6869
69-
./bflb_iot_tool --chipname=BL602 --baudrate=115200 --port=/dev/ttyACM0 --pt=chips/bl602/partition/partition_cfg_4M.toml --dts=chips/bl602/device_tree/bl_factory_params_IoTKitA_40M.dts --firmware=../../../../../out/bl602-light/chip-bl602-lighting-example.bin
70+
./bflb_iot_tool-ubuntu --chipname=BL602 --baudrate=115200 --port=/dev/ttyACM0 --pt=chips/bl602/partition/partition_cfg_4M.toml --dts=chips/bl602/device_tree/bl_factory_params_IoTKitA_40M.dts --firmware=../../../../../out/bl602-light/chip-bl602-lighting-example.bin
7071
```
7172
7273
```

examples/lighting-app/bouffalolab/bl602/include/AppTask.h

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class AppTask
4949
void PostEvent(const AppEvent * event);
5050
void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction);
5151
void LightStateUpdateEventHandler(void);
52+
void LightStateInit(void);
5253

5354
private:
5455
friend AppTask & GetAppTask(void);

examples/lighting-app/bouffalolab/bl602/include/CHIPDeviceManager.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ class DLL_EXPORT CHIPDeviceManagerCallbacks
7070
* @param size size of the attribute
7171
* @param value pointer to the new value
7272
*/
73-
void PostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
74-
uint8_t type, uint16_t size, uint8_t * value)
73+
virtual void PostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
74+
uint8_t type, uint16_t size, uint8_t * value)
7575
{}
7676
// virtual ~CHIPDeviceManagerCallbacks();
7777
};

examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ CHIP_ERROR AppTask::Init()
153153
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
154154

155155
InitButtons();
156+
156157
#if PW_RPC_ENABLED
157158
chip::rpc::Init();
158159
#endif
@@ -576,10 +577,24 @@ void AppTask::LightStateUpdateEventHandler(void)
576577
{
577578
statusLED.SetBrightness(0);
578579
statusLED.Set(0);
580+
PostLightActionRequest(AppEvent::kEventType_Light, LightingManager::OFF_ACTION);
579581
}
580582
else
581583
{
582584
statusLED.SetBrightness(level);
585+
PostLightActionRequest(AppEvent::kEventType_Light, LightingManager::ON_ACTION);
583586
}
584587
} while (0);
585588
}
589+
590+
void AppTask::LightStateInit(void)
591+
{
592+
uint8_t onoff = 1;
593+
uint8_t level = 254;
594+
EndpointId endpoint = 1;
595+
596+
emberAfWriteAttribute(endpoint, ZCL_LEVEL_CONTROL_CLUSTER_ID, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, (uint8_t *) &level,
597+
ZCL_INT8U_ATTRIBUTE_TYPE);
598+
599+
emberAfWriteAttribute(endpoint, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &onoff, ZCL_BOOLEAN_ATTRIBUTE_TYPE);
600+
}

examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <app/util/util.h>
3838
#include <lib/dnssd/Advertiser.h>
3939
#include <lib/support/CodeUtils.h>
40+
#include <route_hook/bl_route_hook.h>
4041

4142
using namespace ::chip;
4243
using namespace ::chip::Inet;
@@ -47,7 +48,6 @@ uint32_t identifyTimerCount;
4748
constexpr uint32_t kIdentifyTimerDelayMS = 250;
4849

4950
static LEDWidget statusLED1;
50-
// static LEDWidget statusLED2;
5151

5252
void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg)
5353
{
@@ -67,6 +67,7 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_
6767

6868
case DeviceEventType::kCommissioningComplete:
6969
log_info("Commissioning complete\r\n");
70+
GetAppTask().LightStateInit();
7071
break;
7172

7273
case DeviceEventType::kWiFiConnectivityChange:
@@ -85,6 +86,12 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_
8586
// newly selected address.
8687
chip::app::DnssdServer::Instance().StartServer();
8788
}
89+
90+
if (event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV6_Assigned)
91+
{
92+
ChipLogProgress(DeviceLayer, "Initializing route hook...");
93+
bl_route_hook_init();
94+
}
8895
break;
8996
}
9097
}
@@ -125,15 +132,11 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event
125132
if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established)
126133
{
127134
log_info("IPv4 Server ready...\r\n");
128-
// TODO
129-
// wifiLED.Set(true);
130135
chip::app::DnssdServer::Instance().StartServer();
131136
}
132137
else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost)
133138
{
134139
log_info("Lost IPv4 connectivity...\r\n");
135-
// TODO
136-
// wifiLED.Set(false);
137140
}
138141
if (event->InternetConnectivityChange.IPv6 == kConnectivity_Established)
139142
{

examples/lighting-app/bouffalolab/bl702/README.md

+34-28
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# CHIP BL702 Lighting App Example
1+
# CHIP BL70X Lighting App Example
22

3-
## Supported Hardware
3+
BL70X is highly integrated BLE and IEEE 802.15.4 combo chip for IoT
4+
applications, and BL702 is a general name for BL70X family.
45

5-
Current supported develop boards:
6+
This example is powered by BL706 and functions as a Thread light bulb device
7+
type, with on/off, level and color capabilities. The steps were verified with
8+
following boards:
69

7-
- BL702-IoT-DVK
8-
- BL706-IoT-DVK
9-
- BL706-NIGHT-LIGHT
10-
> Note, please make sure both of flash and `PSRAM` shipped with develop
11-
> board/device are at lease 2MB.
10+
- BL706-IoT-DVK
11+
- BL706-NIGHT-LIGHT
1212

1313
## Build
1414

@@ -49,51 +49,57 @@ Current supported develop boards:
4949
./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-IoT-DVK
5050
```
5151

52-
- Build lighting-app for board BL702-IOT-DVK module_type is
53-
`BL706C-22` by default. Please execute the following command to
54-
build lighting-app for BL702-IoT-DVK with module `BL702`
55-
56-
```shell
57-
./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL702-IoT-DVK module_type="BL702"
58-
```
59-
6052
- Build lighting-app for board BL706-NIGHT-LIGHT
6153

62-
```shell
63-
./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-NIGHT-LIGHT module_type="BL702"
64-
```
65-
66-
> Note, please check which module is used on the board.
54+
```shell
55+
./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-NIGHT-LIGHT
56+
```
6757

68-
- With UART shell command support:
58+
- With UART shell command enabled:
6959

7060
```shell
7161
./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-IoT-DVK chip_build_libshell=true
7262
```
7363

74-
- With pigweed RPC support:
64+
- With pigweed RPC enabled:
7565
```shell
7666
./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-IoT-DVK 'import("//with_pw_rpc.gni")'
7767
```
7868
> Note, UART shell command and pigweed RPC can not build together.
7969

8070
- Build with `build_examples.py`
8171

82-
- Build for BL702-IoT-DVK, BL706-IoT-DVK and BL706-NIGHT-LIGHT as
83-
following commands.
72+
- Build for BL706-IoT-DVK and BL706-NIGHT-LIGHT as following commands.
8473

8574
```shell
86-
./scripts/build/build_examples.py --target bouffalolab-BL702-IoT-DVK-light build
8775
./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light build
8876
./scripts/build/build_examples.py --target bouffalolab-BL706-NIGHT-LIGHT-light build
8977
```
9078

91-
- Build with pigweed RPC support as following commands.
79+
- Build with pigweed RPC enabled as following commands.
9280
```shell
93-
./scripts/build/build_examples.py --target bouffalolab-BL702-IoT-DVK-light-rpc build
9481
./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc build
9582
```
9683

84+
- Build options
85+
86+
- Build options list There are some build options for function and debug
87+
purpose as below.
88+
- `chip_build_libshell`, whether to enable shell command line. It is
89+
set to false by default.
90+
- `baudrate`, UART baudrate for log output or shell command line.
91+
- `enable_psram`, whether to enable `PSRAM`. It is set to true by
92+
default.
93+
- How to use Before using these build options, please check whether they
94+
are available to configure in BUILD.gn file under example application
95+
folder.
96+
- build with `build_examples.py` Modify value of build options in
97+
BUILD.gn file under example application folder.
98+
- build with gn_bouffalolab_example.sh Input build options, such as
99+
```
100+
./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-IoT-DVK chip_build_libshell=true
101+
```
102+
97103
- Download image
98104

99105
- Using script `chip-bl702-lighting-example.flash.py`.

examples/lighting-app/bouffalolab/bl702/src/AppTask.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ void AppTask::AppTaskMain(void * pvParameter)
334334
if (APP_EVENT_SYS_BLE_ADV & appEvent)
335335
{
336336
LightingSetStatus(APP_EVENT_SYS_BLE_ADV);
337+
LightingUpdate(APP_EVENT_LIGHTING_GO_THROUGH);
337338
isStateReady = false;
338339
}
339340

0 commit comments

Comments
 (0)