Skip to content

Commit

Permalink
Fix Restyled
Browse files Browse the repository at this point in the history
  • Loading branch information
wy-hh committed Oct 19, 2022
1 parent 2247fa1 commit d204b03
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 104 deletions.
2 changes: 1 addition & 1 deletion examples/lighting-app/bouffalolab/bl602/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ bl602_executable("lighting_app") {

include_dirs = [ "include" ]

if ("BL602-IoT-Matter-V1" == board || "BL602-IOT-DVK-3S" == board ) {
if ("BL602-IoT-Matter-V1" == board || "BL602-IOT-DVK-3S" == board) {
defines = [ "BOARD_ID=1" ]
} else {
defines = [ "BOARD_ID=0" ]
Expand Down
39 changes: 25 additions & 14 deletions examples/lighting-app/bouffalolab/bl602/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

This example functions as a wifi light bulb device type, with on/off
capabilities. The steps were verified on following boards:
- BL602-IoT-Matter-V1, [here](https://www.amazon.com/dp/B0B9ZVGXD8) to purchase.
- BL602-NIGHT-LIGHT

- BL602-IoT-Matter-V1, [here](https://www.amazon.com/dp/B0B9ZVGXD8) to
purchase.
- BL602-NIGHT-LIGHT

## BL602-IoT-Matter-V1 board

<img src="../../../platform/bouffalolab/bl602/doc/images/BL602-IoT-Matter_V1.png" style="zoom:25%;" />

## Initial setup
Expand All @@ -32,7 +35,9 @@ The steps in this document were validated on Ubuntu 18.04 and 20.04.
source ./scripts/activate.sh
```
> Note, Bouffalolab flash tool, `bflb-iot-tool`, imports under this environment. If not, please try `scripts/bootstrap.sh` for matter environment update.
> Note, Bouffalolab flash tool, `bflb-iot-tool`, imports under this
> environment. If not, please try `scripts/bootstrap.sh` for matter
> environment update.
## Build CHIP BL602 Lighting App example
Expand All @@ -44,23 +49,28 @@ The steps in this document were validated on Ubuntu 18.04 and 20.04.
./scripts/build/build_examples.py --target bouffalolab-bl602-night-light-light build
```
- Build target name with `-115200` appended for UART baudrate 115200 command enabled as following commands.
- Build target name with `-115200` appended for UART baudrate 115200 command
enabled as following commands.
```shell
./scripts/build/build_examples.py --target bouffalolab-bl602-iot-matter-v1-light-115200 build
```
> UART baudrate is 2000000 by default.
- Build target name with `-rpc` appended for rpc enabled as following commands.
```shell
./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-rpc build
```
> For multiple build options, such as UART baudrate 115200 + rpc, please try build command as `./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-rpc-115200 build`
- Build target name with `-rpc` appended for rpc enabled as following
commands.
`shell ./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-rpc build`
> For multiple build options, such as UART baudrate 115200 + rpc, please try
> build command as
> `./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-rpc-115200 build`
## Download image
After building gets done, a python
`chip-bl602-lighting-example.flash.py` will generated under build output
folder. Such as chip-bl602-lighting-example.flash.py for lighting-app
example. Please check `help` option of script for more detail.
After building gets done, a python `chip-bl602-lighting-example.flash.py` will
generated under build output folder. Such as
chip-bl602-lighting-example.flash.py for lighting-app example. Please check
`help` option of script for more detail.
- Connect the board to your flashing station (MacOS, Ubuntu, Windows).
Expand All @@ -70,7 +80,8 @@ example. Please check `help` option of script for more detail.
- Press the RESET button and release it.
- Release the BOOT button.
- Enter build out folder, download image as following execution under build output folder:
- Enter build out folder, download image as following execution under build
output folder:
```shell
./chip-bl602-lighting-example.flash.py --port /dev/tty.usbserial-3
Expand Down
69 changes: 42 additions & 27 deletions examples/lighting-app/bouffalolab/bl702/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ applications, and BL702 is a general name for BL70X family.
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:
- `XT-ZB6-DevKit`
- `BL706-IoT-DVK`
- `BL706-NIGHT-LIGHT`

- `XT-ZB6-DevKit`
- `BL706-IoT-DVK`
- `BL706-NIGHT-LIGHT`

## Prerequisite

Expand All @@ -22,7 +23,8 @@ following boards:
```shell
source scripts/bootstrap.sh
```
> Note, `bflb-iot-tool` is only installed under connectedhomeip build context by matter environment setup `scripts/bootstrap.sh`.
> Note, `bflb-iot-tool` is only installed under connectedhomeip build
> context by matter environment setup `scripts/bootstrap.sh`.
- Others, please execute the following script before any build commands
executed; and `bflb-iot-tool` imports under this environment.
```shell
Expand All @@ -38,54 +40,62 @@ following boards:
./scripts/build/build_examples.py --target bouffalolab-bl706-night-light-light build
```

- Build target name with `-115200` appended for UART baudrate 115200 command enabled as following commands.
- Build target name with `-115200` appended for UART baudrate 115200 command
enabled as following commands.

```shell
./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-rpc build
```

> UART baudrate is 2000000 by default.

- Build target name with `-shell` appended for UART shell command enabled as following commands.
- Build target name with `-shell` appended for UART shell command enabled as
following commands.

```shell
./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-shell build
```

- Build target name with `-rpc` appended for rpc enabled as following commands.
```shell
./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-rpc build
```
> For multiple build options, such as UART baudrate 115200 + rpc, please try build command as `./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-rpc-115200 build`
- Build target name with `-rpc` appended for rpc enabled as following
commands.
`shell ./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-rpc build`
> For multiple build options, such as UART baudrate 115200 + rpc, please try
> build command as
> `./scripts/build/build_examples.py --target bouffalolab-xt-zb6-devkit-light-rpc-115200 build`

## Download image

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

After building gets done, a python
`chip-bl702-lighting-example.flash.py` will generated under build output
folder. Such as chip-bl702-lighting-example.flash.py for lighting-app
example. Please check `--help` option of script for more detail.
After building gets done, a python `chip-bl702-lighting-example.flash.py`
will generated under build output folder. Such as
chip-bl702-lighting-example.flash.py for lighting-app example. Please check
`--help` option of script for more detail.

- Hold BOOT pin and reset chip, let it be in download mode.
- Enter build out folder, download image as following execution under build output folder:
- Enter build out folder, download image as following execution under
build output folder:

```shell
./chip-bl702-lighting-example.flash.py --port /dev/tty.usbserial-3
```

> Note, where `/dev/tty.usbserial-3` is UART port of device.

- Build Bouffalolab OTA image as following execution under build
output folder:
- Build Bouffalolab OTA image as following execution under build output
folder:
```shell
./chip-bl702-lighting-example.flash.py --build
```
After script executed, a folder `ota_images` and an image
`FW_OTA.bin.xz.hash` will be generated. `FW_OTA.bin.xz.hash` is
compressed with hash verification for
`chip-bl702-lighting-example.bin`.
compressed with hash verification for `chip-bl702-lighting-example.bin`.

> Note, `chip-bl702-lighting-example.flash.py` uses Python module
> `bflb-iot-tool` to flash device. Please make sure current terminal is
> under matter build environment; otherwise, Python module
> `bflb-iot-tool` should be installed under default Python environment using command `pip install bflb-iot-tool`.
> under matter build environment; otherwise, Python module `bflb-iot-tool`
> should be installed under default Python environment using command
> `pip install bflb-iot-tool`.

- Using `Bouffalo Lab` flash tool`BLDevCube`
- Hold BOOT pin and reset chip, let it be in download mode.
Expand All @@ -100,14 +110,19 @@ following boards:
> connectedhomeip.

## Firmware Behavior

- `XT-ZB6-DevKit` board
- Lighting LED, controlled by on/off command, level command and identify command.
- Factory Reset: Press down boot pin over 4 seconds, and release boot pin

- Lighting LED, controlled by on/off command, level command and identify
command.
- Factory Reset: Press down boot pin over 4 seconds, and release boot pin

- `Night Light` board
- Unprovisioned state: light shows yellow.
- Provisioned state: light show white.
- Factory Reset: Power cycle 3 times before light is on; at 3rd time, light shows green and does factory reset after 3 seconds later. And factory reset can be cancelled during 3 seconds wait time.
- Unprovisioned state: light shows yellow.
- Provisioned state: light show white.
- Factory Reset: Power cycle 3 times before light is on; at 3rd time,
light shows green and does factory reset after 3 seconds later. And
factory reset can be cancelled during 3 seconds wait time.

## Test with chip-tool

Expand Down
32 changes: 16 additions & 16 deletions examples/lighting-app/bouffalolab/bl702/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,20 @@ class AppTask
{
APP_EVENT_NONE = 0x00000000,

APP_EVENT_BTN_FACTORY_RESET_CANCEL = 0x00000002,
APP_EVENT_BTN_FACTORY_RESET_IND = 0x00000004,
APP_EVENT_BTN_FACTORY_RESET_PRESS = 0x00000008,
APP_EVENT_BTN_FACTORY_RESET_CANCEL = 0x00000002,
APP_EVENT_BTN_FACTORY_RESET_IND = 0x00000004,
APP_EVENT_BTN_FACTORY_RESET_PRESS = 0x00000008,

APP_EVENT_BTN_ALL_MASK = APP_EVENT_BTN_FACTORY_RESET_CANCEL | APP_EVENT_BTN_FACTORY_RESET_IND | APP_EVENT_BTN_FACTORY_RESET_PRESS,
APP_EVENT_TIMER = 0x00000010,
APP_EVENT_BTN_SHORT = 0x00000020,
APP_EVENT_BTN_ALL_MASK =
APP_EVENT_BTN_FACTORY_RESET_CANCEL | APP_EVENT_BTN_FACTORY_RESET_IND | APP_EVENT_BTN_FACTORY_RESET_PRESS,
APP_EVENT_TIMER = 0x00000010,
APP_EVENT_BTN_SHORT = 0x00000020,

APP_EVENT_SYS_BLE_ADV = 0x00000100,
APP_EVENT_SYS_BLE_CONN = 0x00000200,
APP_EVENT_SYS_PROVISIONED = 0x00000400,
APP_EVENT_SYS_LIGHT_TOGGLE = 0x00000800,
APP_EVENT_FACTORY_RESET = 0x00001000,
APP_EVENT_SYS_BLE_ADV = 0x00000100,
APP_EVENT_SYS_BLE_CONN = 0x00000200,
APP_EVENT_SYS_PROVISIONED = 0x00000400,
APP_EVENT_SYS_LIGHT_TOGGLE = 0x00000800,
APP_EVENT_FACTORY_RESET = 0x00001000,

APP_EVENT_SYS_ALL_MASK =
APP_EVENT_SYS_BLE_ADV | APP_EVENT_SYS_BLE_CONN | APP_EVENT_SYS_PROVISIONED | APP_EVENT_FACTORY_RESET,
Expand All @@ -69,16 +70,15 @@ class AppTask
APP_EVENT_LIGHTING_LEVEL = 0x00020000,
APP_EVENT_LIGHTING_COLOR = 0x00040000,
APP_EVENT_LIGHTING_GO_THROUGH = 0x00100000,
APP_EVENT_LIGHTING_MASK =
APP_EVENT_LIGHTING_ONOFF | APP_EVENT_LIGHTING_LEVEL | APP_EVENT_LIGHTING_COLOR,
APP_EVENT_LIGHTING_MASK = APP_EVENT_LIGHTING_ONOFF | APP_EVENT_LIGHTING_LEVEL | APP_EVENT_LIGHTING_COLOR,

APP_EVENT_IDENTIFY_START = 0x01000000,
APP_EVENT_IDENTIFY_IDENTIFY = 0x02000000,
APP_EVENT_IDENTIFY_STOP = 0x04000000,
APP_EVENT_IDENTIFY_MASK = APP_EVENT_IDENTIFY_START | APP_EVENT_IDENTIFY_IDENTIFY | APP_EVENT_IDENTIFY_STOP,

APP_EVENT_ALL_MASK =
APP_EVENT_LIGHTING_MASK | APP_EVENT_BTN_ALL_MASK | APP_EVENT_SYS_ALL_MASK | APP_EVENT_TIMER | APP_EVENT_BTN_SHORT | APP_EVENT_IDENTIFY_MASK,
APP_EVENT_ALL_MASK = APP_EVENT_LIGHTING_MASK | APP_EVENT_BTN_ALL_MASK | APP_EVENT_SYS_ALL_MASK | APP_EVENT_TIMER |
APP_EVENT_BTN_SHORT | APP_EVENT_IDENTIFY_MASK,
};

void SetEndpointId(EndpointId endpointId)
Expand Down Expand Up @@ -135,7 +135,7 @@ class AppTask
TimerHandle_t sTimer;
uint32_t mTimerIntvl;
uint64_t mButtonPressedTime;
bool mIsFactoryResetIndicat;
bool mIsFactoryResetIndicat;

static StackType_t appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)];
static StaticTask_t appTaskStruct;
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/bouffalolab/bl702/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

#define MAX_PWM_CHANNEL 3

#elif defined (XT_ZB6_DevKit)
#elif defined(XT_ZB6_DevKit)

#define LED_B_PIN_PORT 3
#define LED_B_PIN 18
Expand All @@ -80,7 +80,7 @@

#endif

#if defined (BOARD_BTN_BOOT_PIN)
#if defined(BOARD_BTN_BOOT_PIN)
#define LED_BTN_RESET 31
#endif

Expand Down
Loading

0 comments on commit d204b03

Please sign in to comment.