Skip to content

api/firmware: add Bluetooth info to DeviceInfo #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api/firmware/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ type Device struct {
log Logger
}

// BluetoothInfo contains Bluetooth-related info.
type BluetoothInfo struct {
// FirmwareHash is the hex-encoded 32 byte Bluetooth firmware hash.
FirmwareHash string `json:"firmwareHash"`
}

// DeviceInfo is the data returned from the device info api call.
type DeviceInfo struct {
Name string `json:"name"`
Expand All @@ -112,6 +118,8 @@ type DeviceInfo struct {
// This information is only available since firmwae v9.6.0. Will be an empty string for older
// firmware versions.
SecurechipModel string `json:"securechipModel"`
// Available on Bluetooth-enabled devices, Will be `nil` otherwise.
Bluetooth *BluetoothInfo `json:"bluetooth"`
}

// NewDevice creates a new instance of Device.
Expand Down
143 changes: 112 additions & 31 deletions api/firmware/messages/bitbox02_system.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions api/firmware/messages/bitbox02_system.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@ message DeviceInfoRequest {
}

message DeviceInfoResponse {
message Bluetooth {
// Hash of the currently active Bluetooth firmware on the device.
bytes firmware_hash = 1;
}
string name = 1;
bool initialized = 2;
string version = 3;
bool mnemonic_passphrase_enabled = 4;
uint32 monotonic_increments_remaining = 5;
// From v9.6.0: "ATECC608A" or "ATECC608B".
string securechip_model = 6;
// Only present in Bluetooth-enabled devices.
optional Bluetooth bluetooth = 7;
}

message InsertRemoveSDCardRequest {
Expand Down
10 changes: 10 additions & 0 deletions api/firmware/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package firmware

import (
"encoding/hex"

"github.com/BitBoxSwiss/bitbox02-api-go/api/firmware/messages"
"github.com/BitBoxSwiss/bitbox02-api-go/util/errp"
"github.com/BitBoxSwiss/bitbox02-api-go/util/semver"
Expand Down Expand Up @@ -64,12 +66,20 @@ func (device *Device) DeviceInfo() (*DeviceInfo, error) {
return nil, errp.New("Failed to retrieve device info")
}

var bluetooth *BluetoothInfo
if deviceInfoResponse.DeviceInfo.Bluetooth != nil {
bluetooth = &BluetoothInfo{
FirmwareHash: hex.EncodeToString(deviceInfoResponse.DeviceInfo.Bluetooth.FirmwareHash),
}
}

deviceInfo := &DeviceInfo{
Name: deviceInfoResponse.DeviceInfo.Name,
Version: deviceInfoResponse.DeviceInfo.Version,
Initialized: deviceInfoResponse.DeviceInfo.Initialized,
MnemonicPassphraseEnabled: deviceInfoResponse.DeviceInfo.MnemonicPassphraseEnabled,
SecurechipModel: deviceInfoResponse.DeviceInfo.SecurechipModel,
Bluetooth: bluetooth,
}

return deviceInfo, nil
Expand Down
4 changes: 3 additions & 1 deletion cmd/playground/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ func main() {

info, err := device.DeviceInfo()
errpanic(err)
fmt.Printf("Device info: %+v", info)
infoJson, err := json.MarshalIndent(info, "", " ")
errpanic(err)
fmt.Printf("Device info: %s", infoJson)
//signFromTxID(device, "48e83b2a44c21dab01fc7bad0df1b1d7a59e48af79069454a8320ec6a9d1aefb")

sig, err := device.ETHSignEIP1559(
Expand Down
Loading