Skip to content

Commit

Permalink
Update flash tool, add mac os flash tool,add ipv6 get addr hook,updat…
Browse files Browse the repository at this point in the history
…e readme ,add board link,update ble impl, fix support phone commission (#22798)

* change properties of C2 Characteristic of BLE GATT to indication

* change properties of C2 Characteristic of BLE GATT to indication for BL702

* update supported boards

* [BL602] 1.Update flash tool, 2.Add ipv6 get ip hook

* [BL602] Fix board led onoff

* update README.md

* correct spell

* update workflow build

* [BL602] Update flash tool name

* Restyled by prettier-markdown

* [BL602] Remove not use code

* Restyled by clang-format

* [BL616] Restyled

* Sync ZCL State to LightingManager State setting

* Restyled by clang-format

* fix license conflict

* fix license conflict-1

* fix license conflict-2

* specifiy bfbl_iot_tool version

* [BL602] Delete not use code

Co-authored-by: wyhong <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: wyhong <[email protected]>
Co-authored-by: shchen-Lab <[email protected]>
Co-authored-by: shchen-Lab <[email protected]>
  • Loading branch information
6 people authored and pull[bot] committed Jan 5, 2023
1 parent 457e98c commit 46023e8
Show file tree
Hide file tree
Showing 57 changed files with 1,023 additions and 568 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/examples-bouffalolab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ jobs:
timeout-minutes: 30
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light build"
"./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-light build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl702 bl702 lighting-app \
out/bouffalolab-BL706-IoT-DVK-BL706C-22-light/chip-bl702-lighting-example.out /tmp/bloat_reports/
out/bouffalolab-BL706-IoT-DVK-light/chip-bl702-lighting-example.out /tmp/bloat_reports/
- name: Build example BL702 Lighting App with RPCs
timeout-minutes: 30
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc build"
"./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-light-rpc build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl702 bl702+rpc lighting-app \
out/bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc/chip-bl702-lighting-example.out /tmp/bloat_reports/
out/bouffalolab-BL706-IoT-DVK-light-rpc/chip-bl702-lighting-example.out /tmp/bloat_reports/
- name: Uploading Size Reports
uses: actions/upload-artifact@v2
Expand Down
3 changes: 3 additions & 0 deletions examples/lighting-app/bouffalolab/bl602/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ bl602_executable("lighting_app") {
sources = [
#"${bl602_project_dir}/include/CHIPProjectConfig.h",
"${examples_plat_dir}/InitPlatform.cpp",
"${examples_plat_dir}/route_hook/bl_route_hook.c",
"${examples_plat_dir}/route_hook/bl_route_table.c",
"include/CHIPProjectConfig.h",
"src/AppTask.cpp",
"src/CHIPDeviceManager.cpp",
Expand Down Expand Up @@ -162,6 +164,7 @@ bl602_executable("lighting_app") {
include_dirs += [
"${chip_root}/examples/common",
"${chip_root}/examples/common/pigweed/bouffalolab/bl602",
"${examples_plat_dir}/route_hook",
]
}

Expand Down
5 changes: 3 additions & 2 deletions examples/lighting-app/bouffalolab/bl602/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
This example functions as a wifi light bulb device type, with on/off
capabilities. The steps were verified on BL602-IoT-Matter-V1 board.

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

## Initial setup
Expand Down Expand Up @@ -66,7 +67,7 @@ The steps in this document were validated on Ubuntu 18.04 and 20.04.
```
cd third_party/bouffalolab/repo/tools/flash_tool
./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
./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
```
```
Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/bouffalolab/bl602/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class AppTask
void PostEvent(const AppEvent * event);
void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction);
void LightStateUpdateEventHandler(void);
void LightStateInit(void);

private:
friend AppTask & GetAppTask(void);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class DLL_EXPORT CHIPDeviceManagerCallbacks
* @param size size of the attribute
* @param value pointer to the new value
*/
void PostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
uint8_t type, uint16_t size, uint8_t * value)
virtual void PostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
uint8_t type, uint16_t size, uint8_t * value)
{}
// virtual ~CHIPDeviceManagerCallbacks();
};
Expand Down
15 changes: 15 additions & 0 deletions examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ CHIP_ERROR AppTask::Init()
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));

InitButtons();

#if PW_RPC_ENABLED
chip::rpc::Init();
#endif
Expand Down Expand Up @@ -576,10 +577,24 @@ void AppTask::LightStateUpdateEventHandler(void)
{
statusLED.SetBrightness(0);
statusLED.Set(0);
PostLightActionRequest(AppEvent::kEventType_Light, LightingManager::OFF_ACTION);
}
else
{
statusLED.SetBrightness(level);
PostLightActionRequest(AppEvent::kEventType_Light, LightingManager::ON_ACTION);
}
} while (0);
}

void AppTask::LightStateInit(void)
{
uint8_t onoff = 1;
uint8_t level = 254;
EndpointId endpoint = 1;

emberAfWriteAttribute(endpoint, ZCL_LEVEL_CONTROL_CLUSTER_ID, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, (uint8_t *) &level,
ZCL_INT8U_ATTRIBUTE_TYPE);

emberAfWriteAttribute(endpoint, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &onoff, ZCL_BOOLEAN_ATTRIBUTE_TYPE);
}
13 changes: 8 additions & 5 deletions examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <app/util/util.h>
#include <lib/dnssd/Advertiser.h>
#include <lib/support/CodeUtils.h>
#include <route_hook/bl_route_hook.h>

using namespace ::chip;
using namespace ::chip::Inet;
Expand All @@ -47,7 +48,6 @@ uint32_t identifyTimerCount;
constexpr uint32_t kIdentifyTimerDelayMS = 250;

static LEDWidget statusLED1;
// static LEDWidget statusLED2;

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

case DeviceEventType::kCommissioningComplete:
log_info("Commissioning complete\r\n");
GetAppTask().LightStateInit();
break;

case DeviceEventType::kWiFiConnectivityChange:
Expand All @@ -85,6 +86,12 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_
// newly selected address.
chip::app::DnssdServer::Instance().StartServer();
}

if (event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV6_Assigned)
{
ChipLogProgress(DeviceLayer, "Initializing route hook...");
bl_route_hook_init();
}
break;
}
}
Expand Down Expand Up @@ -125,15 +132,11 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event
if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established)
{
log_info("IPv4 Server ready...\r\n");
// TODO
// wifiLED.Set(true);
chip::app::DnssdServer::Instance().StartServer();
}
else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost)
{
log_info("Lost IPv4 connectivity...\r\n");
// TODO
// wifiLED.Set(false);
}
if (event->InternetConnectivityChange.IPv6 == kConnectivity_Established)
{
Expand Down
62 changes: 34 additions & 28 deletions examples/lighting-app/bouffalolab/bl702/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# CHIP BL702 Lighting App Example
# CHIP BL70X Lighting App Example

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

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

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

## Build

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

- Build lighting-app for board BL702-IOT-DVK module_type is
`BL706C-22` by default. Please execute the following command to
build lighting-app for BL702-IoT-DVK with module `BL702`

```shell
./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL702-IoT-DVK module_type="BL702"
```

- Build lighting-app for board BL706-NIGHT-LIGHT

```shell
./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-NIGHT-LIGHT module_type="BL702"
```

> Note, please check which module is used on the board.
```shell
./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-NIGHT-LIGHT
```

- With UART shell command support:
- With UART shell command enabled:

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

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

- Build with `build_examples.py`

- Build for BL702-IoT-DVK, BL706-IoT-DVK and BL706-NIGHT-LIGHT as
following commands.
- Build for BL706-IoT-DVK and BL706-NIGHT-LIGHT as following commands.

```shell
./scripts/build/build_examples.py --target bouffalolab-BL702-IoT-DVK-light build
./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light build
./scripts/build/build_examples.py --target bouffalolab-BL706-NIGHT-LIGHT-light build
```

- Build with pigweed RPC support as following commands.
- Build with pigweed RPC enabled as following commands.
```shell
./scripts/build/build_examples.py --target bouffalolab-BL702-IoT-DVK-light-rpc build
./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc build
```

- Build options

- Build options list There are some build options for function and debug
purpose as below.
- `chip_build_libshell`, whether to enable shell command line. It is
set to false by default.
- `baudrate`, UART baudrate for log output or shell command line.
- `enable_psram`, whether to enable `PSRAM`. It is set to true by
default.
- How to use Before using these build options, please check whether they
are available to configure in BUILD.gn file under example application
folder.
- build with `build_examples.py` Modify value of build options in
BUILD.gn file under example application folder.
- build with gn_bouffalolab_example.sh Input build options, such as
```
./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-IoT-DVK chip_build_libshell=true
```

- Download image

- Using script `chip-bl702-lighting-example.flash.py`.
Expand Down
Loading

0 comments on commit 46023e8

Please sign in to comment.