@@ -39,6 +39,7 @@ import (
3939 "github.com/BitBoxSwiss/bitbox-wallet-app/backend/config"
4040 "github.com/BitBoxSwiss/bitbox-wallet-app/backend/devices/bitbox"
4141 "github.com/BitBoxSwiss/bitbox-wallet-app/backend/devices/bitbox02"
42+ "github.com/BitBoxSwiss/bitbox-wallet-app/backend/devices/bluetooth"
4243 "github.com/BitBoxSwiss/bitbox-wallet-app/backend/devices/device"
4344 deviceevent "github.com/BitBoxSwiss/bitbox-wallet-app/backend/devices/device/event"
4445 "github.com/BitBoxSwiss/bitbox-wallet-app/backend/devices/usb"
@@ -176,6 +177,9 @@ type Environment interface {
176177 // OnAuthSettingChanged is called when the authentication (screen lock) setting is changed.
177178 // This is also called when the app launches with the current setting.
178179 OnAuthSettingChanged (enabled bool )
180+ // BluetoothConnect tries to connect to the peripheral by the given identifier.
181+ // Use `backend.bluetooth.State()` to track failure.
182+ BluetoothConnect (identifier string )
179183}
180184
181185// Backend ties everything together and is the main starting point to use the BitBox wallet library.
@@ -194,6 +198,7 @@ type Backend struct {
194198 devices map [string ]device.Interface
195199
196200 usbManager * usb.Manager
201+ bluetooth * bluetooth.Bluetooth
197202
198203 accountsAndKeystoreLock locker.Locker
199204 accounts AccountsList
@@ -265,7 +270,6 @@ func NewBackend(arguments *arguments.Arguments, environment Environment) (*Backe
265270 coins : map [coinpkg.Code ]coinpkg.Coin {},
266271 accounts : []accounts.Interface {},
267272 aopp : AOPP {State : aoppStateInactive },
268-
269273 makeBtcAccount : func (config * accounts.AccountConfig , coin * btc.Coin , gapLimits * types.GapLimits , log * logrus.Entry ) accounts.Interface {
270274 return btc .NewAccount (config , coin , gapLimits , log , hclient )
271275 },
@@ -297,6 +301,9 @@ func NewBackend(arguments *arguments.Arguments, environment Environment) (*Backe
297301 backend .banners = banners .NewBanners ()
298302 backend .banners .Observe (backend .Notify )
299303
304+ backend .bluetooth = bluetooth .New (log )
305+ backend .bluetooth .Observe (backend .Notify )
306+
300307 return backend , nil
301308}
302309
@@ -1052,3 +1059,8 @@ func (backend *Backend) ExportLogs() error {
10521059 }
10531060 return nil
10541061}
1062+
1063+ // Bluetooth returns the backend's bluetooth instance.
1064+ func (backend * Backend ) Bluetooth () * bluetooth.Bluetooth {
1065+ return backend .bluetooth
1066+ }
0 commit comments