fix:sdk增加判断是否需要更新的方法

This commit is contained in:
km2023
2026-04-13 18:36:59 +08:00
parent d655b13416
commit 18c6f5e098
2 changed files with 17 additions and 0 deletions

View File

@@ -479,6 +479,16 @@ class DuooomiBleSDK(context: Context, val config: DuooomiBleConfig) {
} ?: BleLog.w("No pending continuation for opId=$opId", "RPC")
}
// MARK: - Version Check
fun hasNewerFirmware(deviceVersion: String?, serverVersion: String?): Boolean {
if (deviceVersion.isNullOrEmpty() || serverVersion.isNullOrEmpty()) return false
if (deviceVersion.length < 10 || serverVersion.length < 10) return false
val deviceTs = deviceVersion.takeLast(10).toLongOrNull() ?: return false
val serverTs = serverVersion.takeLast(10).toLongOrNull() ?: return false
return serverTs > deviceTs
}
// MARK: - Helpers
private fun ensureConnected() {