Bouffalo Lab Contact Sensor ExampleThis example demonstrates a Matter contact sensor device (Vendor ID: 0xFFF1, Product ID: 0x8005), supporting BooleanState cluster reporting via GPIO.
| Board | Chip | Transport | Build system |
|---|---|---|---|
bl704ldk | BL704L | Thread | Matter GN (build_examples.py) |
bl616dk | BL616 | Wi-Fi | CMake (make) |
BL704L
├── IEEE 802.15.4 radio → OpenThread (FTD or MTD)
│ └── Matter over Thread (UDP/IPv6)
├── BLE → BLE commissioning (PASE over BLE)
└── Application
├── CHIP_RESET_PIN (GPIO 16) — long press → factory reset
└── CHIP_CONTACT_PIN (GPIO 20) — rising edge = true, falling = false
CHIP_CONTACT_PINshould be pulled down to a low level; otherwise, the device may wake up unexpectedly.
app_pds.cppbuild_examples.pyActivate the build environment first:
source scripts/activate.sh
Build with Thread MTD (Minimal Thread Device, lower power):
./scripts/build/build_examples.py \ --target bouffalolab-bl704ldk-contact-sensor-thread-mtd-littlefs \ build
The output binary is placed under out/bouffalolab-bl704ldk-contact-sensor-thread-mtd-littlefs/.
./out/bouffalolab-bl704ldk-contact-sensor-thread-mtd-littlefs-mfd/chip-bl702l-contact-sensor-example.flash.py --port <device port>
BL616 (RISC-V, Wi-Fi 6 + BLE)
├── Wi-Fi → Matter over IP (TCP/UDP)
├── BLE → BLE commissioning (PASE over BLE)
├── Low-power (PDS) → Wi-Fi + BLE coordinated sleep (app_lp.cpp)
└── Application
├── CHIP_RESET_PIN (GPIO 2) — long press → factory reset
└── CHIP_CONTACT_PIN (GPIO 20) — rising edge = true, falling = false
bflb/app_pds.cppBouffalo SDK + Matter CMake hybrid buildActivate the build environment first:
source scripts/activate.sh
Build with Wi-Fi:
make -C examples/contact-sensor-app/bouffalolab
make -C examples/contact-sensor-app/bouffalolab clean
make -C examples/contact-sensor-app/bouffalolab flash COMX=<device port>
Commission over BLE with chip-tool, providing Thread credentials:
./out/linux-x64-chip-tool/chip-tool pairing ble-thread \ <device_node_id> hex:<thread_dataset_tlv> 20202021 3840
<thread_dataset_tlv>— active Thread dataset in hex TLV format.
Commission over BLE with chip-tool, providing Wi-Fi credentials:
./out/linux-x64-chip-tool/chip-tool pairing ble-wifi \ <device_node_id> <wifi_ssid> <wifi_passwd> 20202021 3840
<device_node_id>— node ID assigned to the device;
><wifi_ssid>— Wi-Fi network SSID;
><wifi_passwd>— Wi-Fi network password.
Start chip-tool in interactive mode:
./chip-tool interactive start
Subscribe to the BooleanState attribute:
booleanstate subscribe state-value <min-interval> <max-interval> <device_node_id> 1
<min-interval> — minimum reporting interval (seconds)<max-interval> — maximum reporting interval (seconds)<device_node_id> — node ID of the contact sensorTrigger state changes by pressing the contact GPIO button.