Skip to content

WIP / POC for using the BL602 wifi blob from Rust for wifi and BLE connectivity

Notifications You must be signed in to change notification settings

bjoernQ/bl602-wifi-rs

Repository files navigation

BL602 Wifi Rust

This is work in progress and currently more a proof of concept. The code is awfully hacked together - just enough to make it work. However it seems to work so far for me.

It uses the NuttX wifi blob from https://github.com/bouffalolab/bl_blob

Status

What Status
Wifi Connect to Access Point Works
Wifi Scan Works
Wifi Start Access Point Doesn't work
Wifi Automatic Reconnect Not implemented yet
BLE HCI Communication works and there is a minimal BLE stack

Examples

See the examples folder.

Example: simple

This connects to an access point and provides a minimal TCP server on port 4321. You can ping the BL602 and telnet to port 4321.

Sometimes it fails to connect (there is no retry currently).

In examples/simple/wifi_config.rs change the SSID and PSK for your access point.

Maybe you need to change the IP address (currently 192.168.2.191) and the IP of the default gateway (192.168.2.1) in examples/simple/main.rs.

Compile with cargo build -Z build-std --target riscv32imfc-unknown-none-elf.json --example simple and flash the resulting binary.

Example: scan

This scans for wifi networks.

Example: dhcp

Similar to simple but uses DHCP - so no need to configure an IP address or gateway.

Example: ble_advertising

This starts BLE advertising. It should show up as BL-602 BLE when scanning for Bluetooth devices. It's possible to connect to it and discover two services. One is read and writeable and one is just writeable. Read and write should also work.

Implementation Notes

This needs some modifications to the following crates (done in my forks referenced in Cargo.toml)

  • riscv-rt - needs support for ILP32F and initialization of the FPU

Also it needs a very special linker script.

It uses one of the timers which can't be used for other things.

You'll need nightly Rust. (I use rustc 1.57.0-nightly (9bb77da74 2021-09-13) currently)

Things to change / improve

  • especially the code in compat can be improved
  • make it more stable
  • use a queue for tx for improved performance
  • implement more BLE stack functionality

and many more ...

About

WIP / POC for using the BL602 wifi blob from Rust for wifi and BLE connectivity

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published