Skip to content

Commit

Permalink
[BL602] 1.Update README 2.Add wifi scan 3.Update sdk repo to fix pbuf. (
Browse files Browse the repository at this point in the history
#18944)

* [BL602] 1.Update README 2.Add wifi scan 3.Update sdk repo to fix pbuf.

* [BL602] Update README

* Restyled by whitespace

* Restyled by clang-format

* Restyled by prettier-markdown

* [BL602] Update README ,word list and fix spell error.

* [BL602] Fix spell error

* Restyled by prettier-markdown

* [BL602] Delete picocom from the word list

* Restyled by prettier-markdown

* [BL602] delete not use code

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Oct 10, 2023
1 parent edc8325 commit 3791001
Show file tree
Hide file tree
Showing 18 changed files with 192 additions and 134 deletions.
3 changes: 3 additions & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ DS
duplicative
DUT
DV
DVK
dynload
eabi
EB
Expand Down Expand Up @@ -532,6 +533,7 @@ fsync
ftd
fullclean
fuzzer
FW
gbl
gcloud
GDB
Expand Down Expand Up @@ -1104,6 +1106,7 @@ RPi
RPis
rsn
RSSI
RST
rsync
RTL
rtld
Expand Down
185 changes: 126 additions & 59 deletions examples/lighting-app/bouffalolab/bl602/README.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,157 @@
#CHIP BL602 Lighting Example
# BL602

## Build
This example functions as a wifi light bulb device type, with on/off
capabilities. The steps were verified on BL602-IoT-DVK-3S board.

- Install some additional tools(likely already present for CHIP developers):
BL602-IoT-DVK-3S
<img src="../../../platform/bouffalolab/bl602/doc/images/bl602_iot_3S_v2.jpg" style="zoom:25%;" />

#Linux \$ sudo apt-get install git libwebkitgtk-1.0-0 ninja-build
## Initial setup

#Mac OS X \$ brew install ninja
- Setting up the environment on ubuntu 20.04 or 18.04

* Build the example application:
```
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install git gcc g++ python pkg-config libssl-dev libdbus-1-dev libglib2.0-dev libavahi-client-dev ninja-build python3-venv python3-dev python3-pip unzip libgirepository1.0-dev libcairo2-dev bluez avahi-daemon
$ sudo apt-get install pi-bluetooth (if not raspberry pi, sudo apt-get install bluetooth)
$ reboot
`connectedhomeip$ ./scripts/build/build_examples.py --target bl602-lighting build`
```

Generated files
- Clone and initialize the connectedhomeip repo

```
connectedhomeip/out/lighting_app_bl602/chip-bl602-lighting-example.bin
```
```
git clone https://github.com/project-chip/connectedhomeip.git
cd connectedhomeip
git submodule update --init --recursive
```

- To delete generated executable, libraries and object files use:
- Install packets

```
$ cd ~/connectedhomeip/
$ rm -rf out/
```
```
$ cd {path-to-connectedhomeip}
connectedhomeip$ source ./scripts/bootstrap.sh
connectedhomeip$ source ./scripts/activate.sh
## Flash
```

- Download [FLASH_TOOL](https://dev.bouffalolab.com/download/).
## Build the image

### Setting up Python Controller
- Build the example application:

Once BL602 is up and running, we need to set up a device controller to perform
commissioning and cluster control.
`connectedhomeip$ ./scripts/build/build_examples.py --target bl602-light build`

- Set up python controller.
Generated files

```
$ cd {path-to-connectedhomeip}
$ ./scripts/build_python.sh -m platform
```
`connectedhomeip/out/bl602-light/chip-bl602-lighting-example.bin`

- Execute the controller.
- To delete generated executable, libraries and object files use:

```
$ source ./out/python_env/bin/activate
$ chip-device-ctrl
```
```
$ cd ~/connectedhomeip/
$ rm -rf out/
```
### Commissioning over BLE
## Flash the board
- Establish the secure session over BLE. BLE is the default mode in the
application and is configurable through menuconfig.
- Download [Bouffalo Lab Dev Cube](https://dev.bouffalolab.com/download/).
```
- chip-device-ctrl > ble-scan
- chip-device-ctrl > set-pairing-wifi-credential TESTSSID P455W4RD
- chip-device-ctrl > connect -ble 3904 20202021 135246
Log in to the site as a guest.
Parameters:
1. Discriminator: 3904
2. Setup-pin-code: 20202021
3. Node ID: Optional.
If not passed in this command, then it is auto-generated by the controller and displayed in the output of connect.
The same value should be used in the next commands.
We have chosen a random node ID which is 135246.
4. TESTSSID : Wi-Fi SSID
5. P455W4RD : Wi-Fi Password
```
<img src="../../../platform/bouffalolab/bl602/doc/images/image-web-login.png" style="zoom:30%;" align=left />
<img src="../../../platform/bouffalolab/bl602/doc/images/dev-cube.png" style="zoom:30%;" align=left />
run the software :
<img src="../../../platform/bouffalolab/bl602/doc/images/dev-cube-home.png" style="zoom:70%;" align=left />
<img src="../../../platform/bouffalolab/bl602/doc/images/dev-cube-iot.png" style="zoom:70%;" />
The following picture shows the burning interface. To download the firmware, you
need to enter the download mode: press and hold the Boot (IO8) pin of the
development board, press the **RST** button, and then release the Boot button to
enter the burning and downloading mode.
<img src="../../../platform/bouffalolab/bl602/doc/images/image-dev-cube.png" style="zoom:70%;" align=left />
Notice: Latest version Bouffalolab dev cube is recommended.
Factory Params:
`BouffaloLabDevCube-1.7.2-linux-x86/chips/bl602/device_tree/bl_factory_params_IoTKitA_40M.dts`
Partition Table:
`BouffaloLabDevCube-1.7.2-linux-x86/chips/bl602/partition/partition_cfg_2M.toml`
Boot2 Bin:
`BouffaloLabDevCube-1.7.2-linux-x86/chips/bl602/builtin_imgs/boot2_iap_v5.5/boot2_iap_release.bin`
Firmware Bin: `connectedhomeip/out/bl602-light/chip-bl602-lighting-example.bin`
Partition Table:
1. FW: The size of FW size0 must be larger than the bin size, we can do it by
reducing the size of FW size1 and media partition size0.
COM Port:
```
ls -la /dev/ttyUSB*
```
select the big one.
## Validate the example
1.The device should present itself as a USB serial device on your computer. You
may look it up in `/dev/`:
```
ls -la /dev/tty*
```
You can open the serial console. For example, if the device is at `/dev/USB1`:
```
picocom -b 2000000 /dev/ttyUSB1
```
To reset the board, press the **RST** button. And you will see the log from the
demo board.
## Commission a device using chip-tool
To initiate a client commissioning request to a device, run the built executable
and choose the pairing mode.
#### Commissioning over BLE
Run the built executable and pass it the discriminator and pairing code of the
remote device, as well as the network credentials to use.
The command below uses the default values hard-coded into the debug versions of
the BL602 lighting-app to commission it onto a Wi-Fi network:
```
$ sudo ./chip-tool pairing ble-wifi 1 ${SSID} ${PASSWORD} 20202021 3840

Parameters:
1. Discriminator: 3840
2. Setup-pin-code: 20202021
3. Node ID: 1
4. SSID : Wi-Fi SSID
5. PASSWORD : Wi-Fi Password
```
### Cluster control
- After successful commissioning, use the OnOff cluster commands to control
the OnOff attribute. This allows you to toggle a parameter implemented by
the device to be On or Off.
`chip-device-ctrl > zcl OnOff On 135246 1 1`
`chip-device-ctrl > zcl OnOff Off 135246 1 1`

- Use the LevelControl cluster commands to control the CurrentLevel attribute.
This allows you to control the brightness of the led.

`chip-device-ctrl > zcl LevelControl MoveToLevel 135246 1 1 level=10 transitionTime=0 optionMask=0 optionOverride=0`
`$ sudo ./chip-tool onoff on 1 1`
- Use the ColorControl cluster commands to control the CurrentHue and
CurrentSaturation attribute.
- Use ColorControl cluster command to control the color attributes:
`chip-device-ctrl > zcl ColorControl MoveToHue 135246 1 1 hue=100 direction=0 transitionTime=0 optionsMask=0 optionsOverride=0`
`chip-device-ctrl > zcl ColorControl MoveToSaturation 135245 1 1 saturation=200 transitionTime=0 optionsMask=0 optionsOverride=0`
`$ sudo ./chip-tool colorcontrol move-to-hue-and-saturation 240 100 0 0 0 1 1`
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021
#endif
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF40
#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00

// For convenience, Chip Security Test Mode can be enabled and the
// requirement for authentication in various protocols can be disabled.
Expand Down
22 changes: 20 additions & 2 deletions examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,26 @@ void AppTask::AppTaskMain(void * pvParameter)

log_info("App Task entered\r\n");

sWiFiNetworkCommissioningInstance.Init();
chip::Server::GetInstance().Init();
err = sWiFiNetworkCommissioningInstance.Init();
if (CHIP_NO_ERROR != err)
{
log_error("Network commissioning failed, err:%d \r\n", err);
}

chip::CommonCaseDeviceServerInitParams initParams;
err = initParams.InitializeStaticResourcesBeforeServerInit();
if (CHIP_NO_ERROR != err)
{
log_error("Resources Init failed, err:%d \r\n", err);
return;
}

err = chip::Server::GetInstance().Init(initParams);
if (CHIP_NO_ERROR != err)
{
log_error("Server Init failed, err:%d \r\n", err);
return;
}

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
Expand Down
5 changes: 3 additions & 2 deletions examples/lighting-app/bouffalolab/bl602/src/LEDWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ static void showRGB(uint8_t red, uint8_t green, uint8_t blue)

level = (blue * 10000) / UINT8_MAX;
log_info("blue level: %d\r\n", level);
pwmB.port = 2;
pwmB.config.pin = 17;
pwmB.port = 2;
// not use debug port
// pwmB.config.pin = 17;
pwmB.config.duty_cycle = level; // duty_cycle range is 0~10000 correspond to 0~100%
pwmB.config.freq = 1000;
hosal_pwm_init(&pwmB);
Expand Down
10 changes: 0 additions & 10 deletions examples/lighting-app/bouffalolab/bl602/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,6 @@ app::Clusters::NetworkCommissioning::Instance
sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::BLWiFiDriver::GetInstance()));
} // namespace

static void InitServer(intptr_t context)
{
chip::Server::GetInstance().Init();

// Initialize device attestation config
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());

sWiFiNetworkCommissioningInstance.Init();
}

extern "C" int main()
{
InitPlatform();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3791001

Please sign in to comment.