Browse Source

:sparkles: 适配 Air780EPV 支持来电以及挂断通知

Mizore 1 year ago
parent
commit
d1a155f9f6
1 changed files with 31 additions and 0 deletions
  1. 31 0
      script/main.lua

+ 31 - 0
script/main.lua

@@ -143,4 +143,35 @@ sys.taskInit(function()
     end
 end)
 
+-- 通话相关
+local is_calling = false
+
+sys.subscribe("CC_IND", function(status)
+    if cc == nil then return end
+
+    if status == "INCOMINGCALL" then
+        -- 来电事件, 期间会重复触发
+        if is_calling then return end
+        is_calling = true
+
+        log.info("cc_status", "INCOMINGCALL", "来电事件", cc.lastNum())
+
+        -- 发送通知
+        util_notify.add({ "来电号码: " .. cc.lastNum(), "来电时间: " .. os.date("%Y-%m-%d %H:%M:%S"), "#CALL #CALL_IN" })
+        return
+    end
+
+    if status == "DISCONNECTED" then
+        -- 挂断事件
+        is_calling = false
+        log.info("cc_status", "DISCONNECTED", "挂断事件", cc.lastNum())
+
+        -- 发送通知
+        util_notify.add({ "来电号码: " .. cc.lastNum(), "挂断时间: " .. os.date("%Y-%m-%d %H:%M:%S"), "#CALL #CALL_DISCONNECTED" })
+        return
+    end
+
+    log.info("cc_status", status)
+end)
+
 sys.run()