feat(sdk): 同步 iOS 改动 — owner→brand 重命名 + 硬绑前 brand 校验 + README 内部细节抹除

- DuooomiBleConfig.owner → brand(语义:设备品牌名),HTTP header x-owner 不变
- bind() 前置 verifyBrand:缺 deviceInfo 先 getDeviceInfo,与 config.brand 严格匹配,
  不一致主动 disconnect 并抛 DuooomiBleError.BrandMismatch
- README 抹除软绑/对账/UpgradeRecord 等内部实现细节,仅保留厂商面向的公开 API
  (功能代码完全保留:fetchLatestFirmware 内部三段串、unbind 软解、tryReportPendingUpgrade)
- README 顶部加 demo 优先验证提示

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
km2023
2026-05-09 12:03:26 +08:00
parent d336ac358e
commit e63865092c
8 changed files with 45 additions and 59 deletions

View File

@@ -65,7 +65,7 @@ fun DemoScreen(
val upgradeRecords by sdk.upgradeRecords.collectAsState()
// Editable config (rekey on sdk change so new SDK 不会带着旧编辑残留)
var configOwner by remember(sdk) { mutableStateOf(config.owner) }
var configBrand by remember(sdk) { mutableStateOf(config.brand) }
var configApiKey by remember(sdk) { mutableStateOf(config.apiKey) }
var configScanPrefix by remember(sdk) { mutableStateOf(config.scanPrefix) }
@@ -126,14 +126,14 @@ fun DemoScreen(
// === Config Section ===
item {
SectionHeader("SDK Config修改后点 Reload 生效)")
ConfigField("x-owner", configOwner) { configOwner = it }
ConfigField("brand", configBrand) { configBrand = it }
ConfigField("apiKey", configApiKey) { configApiKey = it }
ConfigField("scanPrefix", configScanPrefix) { configScanPrefix = it }
Button(
onClick = {
onReload(DemoConfig(configOwner, configApiKey, configScanPrefix))
onReload(DemoConfig(configBrand, configApiKey, configScanPrefix))
log(
"SDK reloaded with owner=$configOwner, prefix=$configScanPrefix",
"SDK reloaded with brand=$configBrand, prefix=$configScanPrefix",
LogLevel.SUCCESS
)
},

View File

@@ -35,7 +35,7 @@ class MainActivity : ComponentActivity() {
val prefs = getSharedPreferences(PREFS, Context.MODE_PRIVATE)
val initialConfig = DemoConfig(
owner = prefs.getString(KEY_OWNER, DemoSecrets.OWNER) ?: DemoSecrets.OWNER,
brand = prefs.getString(KEY_BRAND, DemoSecrets.BRAND) ?: DemoSecrets.BRAND,
apiKey = prefs.getString(KEY_API_KEY, DemoSecrets.API_KEY) ?: DemoSecrets.API_KEY,
scanPrefix = prefs.getString(KEY_SCAN_PREFIX, DemoSecrets.SCAN_NAME_PREFIX)
?: DemoSecrets.SCAN_NAME_PREFIX
@@ -69,14 +69,14 @@ class MainActivity : ComponentActivity() {
context = this,
config = DuooomiBleConfig(
apiKey = c.apiKey,
owner = c.owner,
brand = c.brand,
scanNamePrefix = c.scanPrefix
)
)
private fun persist(prefs: SharedPreferences, c: DemoConfig) {
prefs.edit()
.putString(KEY_OWNER, c.owner)
.putString(KEY_BRAND, c.brand)
.putString(KEY_API_KEY, c.apiKey)
.putString(KEY_SCAN_PREFIX, c.scanPrefix)
.apply()
@@ -101,14 +101,14 @@ class MainActivity : ComponentActivity() {
private companion object {
const val PREFS = "demo_config"
const val KEY_OWNER = "demo.config.owner"
const val KEY_BRAND = "demo.config.brand"
const val KEY_API_KEY = "demo.config.apiKey"
const val KEY_SCAN_PREFIX = "demo.config.scanPrefix"
}
}
data class DemoConfig(
val owner: String,
val brand: String,
val apiKey: String,
val scanPrefix: String
)