支持设备短按向家长留言
This commit is contained in:
@@ -335,8 +335,21 @@ class TalkingQMQTTService:
|
||||
|
||||
async def _handle_short_press_message(self, device_id: str, payload: dict):
|
||||
params = payload.get("params", {})
|
||||
nfc_uuid = params.get("uuid")
|
||||
nfc_uuid = str(params.get("uuid") or "").strip()
|
||||
logger.info(device_id, "", f"[短按留言] 设备 {device_id} 短按发送留言, UUID={nfc_uuid}")
|
||||
if nfc_uuid == settings.talkingq_parent_message_uuid:
|
||||
await device_target_cache.set_parent_target(device_id, nfc_uuid)
|
||||
response_payload = {
|
||||
"msg_id": "011",
|
||||
"status": "success",
|
||||
"type": 0,
|
||||
"params": {
|
||||
"url": "http://175.24.73.253:8080/assets/audio/message_ok.mp3"
|
||||
},
|
||||
}
|
||||
await self._publish(f"device/{device_id}/event_resp", response_payload)
|
||||
return
|
||||
|
||||
media_file_key = str(params.get("media_file_key") or params.get("audio_url") or "").strip()
|
||||
if media_file_key:
|
||||
try:
|
||||
@@ -351,6 +364,18 @@ class TalkingQMQTTService:
|
||||
ext_json=params.get("ext_json") if isinstance(params.get("ext_json"), dict) else None,
|
||||
)
|
||||
logger.info(device_id, "", f"[短按留言] 设备 {device_id} 留言已写入家长会话")
|
||||
await self._publish(
|
||||
f"device/{device_id}/event_resp",
|
||||
{
|
||||
"msg_id": "011",
|
||||
"status": "success",
|
||||
"type": 0,
|
||||
"params": {
|
||||
"url": "http://175.24.73.253:8080/assets/audio/message_ok.mp3"
|
||||
},
|
||||
},
|
||||
)
|
||||
return
|
||||
except Exception as exc:
|
||||
logger.warning(device_id, "", f"[短按留言] 设备 {device_id} 留言写入失败: {exc}")
|
||||
await self._publish(
|
||||
@@ -363,14 +388,7 @@ class TalkingQMQTTService:
|
||||
)
|
||||
return
|
||||
|
||||
payload = {
|
||||
"msg_id": "011",
|
||||
"status": "success",
|
||||
"type": 0,
|
||||
"params": {
|
||||
"url": f"http://{settings.server_host}:{settings.server_port}/assets/audio/message_ok.mp3"
|
||||
}
|
||||
}
|
||||
payload = {"msg_id": "011", "status": "failed", "message": "unsupported uuid"}
|
||||
await self._publish(f"device/{device_id}/event_resp", payload)
|
||||
|
||||
async def _handle_device_identity_init(self, imei: str, payload: dict):
|
||||
|
||||
Reference in New Issue
Block a user