|
|
|
@ -268,6 +268,13 @@ class OtaPlugin : BleService.Callback, FlutterPlugin, MethodCallHandler { |
|
|
|
streamSink = null |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
override fun onMethodCall(call: MethodCall, result: Result) { |
|
|
|
if (call.method == "init") { |
|
|
|
|
|
|
|
// 初始化 otaManager 和 bluetoothHelper |
|
|
|
ConfigHelper.initialize(context) |
|
|
|
otaManager = OTAManager(context) |
|
|
|
@ -289,11 +296,9 @@ class OtaPlugin : BleService.Callback, FlutterPlugin, MethodCallHandler { |
|
|
|
} |
|
|
|
|
|
|
|
Log.i("TAG", "onAttachedToEngine") |
|
|
|
|
|
|
|
result.success("") |
|
|
|
} |
|
|
|
|
|
|
|
override fun onMethodCall(call: MethodCall, result: Result) { |
|
|
|
if (call.method == "startUpgrading") { |
|
|
|
else if (call.method == "startUpgrading") { |
|
|
|
Log.d("TAG", "startUpgrading") |
|
|
|
// 接收传入的参数 |
|
|
|
val arguments = call.arguments as? Map<String, Any> |
|
|
|
@ -326,13 +331,16 @@ class OtaPlugin : BleService.Callback, FlutterPlugin, MethodCallHandler { |
|
|
|
BleService.isEnterOta = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
result.success("") |
|
|
|
|
|
|
|
} else if (call.method == "onOtaClose") { |
|
|
|
BleService.isEnterOta = false |
|
|
|
isDisconnect = false |
|
|
|
otaManager.bluetoothHelper.stopScan() |
|
|
|
otaManager.bluetoothHelper.disconnectDevice(otaDevice) |
|
|
|
otaManager?.bluetoothHelper?.stopScan() |
|
|
|
|
|
|
|
otaManager?.bluetoothHelper?.disconnectDevice(otaDevice) |
|
|
|
|
|
|
|
result.success("") |
|
|
|
} else { |
|
|
|
result.notImplemented() |
|
|
|
} |
|
|
|
|