File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2025 Shift Crypto AG
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ package bitbox02
16
+
17
+ import (
18
+ "crypto/sha256"
19
+ _ "embed" // Needed for the go:embed directive below.
20
+ )
21
+
22
+ //go:embed assets/da14531-firmware.bin
23
+ var bluetoothFirmware []byte
24
+
25
+ func bundledBluetoothFirmwareHash () []byte {
26
+ hash := sha256 .Sum256 (bluetoothFirmware )
27
+ return hash [:]
28
+ }
Original file line number Diff line number Diff line change 17
17
package bitbox02
18
18
19
19
import (
20
+ "encoding/hex"
21
+
20
22
deviceevent "github.com/BitBoxSwiss/bitbox-wallet-app/backend/devices/device/event"
21
23
keystoreInterface "github.com/BitBoxSwiss/bitbox-wallet-app/backend/keystore"
22
24
"github.com/BitBoxSwiss/bitbox-wallet-app/util/logging"
@@ -90,6 +92,27 @@ func NewDevice(
90
92
Subject : string (deviceevent .EventKeystoreAvailable ),
91
93
Action : action .Replace ,
92
94
})
95
+
96
+ }
97
+ }
98
+
99
+ // Temporary automatic Bluetooth firmware upgrade during the testing phase. We prompt an
100
+ // upgrade every time if the bundled firmware does not match the actual firmware on the
101
+ // device. TODO: remove before production release.
102
+ if ev == firmware .EventStatusChanged && device .SupportsBluetooth () {
103
+ switch device .Device .Status () {
104
+ case firmware .StatusInitialized , firmware .StatusUninitialized :
105
+ info , err := device .DeviceInfo ()
106
+ if err != nil {
107
+ device .log .WithError (err ).Error ("DeviceInfo" )
108
+ return
109
+ }
110
+ if info .Bluetooth != nil &&
111
+ info .Bluetooth .FirmwareHash != hex .EncodeToString (bundledBluetoothFirmwareHash ()) {
112
+ if err := device .BluetoothUpgrade (bluetoothFirmware ); err != nil {
113
+ device .log .WithError (err ).Error ("BluetoothUpgrade" )
114
+ }
115
+ }
93
116
}
94
117
}
95
118
})
You can’t perform that action at this time.
0 commit comments