Skip to content

Commit ae18bcb

Browse files
committed
Merge branch 'device-info-ble'
2 parents d958ecb + 3fed84e commit ae18bcb

File tree

5 files changed

+139
-32
lines changed

5 files changed

+139
-32
lines changed

api/firmware/device.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ type Device struct {
110110
log Logger
111111
}
112112

113+
// BluetoothInfo contains Bluetooth-related info.
114+
type BluetoothInfo struct {
115+
// FirmwareHash is the hex-encoded 32 byte Bluetooth firmware hash.
116+
FirmwareHash string `json:"firmwareHash"`
117+
}
118+
113119
// DeviceInfo is the data returned from the device info api call.
114120
type DeviceInfo struct {
115121
Name string `json:"name"`
@@ -119,6 +125,8 @@ type DeviceInfo struct {
119125
// This information is only available since firmwae v9.6.0. Will be an empty string for older
120126
// firmware versions.
121127
SecurechipModel string `json:"securechipModel"`
128+
// Available on Bluetooth-enabled devices, Will be `nil` otherwise.
129+
Bluetooth *BluetoothInfo `json:"bluetooth"`
122130
}
123131

124132
// NewDevice creates a new instance of Device.

api/firmware/messages/bitbox02_system.pb.go

Lines changed: 112 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/firmware/messages/bitbox02_system.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@ message DeviceInfoRequest {
2626
}
2727

2828
message DeviceInfoResponse {
29+
message Bluetooth {
30+
// Hash of the currently active Bluetooth firmware on the device.
31+
bytes firmware_hash = 1;
32+
}
2933
string name = 1;
3034
bool initialized = 2;
3135
string version = 3;
3236
bool mnemonic_passphrase_enabled = 4;
3337
uint32 monotonic_increments_remaining = 5;
3438
// From v9.6.0: "ATECC608A" or "ATECC608B".
3539
string securechip_model = 6;
40+
// Only present in Bluetooth-enabled devices.
41+
optional Bluetooth bluetooth = 7;
3642
}
3743

3844
message InsertRemoveSDCardRequest {

api/firmware/system.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
package firmware
1616

1717
import (
18+
"encoding/hex"
19+
1820
"github.com/BitBoxSwiss/bitbox02-api-go/api/firmware/messages"
1921
"github.com/BitBoxSwiss/bitbox02-api-go/util/errp"
2022
"github.com/BitBoxSwiss/bitbox02-api-go/util/semver"
@@ -64,12 +66,20 @@ func (device *Device) DeviceInfo() (*DeviceInfo, error) {
6466
return nil, errp.New("Failed to retrieve device info")
6567
}
6668

69+
var bluetooth *BluetoothInfo
70+
if deviceInfoResponse.DeviceInfo.Bluetooth != nil {
71+
bluetooth = &BluetoothInfo{
72+
FirmwareHash: hex.EncodeToString(deviceInfoResponse.DeviceInfo.Bluetooth.FirmwareHash),
73+
}
74+
}
75+
6776
deviceInfo := &DeviceInfo{
6877
Name: deviceInfoResponse.DeviceInfo.Name,
6978
Version: deviceInfoResponse.DeviceInfo.Version,
7079
Initialized: deviceInfoResponse.DeviceInfo.Initialized,
7180
MnemonicPassphraseEnabled: deviceInfoResponse.DeviceInfo.MnemonicPassphraseEnabled,
7281
SecurechipModel: deviceInfoResponse.DeviceInfo.SecurechipModel,
82+
Bluetooth: bluetooth,
7383
}
7484

7585
return deviceInfo, nil

cmd/playground/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ func main() {
211211

212212
info, err := device.DeviceInfo()
213213
errpanic(err)
214-
fmt.Printf("Device info: %+v", info)
214+
infoJson, err := json.MarshalIndent(info, "", " ")
215+
errpanic(err)
216+
fmt.Printf("Device info: %s", infoJson)
215217
//signFromTxID(device, "48e83b2a44c21dab01fc7bad0df1b1d7a59e48af79069454a8320ec6a9d1aefb")
216218

217219
sig, err := device.ETHSignEIP1559(

0 commit comments

Comments
 (0)