feat(binding): verify 4G relations before Banban unbind
This commit is contained in:
@@ -399,8 +399,24 @@ class TalkingQMQTTService:
|
||||
params = payload
|
||||
status = params.get("status")
|
||||
logger.info(device_id, "", f"[NFC绑定] 设备 {device_id} 请求绑定卡片返回状态: {status}")
|
||||
data = params.get("data", {})
|
||||
if status != "success":
|
||||
return
|
||||
data = params.get("data")
|
||||
if not isinstance(data, dict) or not isinstance(data.get("uuid"), str) or not data["uuid"].strip():
|
||||
logger.warning(device_id, "", "[NFC bind] invalid card response")
|
||||
return
|
||||
nfc_uuid = data.get("uuid")
|
||||
from banban.service.traffic_handoff import normalize_iccid
|
||||
logger.info(device_id, "", f"[NFC bind] 006 ICCID present={'iccid' in data}, valid={normalize_iccid(data.get('iccid')) is not None}")
|
||||
if data.get("iccid") is not None:
|
||||
from banban.service.joint_binding import joint_binding_service
|
||||
try:
|
||||
await asyncio.wait_for(joint_binding_service.record_iccid(device_id, data["iccid"]), timeout=2)
|
||||
logger.info(device_id, "", "[NFC bind] 006 ICCID persisted")
|
||||
except Exception:
|
||||
# A SIM persistence failure must not lose the NFC receipt. The
|
||||
# combined operation remains pending until ICCID is available.
|
||||
logger.warning(device_id, "", "[NFC bind] ICCID persistence failed; traffic binding pending")
|
||||
# 卡片与设备绑定
|
||||
# await card_service.activate_card(device_id=device_id, card_uuid=nfc_uuid)
|
||||
result = await binding_service.finalize_nfc_bind(device_id=device_id, card_uuid=nfc_uuid)
|
||||
|
||||
Reference in New Issue
Block a user