Skip to content

espradio: add ESP32 BLE support using espradio VHCI transport - #464

Draft
deadprogram wants to merge 2 commits into
devfrom
esp32-hci
Draft

espradio: add ESP32 BLE support using espradio VHCI transport#464
deadprogram wants to merge 2 commits into
devfrom
esp32-hci

Conversation

@deadprogram

@deadprogram deadprogram commented Jul 29, 2026

Copy link
Copy Markdown
Member

Adds a new espradio build tag that wires the existing HCI stack up to the ESP32's virtual HCI controller via tinygo.org/x/espradio. The new Adapter calls espradio.BLEInit() and hands a VHCI-backed transport to newBLEStack(); for WiFi+BLE co-existence, espradio.Enable() should be called first.

The shared HCI implementation files pick up the espradio build tag, and go.mod is updated for the espradio and drivers dependencies.

Works on ESP32C3 for both central and advertiser roles!

tinygo flash -target xiao-esp32c3 -tags espradio -monitor ./examples/heartrate
tinygo flash -target xiao-esp32c3 -tags espradio -ldflags="-X main.DeviceAddress=6B:C3:F8:21:99:0D" -monitor ./examples/heartrate-monitor/

Requires that both tinygo-org/espradio#58 and tinygo-org/espradio#59 be merged, which is why this is in draft. It also requires the current dev branch of TinyGo.

@marcofeltmann marcofeltmann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local build with v1.24.4 but github workflow on macos with v1.25.0 seems odd, better sync the versions.

Comment thread .github/workflows/macos.yml Outdated
uses: actions/setup-go@v6
with:
go-version: '1.23.12'
go-version: '~1.25.0'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Differs from go.mod version v1.24.4

Maybe sync via

    go-version-file: 'go.mod'

(source: https://github.com/actions/setup-go#usage)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Of course I had to make a change to the go.mod file as a result, it seems? Waiting on the build...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok now I think I have it correct.

@deadprogram

Copy link
Copy Markdown
Member Author

Test failure until the next TinyGo release, since this repo builds that use the current release, but this PR needs the upcoming one.

Adds a new `espradio` build tag that wires the existing HCI stack up to
the ESP32's virtual HCI controller via tinygo.org/x/espradio. The new
Adapter calls espradio.BLEInit() and hands a VHCI-backed transport to
newBLEStack(); for WiFi+BLE co-existence, espradio.Enable() should be
called first.

The shared HCI implementation files pick up the espradio build tag, and
go.mod is updated for the espradio and drivers dependencies.

Signed-off-by: deadprogram <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants