@@ -42,17 +42,13 @@ type Device struct {
42
42
bootloader.Device
43
43
deviceID string
44
44
45
- mu sync.RWMutex
46
- onEvent func (event.Event , interface {})
45
+ mu sync.RWMutex
47
46
48
47
log * logrus.Entry
49
48
50
49
observable.Implementation
51
50
}
52
51
53
- // EventStatusChanged is fired when the status changes. Check the status using Status().
54
- const EventStatusChanged event.Event = "statusChanged"
55
-
56
52
// NewDevice creates a new instance of Device.
57
53
func NewDevice (
58
54
deviceID string ,
@@ -134,26 +130,14 @@ func (device *Device) Keystore() keystoreInterface.Keystore {
134
130
135
131
// SetOnEvent implements device.Device.
136
132
func (device * Device ) SetOnEvent (onEvent func (event.Event , interface {})) {
137
- device .mu .Lock ()
138
- defer device .mu .Unlock ()
139
- device .onEvent = onEvent
140
133
}
141
134
142
135
func (device * Device ) fireEvent () {
143
- device .mu .RLock ()
144
- f := device .onEvent
145
- device .mu .RUnlock ()
146
- if f != nil {
147
- // Old-school
148
- f (EventStatusChanged , nil )
149
-
150
- // New-school
151
- device .Notify (observable.Event {
152
- Subject : fmt .Sprintf ("status" ),
153
- Action : action .Replace ,
154
- Object : device .Status (),
155
- })
156
- }
136
+ device .Notify (observable.Event {
137
+ Subject : fmt .Sprintf ("status" ),
138
+ Action : action .Replace ,
139
+ Object : device .Status (),
140
+ })
157
141
}
158
142
159
143
// firmwareBootRequired returns true if the currently flashed firmware has to be booted/run before
@@ -269,7 +253,7 @@ func (device *Device) VersionInfo() (*VersionInfo, error) {
269
253
brokenInstall := latestFirmwareVersion == currentFirmwareVersion &&
270
254
! bytes .Equal (currentFirmwareHash , latestFirmwareHash )
271
255
272
- canUpgrade := erased || latestFirmwareVersion > currentFirmwareVersion || brokenInstall || true
256
+ canUpgrade := erased || latestFirmwareVersion > currentFirmwareVersion || brokenInstall
273
257
additionalUpgradeFollows := nextFw .monotonicVersion < latestFirmwareVersion
274
258
device .log .
275
259
WithField ("latestFirmwareVersion" , latestFirmwareVersion ).
0 commit comments