Skip to content

Commit fbd97a6

Browse files
committed
chore(deps): updating ios mcu lib
1 parent 2caaea7 commit fbd97a6

File tree

8 files changed

+267
-278
lines changed

8 files changed

+267
-278
lines changed

android/src/main/java/uk/co/playerdata/reactnativemcumanager/DeviceUpgrade.kt

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ import io.runtime.mcumgr.exception.McuMgrException
1414
import java.io.IOException
1515

1616
val UpgradeModes =
17-
mapOf(
18-
1 to FirmwareUpgradeManager.Mode.TEST_AND_CONFIRM,
19-
2 to FirmwareUpgradeManager.Mode.CONFIRM_ONLY,
20-
3 to FirmwareUpgradeManager.Mode.TEST_ONLY
21-
)
17+
mapOf(
18+
1 to FirmwareUpgradeManager.Mode.TEST_AND_CONFIRM,
19+
2 to FirmwareUpgradeManager.Mode.CONFIRM_ONLY,
20+
3 to FirmwareUpgradeManager.Mode.TEST_ONLY
21+
)
2222

2323
class DeviceUpgrade(
24-
private val id: String,
25-
device: BluetoothDevice,
26-
private val context: Context,
27-
private val updateFileUri: Uri,
28-
private val updateOptions: UpdateOptions,
29-
private val manager: ReactNativeMcuManagerModule
24+
private val id: String,
25+
device: BluetoothDevice,
26+
private val context: Context,
27+
private val updateFileUri: Uri,
28+
private val updateOptions: UpdateOptions,
29+
private val manager: ReactNativeMcuManagerModule
3030
) : FirmwareUpgradeCallback {
3131
private val TAG = "DeviceUpdate"
3232
private var lastNotification = -1
@@ -54,13 +54,7 @@ class DeviceUpgrade(
5454
disconnectDevice()
5555
Log.v(this.TAG, "Cancel")
5656
withSafePromise { promise ->
57-
promise.reject(
58-
CodedException(
59-
"UPGRADE_CANCELLED",
60-
"Upgrade cancelled",
61-
null
62-
)
63-
)
57+
promise.reject(CodedException("UPGRADE_CANCELLED", "Upgrade cancelled", null))
6458
}
6559
}
6660

@@ -93,20 +87,16 @@ class DeviceUpgrade(
9387
disconnectDevice()
9488
Log.v(this.TAG, "mcu exception")
9589
withSafePromise { promise ->
96-
promise.reject(
97-
ReactNativeMcuMgrException.fromMcuMgrException(
98-
e
99-
)
100-
)
90+
promise.reject(ReactNativeMcuMgrException.fromMcuMgrException(e))
10191
}
10292
}
10393
}
10494

10595
override fun onUpgradeStarted(controller: FirmwareUpgradeController) {}
10696

10797
override fun onStateChanged(
108-
prevState: FirmwareUpgradeManager.State,
109-
newState: FirmwareUpgradeManager.State
98+
prevState: FirmwareUpgradeManager.State,
99+
newState: FirmwareUpgradeManager.State
110100
) {
111101
val stateMap: Map<String, Any?> = mapOf("id" to id, "state" to newState.name)
112102
manager.upgradeStateCB(stateMap)
@@ -120,24 +110,14 @@ class DeviceUpgrade(
120110
override fun onUpgradeFailed(state: FirmwareUpgradeManager.State, error: McuMgrException) {
121111
disconnectDevice()
122112
withSafePromise { promise ->
123-
promise.reject(
124-
ReactNativeMcuMgrException.fromMcuMgrException(
125-
error
126-
)
127-
)
113+
promise.reject(ReactNativeMcuMgrException.fromMcuMgrException(error))
128114
}
129115
}
130116

131117
override fun onUpgradeCanceled(state: FirmwareUpgradeManager.State) {
132118
disconnectDevice()
133119
withSafePromise { promise ->
134-
promise.reject(
135-
CodedException(
136-
"UPGRADE_CANCELLED",
137-
"Upgrade cancelled",
138-
null
139-
)
140-
)
120+
promise.reject(CodedException("UPGRADE_CANCELLED", "Upgrade cancelled", null))
141121
}
142122
}
143123

android/src/main/java/uk/co/playerdata/reactnativemcumanager/ReactNativeMcuMgrException.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import io.runtime.mcumgr.exception.McuMgrErrorException
1010
import io.runtime.mcumgr.exception.McuMgrException
1111
import io.runtime.mcumgr.exception.McuMgrTimeoutException
1212

13-
class ReactNativeMcuMgrException private constructor(
14-
code: String, message: String?, cause: Throwable?
15-
) : CodedException(code, message, cause) {
13+
class ReactNativeMcuMgrException
14+
private constructor(code: String, message: String?, cause: Throwable?) :
15+
CodedException(code, message, cause) {
1616

1717
companion object {
1818
private fun getCode(e: McuMgrException): String {

example/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default function App() {
127127
<Text style={styles.block}>Step 4 - Update</Text>
128128

129129
<View style={styles.block}>
130-
<Text>Update Progress / State:</Text>
130+
<Text>State / Update Progress:</Text>
131131
<Text>
132132
{state}: {progress}
133133
</Text>

example/src/useBluetoothDevices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const useBluetoothDevices = () => {
2727
deviceIdRef.current.push(scannedDevice.id);
2828

2929
setDevices((oldDevices) =>
30-
sortBy(uniqBy([...oldDevices, scannedDevice], 'id'), 'name')
30+
sortBy(uniqBy([scannedDevice, ...oldDevices], 'id'), 'name')
3131
);
3232
}
3333
)

0 commit comments

Comments
 (0)