|
@@ -13,11 +13,13 @@ import android.text.TextUtils
|
|
import android.util.Log
|
|
import android.util.Log
|
|
import android.view.View
|
|
import android.view.View
|
|
import com.alibaba.fastjson.JSON
|
|
import com.alibaba.fastjson.JSON
|
|
|
|
+import com.alibaba.fastjson.JSONObject
|
|
import com.enation.javashop.android.jrouter.external.annotation.Router
|
|
import com.enation.javashop.android.jrouter.external.annotation.Router
|
|
import com.enation.javashop.net.engine.model.NetState
|
|
import com.enation.javashop.net.engine.model.NetState
|
|
import com.google.gson.Gson
|
|
import com.google.gson.Gson
|
|
import com.wdkl.app.ncs.conversion_box.BuildConfig
|
|
import com.wdkl.app.ncs.conversion_box.BuildConfig
|
|
import com.wdkl.app.ncs.conversion_box.R
|
|
import com.wdkl.app.ncs.conversion_box.R
|
|
|
|
+import com.wdkl.app.ncs.conversion_box.bean.CallingItem
|
|
import com.wdkl.app.ncs.conversion_box.bean.SosItem
|
|
import com.wdkl.app.ncs.conversion_box.bean.SosItem
|
|
import com.wdkl.app.ncs.conversion_box.databinding.MainActivityLayoutBinding
|
|
import com.wdkl.app.ncs.conversion_box.databinding.MainActivityLayoutBinding
|
|
import com.wdkl.app.ncs.conversion_box.fragment.*
|
|
import com.wdkl.app.ncs.conversion_box.fragment.*
|
|
@@ -44,8 +46,10 @@ import com.wdkl.ncs.android.middleware.model.vo.InteractionVO
|
|
import com.wdkl.ncs.android.middleware.tcp.TcpClient
|
|
import com.wdkl.ncs.android.middleware.tcp.TcpClient
|
|
import com.wdkl.ncs.android.middleware.tcp.channel.OtherUtil
|
|
import com.wdkl.ncs.android.middleware.tcp.channel.OtherUtil
|
|
import com.wdkl.ncs.android.middleware.tcp.channel.VoiceUtil
|
|
import com.wdkl.ncs.android.middleware.tcp.channel.VoiceUtil
|
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.dto.TcpCallback
|
|
import com.wdkl.ncs.android.middleware.tcp.dto.TcpModel
|
|
import com.wdkl.ncs.android.middleware.tcp.dto.TcpModel
|
|
import com.wdkl.ncs.android.middleware.tcp.enums.DeviceTypeEnum
|
|
import com.wdkl.ncs.android.middleware.tcp.enums.DeviceTypeEnum
|
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.enums.RoleTypeEnum
|
|
import com.wdkl.ncs.android.middleware.tcp.enums.TcpAction
|
|
import com.wdkl.ncs.android.middleware.tcp.enums.TcpAction
|
|
import com.wdkl.ncs.android.middleware.tcp.enums.TcpType
|
|
import com.wdkl.ncs.android.middleware.tcp.enums.TcpType
|
|
import com.wdkl.ncs.android.middleware.udp.ServerInfoUtil
|
|
import com.wdkl.ncs.android.middleware.udp.ServerInfoUtil
|
|
@@ -95,7 +99,6 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
private var clickTime : Long = 0
|
|
private var clickTime : Long = 0
|
|
private var clickSosTime : Long = 0
|
|
private var clickSosTime : Long = 0
|
|
|
|
|
|
- lateinit var callTimer: CountDownTimer
|
|
|
|
|
|
|
|
//网络异常计数
|
|
//网络异常计数
|
|
private var netErrCount : Int = 0
|
|
private var netErrCount : Int = 0
|
|
@@ -119,9 +122,13 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
//对方设备id
|
|
//对方设备id
|
|
var fromId: Int = -1
|
|
var fromId: Int = -1
|
|
|
|
|
|
|
|
+ private var tid: String = ""
|
|
|
|
+
|
|
private var sosList = ArrayList<SosItem>()
|
|
private var sosList = ArrayList<SosItem>()
|
|
private var outCallList = ArrayList<String>()
|
|
private var outCallList = ArrayList<String>()
|
|
private var nursingRooms = ArrayList<String>()
|
|
private var nursingRooms = ArrayList<String>()
|
|
|
|
+ //呼叫成功的设备集合
|
|
|
|
+ private var callingList = ArrayList<CallingItem>()
|
|
|
|
|
|
private var serverIp = ""
|
|
private var serverIp = ""
|
|
|
|
|
|
@@ -146,14 +153,9 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
}
|
|
}
|
|
|
|
|
|
override fun init() {
|
|
override fun init() {
|
|
- //开始ping网络,30秒ping一次
|
|
|
|
- //NetHelper.startNetCheck()
|
|
|
|
-
|
|
|
|
//获取mac地址
|
|
//获取mac地址
|
|
Constant.LOCAL_MAC = NetHelper.getInstance().macAddress
|
|
Constant.LOCAL_MAC = NetHelper.getInstance().macAddress
|
|
|
|
|
|
- //presenter.loadTcpServerHost()
|
|
|
|
-
|
|
|
|
//注册广播
|
|
//注册广播
|
|
regReceiver()
|
|
regReceiver()
|
|
|
|
|
|
@@ -179,8 +181,6 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
//val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
|
//val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
|
//alarmManager.setTimeZone("Asia/Shanghai")
|
|
//alarmManager.setTimeZone("Asia/Shanghai")
|
|
|
|
|
|
- //initCallTimer()
|
|
|
|
-
|
|
|
|
//rs485
|
|
//rs485
|
|
/*Thread {
|
|
/*Thread {
|
|
startRs485()
|
|
startRs485()
|
|
@@ -512,7 +512,6 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
|
|
|
|
|
|
|
|
override fun destory() {
|
|
override fun destory() {
|
|
- //callTimer.cancel()
|
|
|
|
unRegReceiver()
|
|
unRegReceiver()
|
|
EventBus.getDefault().unregister(this)
|
|
EventBus.getDefault().unregister(this)
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
@@ -528,7 +527,6 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
|
|
|
|
//数据加载错误
|
|
//数据加载错误
|
|
override fun onError(message: String, type: Int) {
|
|
override fun onError(message: String, type: Int) {
|
|
- //errorLog("error",message)
|
|
|
|
showMessage(message)
|
|
showMessage(message)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -718,34 +716,6 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
}, 5000)*/
|
|
}, 5000)*/
|
|
}
|
|
}
|
|
|
|
|
|
- private fun initCallTimer() {
|
|
|
|
- var overTime = SettingConfig.getSipOverTime(activity)
|
|
|
|
- if (overTime <= 0) {
|
|
|
|
- overTime = 30
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- callTimer = object: CountDownTimer(overTime*1000L, 1000) {
|
|
|
|
- override fun onTick(millisUntilFinished: Long) {
|
|
|
|
- //
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- override fun onFinish() {
|
|
|
|
- //呼叫超时,退出呼叫界面
|
|
|
|
- showMessage(R.string.no_response)
|
|
|
|
- updateCallText(getString(R.string.call_standby))
|
|
|
|
- if (curInteractionVO != null) {
|
|
|
|
- VoiceUtil.cancelAudioCall(curInteractionVO!!.fromDeviceId)
|
|
|
|
- SerialPortHelper.closeSoundChannel(curInteractionVO!!.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
- val doorAddr = getDoorLightAddr(curInteractionVO!!.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
- if (!TextUtils.isEmpty(doorAddr)) {
|
|
|
|
- SerialPortHelper.closeDoorLight(doorAddr)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
|
|
override fun setPartSettings(partSetting: PartSettingDO) {
|
|
override fun setPartSettings(partSetting: PartSettingDO) {
|
|
//设置白昼起止时间
|
|
//设置白昼起止时间
|
|
@@ -817,7 +787,7 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
tcpConnect = true
|
|
tcpConnect = true
|
|
Thread(Runnable {
|
|
Thread(Runnable {
|
|
TcpClient.getInstance().init(Constant.TCP_SERVER_URL, Constant.TCP_PORT, Constant.TCP_HEART_BEAT)
|
|
TcpClient.getInstance().init(Constant.TCP_SERVER_URL, Constant.TCP_PORT, Constant.TCP_HEART_BEAT)
|
|
- TcpClient.getInstance().setTcpCallback {
|
|
|
|
|
|
+ TcpClient.getInstance().setTcpSendCallback {
|
|
updateSendTcpInfo(it)
|
|
updateSendTcpInfo(it)
|
|
}
|
|
}
|
|
}).start()
|
|
}).start()
|
|
@@ -873,15 +843,10 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
} else if (Constant.CALL_STATE == Constant.CALL_INCOMING && addr.equals(curDeviceUart, true)) {
|
|
} else if (Constant.CALL_STATE == Constant.CALL_INCOMING && addr.equals(curDeviceUart, true)) {
|
|
//分机接听
|
|
//分机接听
|
|
RingPlayHelper.stopRingTone()
|
|
RingPlayHelper.stopRingTone()
|
|
- VoiceUtil.acceptAudioCall(curDeviceId, fromId, curInteractionVO!!.id)
|
|
|
|
|
|
+ VoiceUtil.acceptAudioCall(tid, curDeviceId, fromId, curInteractionVO!!.id)
|
|
showCallFragment()
|
|
showCallFragment()
|
|
} else {
|
|
} else {
|
|
//分机呼叫
|
|
//分机呼叫
|
|
- /*if (curInteractionVO == null) {
|
|
|
|
- startCall(addr)
|
|
|
|
- } else if (!addr.equals(curInteractionVO!!.fromEthMac, true) && !addr.equals(curInteractionVO!!.toEthMac, true)) {
|
|
|
|
- startCall(addr)
|
|
|
|
- }*/
|
|
|
|
startCall(addr)
|
|
startCall(addr)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1038,10 +1003,34 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
if (frameDevice.device.deviceType == DeviceTypeEnum.SIMULATE_BED_DEVICE.value()) {
|
|
if (frameDevice.device.deviceType == DeviceTypeEnum.SIMULATE_BED_DEVICE.value()) {
|
|
curDeviceId = frameDevice.device.id
|
|
curDeviceId = frameDevice.device.id
|
|
updateCallText(getString(R.string.call_in_calling) + "$uart, $curDeviceId")
|
|
updateCallText(getString(R.string.call_in_calling) + "$uart, $curDeviceId")
|
|
- VoiceUtil.startAudioCall(curDeviceId)
|
|
|
|
- if (Constant.CALL_STATE == Constant.CALL_STANDBY) {
|
|
|
|
- Constant.CALL_STATE = Constant.CALL_OUTGOING
|
|
|
|
|
|
+
|
|
|
|
+ //VoiceUtil.startAudioCall(curDeviceId)
|
|
|
|
+ val tcpModel = VoiceUtil.voiceCall(curDeviceId, RoleTypeEnum.NURSE.name)
|
|
|
|
+ val transaction: TcpCallback = object : TcpCallback(tcpModel.tid, uart) {
|
|
|
|
+ override fun onSuccess(jsonObject: JSONObject) {
|
|
|
|
+ if (Constant.CALL_STATE == Constant.CALL_STANDBY) {
|
|
|
|
+ Constant.CALL_STATE = Constant.CALL_OUTGOING
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onFailed(jsonObject: JSONObject) {
|
|
|
|
+ // 这里写发送失败的方法
|
|
|
|
+ val callbackString = jsonObject.getString(CALLBACK)
|
|
|
|
+ Log.e(TAG, "call fail: $callbackString, mac: $mac")
|
|
|
|
+ //呼叫失败,关闭对应分机
|
|
|
|
+ if (!TextUtils.isEmpty(mac)) {
|
|
|
|
+ Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
|
|
+ updateCallText(getString(R.string.call_standby))
|
|
|
|
+ //关闭分机呼叫和门灯
|
|
|
|
+ SerialPortHelper.closeSoundChannel(mac)
|
|
|
|
+ val doorAddr = getDoorLightAddr(mac)
|
|
|
|
+ if (!TextUtils.isEmpty(doorAddr)) {
|
|
|
|
+ SerialPortHelper.closeDoorLight(doorAddr)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ TcpClient.getInstance().sendTcp(tcpModel, false, transaction)
|
|
}
|
|
}
|
|
break
|
|
break
|
|
}
|
|
}
|
|
@@ -1054,12 +1043,23 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
}
|
|
}
|
|
|
|
|
|
private fun cancelOutCall(uart: String, resetCall: Boolean) {
|
|
private fun cancelOutCall(uart: String, resetCall: Boolean) {
|
|
- //callTimer.cancel()
|
|
|
|
if (FrameHelper.frameDeviceList.size > 0 ) {
|
|
if (FrameHelper.frameDeviceList.size > 0 ) {
|
|
for (frameDevice in FrameHelper.frameDeviceList) {
|
|
for (frameDevice in FrameHelper.frameDeviceList) {
|
|
if (frameDevice.device != null && uart.equals(frameDevice.device.ethMac, true)) {
|
|
if (frameDevice.device != null && uart.equals(frameDevice.device.ethMac, true)) {
|
|
updateCallText(getString(R.string.call_standby))
|
|
updateCallText(getString(R.string.call_standby))
|
|
- VoiceUtil.cancelAudioCall(frameDevice.device.id)
|
|
|
|
|
|
+
|
|
|
|
+ var findDevice = false
|
|
|
|
+ for (item in callingList) {
|
|
|
|
+ if (item.deviceId == frameDevice.device.id) {
|
|
|
|
+ findDevice = true
|
|
|
|
+ val callTcp = VoiceUtil.voiceCancel(item.tid, frameDevice.device.id, item.interactionId)
|
|
|
|
+ TcpClient.getInstance().sendMsg(callTcp.toJson())
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!findDevice) {
|
|
|
|
+ VoiceUtil.cancelAudioCall2(frameDevice.device.id)
|
|
|
|
+ }
|
|
|
|
+
|
|
if (resetCall) {
|
|
if (resetCall) {
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
}
|
|
}
|
|
@@ -1076,18 +1076,9 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private fun cancelOutCall() {
|
|
|
|
- //callTimer.cancel()
|
|
|
|
- if (curInteractionVO != null) {
|
|
|
|
- VoiceUtil.cancelAudioCall(curInteractionVO!!.fromDeviceId)
|
|
|
|
- }
|
|
|
|
- updateCallText(getString(R.string.call_standby))
|
|
|
|
- Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private fun rejectCall() {
|
|
private fun rejectCall() {
|
|
updateCallText(getString(R.string.call_standby))
|
|
updateCallText(getString(R.string.call_standby))
|
|
- VoiceUtil.rejectAudioCall(curDeviceId, fromId, curInteractionVO!!.id)
|
|
|
|
|
|
+ VoiceUtil.rejectAudioCall(tid, curDeviceId, fromId, curInteractionVO!!.id)
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1096,17 +1087,32 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
for (frameDevice in FrameHelper.frameDeviceList) {
|
|
for (frameDevice in FrameHelper.frameDeviceList) {
|
|
if (frameDevice.device != null && uart.equals(frameDevice.device.ethMac, true)) {
|
|
if (frameDevice.device != null && uart.equals(frameDevice.device.ethMac, true)) {
|
|
updateCallText("SOS-->$uart, ${frameDevice.device.id}")
|
|
updateCallText("SOS-->$uart, ${frameDevice.device.id}")
|
|
- OtherUtil.sendSosCall(frameDevice.device.id)
|
|
|
|
|
|
+ //OtherUtil.sendSosCall(frameDevice.device.id)
|
|
|
|
+
|
|
|
|
+ val tcpModel = OtherUtil.SOSCall(frameDevice.device.id, 0)
|
|
|
|
+ val transaction: TcpCallback = object : TcpCallback(tcpModel.tid, uart) {
|
|
|
|
+ override fun onSuccess(jsonObject: JSONObject) {
|
|
|
|
+ //开启门灯
|
|
|
|
+ Log.d(TAG, "sos call success, mac: $mac")
|
|
|
|
+ val doorAddr = getDoorLightAddrBySos(mac)
|
|
|
|
+ if (!TextUtils.isEmpty(doorAddr)) {
|
|
|
|
+ SerialPortHelper.openDoorLightRed(doorAddr)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override fun onFailed(jsonObject: JSONObject) {
|
|
|
|
+ // 这里写发送失败的方法
|
|
|
|
+ val callbackString = jsonObject.getString(CALLBACK)
|
|
|
|
+ Log.e(TAG, "sos call fail: $callbackString, mac: $mac")
|
|
|
|
+ //关闭紧急按钮
|
|
|
|
+ SerialPortHelper.closeEmergency(mac)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ TcpClient.getInstance().sendTcp(tcpModel, false, transaction)
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- //开启门灯
|
|
|
|
- val doorAddr = getDoorLightAddrBySos(uart)
|
|
|
|
- if (!TextUtils.isEmpty(doorAddr)) {
|
|
|
|
- SerialPortHelper.openDoorLightRed(doorAddr)
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private fun cancelSosCall(uart: String) {
|
|
private fun cancelSosCall(uart: String) {
|
|
@@ -1140,36 +1146,6 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- //创建会话
|
|
|
|
- /*private fun startSipCall(targetId: String): Boolean {
|
|
|
|
- val room = UUID.randomUUID().toString() + System.currentTimeMillis()
|
|
|
|
- val b = gEngineKit!!.startOutCall(activity, room, targetId, true)
|
|
|
|
- if (b) {
|
|
|
|
- val session = gEngineKit!!.currentSession
|
|
|
|
- if (session == null) {
|
|
|
|
- return false
|
|
|
|
- } else {
|
|
|
|
- session.setSessionCallback(this)
|
|
|
|
- session.toggleSpeaker(false)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return b
|
|
|
|
- }*/
|
|
|
|
-
|
|
|
|
- //语音接通
|
|
|
|
- /*private fun joinAudioCall() {
|
|
|
|
- val session = gEngineKit?.getCurrentSession()
|
|
|
|
- if (session != null) {
|
|
|
|
- Log.e("dds", "audio call session state: " + session.state)
|
|
|
|
- if (session.state == EnumType.CallState.Incoming) {
|
|
|
|
- session.joinHome(session.roomId)
|
|
|
|
- session.toggleSpeaker(false)
|
|
|
|
- } else if (session.state == EnumType.CallState.Idle) {
|
|
|
|
- callEnd()
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }*/
|
|
|
|
-
|
|
|
|
//通过床位分机查找所在房间的门灯
|
|
//通过床位分机查找所在房间的门灯
|
|
private fun getDoorLightAddr(bedAddr: String) : String? {
|
|
private fun getDoorLightAddr(bedAddr: String) : String? {
|
|
//首先找到分机所在床位层级,然后通过该bed frame的父级id(即房间层级)找到对应room frame,获得门灯设备信息
|
|
//首先找到分机所在床位层级,然后通过该bed frame的父级id(即房间层级)找到对应room frame,获得门灯设备信息
|
|
@@ -1298,7 +1274,18 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
if (frameDevice.frame != null && frameDevice.frame.parentId == roomId) {
|
|
if (frameDevice.frame != null && frameDevice.frame.parentId == roomId) {
|
|
if (frameDevice.device != null && frameDevice.device.deviceType == DeviceTypeEnum.SIMULATE_BED_DEVICE.value()) {
|
|
if (frameDevice.device != null && frameDevice.device.deviceType == DeviceTypeEnum.SIMULATE_BED_DEVICE.value()) {
|
|
//取消分机呼叫
|
|
//取消分机呼叫
|
|
- VoiceUtil.cancelAudioCall(frameDevice.device.id)
|
|
|
|
|
|
+ var findDevice = false
|
|
|
|
+ for (item in callingList) {
|
|
|
|
+ if (item.deviceId == frameDevice.device.id) {
|
|
|
|
+ findDevice = true
|
|
|
|
+ val callTcp = VoiceUtil.voiceCancel(item.tid, frameDevice.device.id, item.interactionId)
|
|
|
|
+ TcpClient.getInstance().sendMsg(callTcp.toJson())
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!findDevice) {
|
|
|
|
+ VoiceUtil.cancelAudioCall2(frameDevice.device.id)
|
|
|
|
+ }
|
|
|
|
+
|
|
Log.d("tcp", "cancel bed call: " + frameDevice.frame.fullName)
|
|
Log.d("tcp", "cancel bed call: " + frameDevice.frame.fullName)
|
|
bedMac = frameDevice.device.ethMac.toUpperCase(Locale.ROOT)
|
|
bedMac = frameDevice.device.ethMac.toUpperCase(Locale.ROOT)
|
|
SerialPortHelper.closeSoundChannel(bedMac)
|
|
SerialPortHelper.closeSoundChannel(bedMac)
|
|
@@ -1419,8 +1406,9 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
if (tcpModel.action == TcpAction.VoiceAction.CALL) {
|
|
if (tcpModel.action == TcpAction.VoiceAction.CALL) {
|
|
//收到通话请求
|
|
//收到通话请求
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
|
+ tid = tcpModel.tid
|
|
fromId = tcpModel.fromId
|
|
fromId = tcpModel.fromId
|
|
- curDeviceUart = interactionVO.toEthMac.toUpperCase(Locale.ROOT)
|
|
|
|
|
|
+ curDeviceUart = interactionVO.toEthIp.toUpperCase(Locale.ROOT)
|
|
curInteractionVO = interactionVO
|
|
curInteractionVO = interactionVO
|
|
curDeviceId = interactionVO.toDeviceId
|
|
curDeviceId = interactionVO.toDeviceId
|
|
targetSip = interactionVO.fromSipId
|
|
targetSip = interactionVO.fromSipId
|
|
@@ -1435,7 +1423,7 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
Constant.CALL_STATE = Constant.CALL_INCOMING
|
|
Constant.CALL_STATE = Constant.CALL_INCOMING
|
|
if (Constant.autoAnswer) {
|
|
if (Constant.autoAnswer) {
|
|
//自动接听
|
|
//自动接听
|
|
- VoiceUtil.acceptAudioCall(tcpModel.toId, fromId, interactionVO?.id)
|
|
|
|
|
|
+ VoiceUtil.acceptAudioCall(tid, tcpModel.toId, fromId, interactionVO?.id)
|
|
showCallFragment()
|
|
showCallFragment()
|
|
} else {
|
|
} else {
|
|
//响铃并手动接听
|
|
//响铃并手动接听
|
|
@@ -1444,17 +1432,17 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
}
|
|
}
|
|
} else if (tcpModel.getAction() == TcpAction.VoiceAction.ACCEPT) {
|
|
} else if (tcpModel.getAction() == TcpAction.VoiceAction.ACCEPT) {
|
|
//我方呼出,对方接受
|
|
//我方呼出,对方接受
|
|
- //callTimer.cancel()
|
|
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
fromId = tcpModel.fromId
|
|
fromId = tcpModel.fromId
|
|
- curDeviceUart = interactionVO.fromEthMac.toUpperCase(Locale.ROOT)
|
|
|
|
|
|
+ tid = tcpModel.tid
|
|
|
|
+ curDeviceUart = interactionVO.fromEthIp.toUpperCase(Locale.ROOT)
|
|
curInteractionVO = interactionVO
|
|
curInteractionVO = interactionVO
|
|
curDeviceId = interactionVO.fromDeviceId
|
|
curDeviceId = interactionVO.fromDeviceId
|
|
targetSip = interactionVO.toSipId
|
|
targetSip = interactionVO.toSipId
|
|
showCallFragment()
|
|
showCallFragment()
|
|
|
|
|
|
//从呼叫列表移除
|
|
//从呼叫列表移除
|
|
- outCallList.remove(interactionVO.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
|
|
+ outCallList.remove(interactionVO.fromEthIp.toUpperCase(Locale.ROOT))
|
|
|
|
|
|
//关闭门灯
|
|
//关闭门灯
|
|
val doorAddr = getDoorLightAddr(curDeviceUart)
|
|
val doorAddr = getDoorLightAddr(curDeviceUart)
|
|
@@ -1463,24 +1451,43 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
}
|
|
}
|
|
} else if (tcpModel.getAction() == TcpAction.VoiceAction.SUCCESS) {
|
|
} else if (tcpModel.getAction() == TcpAction.VoiceAction.SUCCESS) {
|
|
//呼叫成功
|
|
//呼叫成功
|
|
- //curDeviceUart = interactionVO.fromEthMac
|
|
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
if (Constant.CALL_STATE == Constant.CALL_OUTGOING) {
|
|
if (Constant.CALL_STATE == Constant.CALL_OUTGOING) {
|
|
Constant.CALL_STATE = Constant.CALL_OUT_SUCCESS
|
|
Constant.CALL_STATE = Constant.CALL_OUT_SUCCESS
|
|
curInteractionVO = interactionVO
|
|
curInteractionVO = interactionVO
|
|
- updateCallText(getString(R.string.call_success) + "-->" + interactionVO.fromEthMac.toUpperCase(Locale.ROOT) + ", " + interactionVO.fromDeviceId)
|
|
|
|
- //callTimer.start()
|
|
|
|
|
|
+ updateCallText(getString(R.string.call_success) + "-->" + interactionVO.fromEthIp.toUpperCase(Locale.ROOT) + ", " + interactionVO.fromDeviceId)
|
|
} /*else if (Constant.CALL_STATE == Constant.CALL_INCOMING || Constant.CALL_STATE == Constant.CALL_CALLING) {
|
|
} /*else if (Constant.CALL_STATE == Constant.CALL_INCOMING || Constant.CALL_STATE == Constant.CALL_CALLING) {
|
|
//因为一个转换盒同时只能存在一个通话,如果当前已经有来电或正在通话中则取消该呼叫,但是门灯不灭掉,表示当前房间刚才存在呼叫等待处理
|
|
//因为一个转换盒同时只能存在一个通话,如果当前已经有来电或正在通话中则取消该呼叫,但是门灯不灭掉,表示当前房间刚才存在呼叫等待处理
|
|
- SerialPortHelper.closeSoundChannel(interactionVO.fromEthMac)
|
|
|
|
- cancelOutCall(interactionVO.fromEthMac, false)
|
|
|
|
|
|
+ SerialPortHelper.closeSoundChannel(interactionVO.fromEthIp)
|
|
|
|
+ cancelOutCall(interactionVO.fromEthIp, false)
|
|
}*/
|
|
}*/
|
|
|
|
|
|
//呼叫成功,添加到呼叫列表
|
|
//呼叫成功,添加到呼叫列表
|
|
- outCallList.add(interactionVO.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
|
|
+ outCallList.add(interactionVO.fromEthIp.toUpperCase(Locale.ROOT))
|
|
|
|
+
|
|
|
|
+ /*if (callingList.size > 0) {
|
|
|
|
+ for ((index, e) in callingList.withIndex()) {
|
|
|
|
+ if (e.uart.equals(interactionVO.fromEthIp, true)) {
|
|
|
|
+ var item = CallingItem(tcpModel.tid, interactionVO.fromDeviceId, interactionVO.fromEthIp, System.currentTimeMillis(), interactionVO.id)
|
|
|
|
+ callingList.set(index, item)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+ if (callingList.size > 0) {
|
|
|
|
+ val iterator = callingList.iterator()
|
|
|
|
+ while (iterator.hasNext()) {
|
|
|
|
+ val it = iterator.next()
|
|
|
|
+ if (interactionVO.fromDeviceId == it.deviceId) {
|
|
|
|
+ iterator.remove()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ val item = CallingItem(tcpModel.tid, interactionVO.fromDeviceId, interactionVO.fromEthIp, System.currentTimeMillis(), interactionVO.id)
|
|
|
|
+ callingList.add(item)
|
|
|
|
|
|
//开启门灯
|
|
//开启门灯
|
|
- val doorAddr = getDoorLightAddr(interactionVO.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
|
|
+ val doorAddr = getDoorLightAddr(interactionVO.fromEthIp.toUpperCase(Locale.ROOT))
|
|
if (!TextUtils.isEmpty(doorAddr)) {
|
|
if (!TextUtils.isEmpty(doorAddr)) {
|
|
if (Constant.colorLight && !Constant.nursingSign) {
|
|
if (Constant.colorLight && !Constant.nursingSign) {
|
|
SerialPortHelper.openDoorLightGreen(doorAddr)
|
|
SerialPortHelper.openDoorLightGreen(doorAddr)
|
|
@@ -1492,16 +1499,15 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
//我方呼出,对方拒绝
|
|
//我方呼出,对方拒绝
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
//从呼叫列表移除
|
|
//从呼叫列表移除
|
|
- outCallList.remove(interactionVO.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
|
|
+ outCallList.remove(interactionVO.fromEthIp.toUpperCase(Locale.ROOT))
|
|
|
|
|
|
//if (curInteractionVO!!.id == interactionVO.id) {
|
|
//if (curInteractionVO!!.id == interactionVO.id) {
|
|
- //callTimer.cancel()
|
|
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
updateCallText(getString(R.string.call_standby))
|
|
updateCallText(getString(R.string.call_standby))
|
|
showMessage(R.string.call_reject)
|
|
showMessage(R.string.call_reject)
|
|
//关闭分机呼叫和门灯
|
|
//关闭分机呼叫和门灯
|
|
- SerialPortHelper.closeSoundChannel(interactionVO.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
- val doorAddr = getDoorLightAddr(interactionVO.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
|
|
+ SerialPortHelper.closeSoundChannel(interactionVO.fromEthIp.toUpperCase(Locale.ROOT))
|
|
|
|
+ val doorAddr = getDoorLightAddr(interactionVO.fromEthIp.toUpperCase(Locale.ROOT))
|
|
if (!TextUtils.isEmpty(doorAddr)) {
|
|
if (!TextUtils.isEmpty(doorAddr)) {
|
|
SerialPortHelper.closeDoorLight(doorAddr)
|
|
SerialPortHelper.closeDoorLight(doorAddr)
|
|
}
|
|
}
|
|
@@ -1510,58 +1516,57 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
//我方呼出,对方通话中
|
|
//我方呼出,对方通话中
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
//if (curInteractionVO!!.id == interactionVO.id) {
|
|
//if (curInteractionVO!!.id == interactionVO.id) {
|
|
- //callTimer.cancel()
|
|
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
updateCallText(getString(R.string.call_standby))
|
|
updateCallText(getString(R.string.call_standby))
|
|
//}
|
|
//}
|
|
|
|
|
|
//从呼叫列表移除
|
|
//从呼叫列表移除
|
|
- outCallList.remove(interactionVO.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
|
|
+ outCallList.remove(interactionVO.fromEthIp.toUpperCase(Locale.ROOT))
|
|
|
|
|
|
showMessage(R.string.call_busy)
|
|
showMessage(R.string.call_busy)
|
|
//关闭分机呼叫和门灯
|
|
//关闭分机呼叫和门灯
|
|
- SerialPortHelper.closeSoundChannel(interactionVO.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
- val doorAddr = getDoorLightAddr(interactionVO.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
|
|
+ SerialPortHelper.closeSoundChannel(interactionVO.fromEthIp.toUpperCase(Locale.ROOT))
|
|
|
|
+ val doorAddr = getDoorLightAddr(interactionVO.fromEthIp.toUpperCase(Locale.ROOT))
|
|
if (!TextUtils.isEmpty(doorAddr)) {
|
|
if (!TextUtils.isEmpty(doorAddr)) {
|
|
SerialPortHelper.closeDoorLight(doorAddr)
|
|
SerialPortHelper.closeDoorLight(doorAddr)
|
|
}
|
|
}
|
|
} else if (tcpModel.getAction() == TcpAction.VoiceAction.FAILED) {
|
|
} else if (tcpModel.getAction() == TcpAction.VoiceAction.FAILED) {
|
|
//我方呼出,对方不在线,设备离线或其它错误
|
|
//我方呼出,对方不在线,设备离线或其它错误
|
|
- //callTimer.cancel()
|
|
|
|
- val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
|
- Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
|
|
- updateCallText(getString(R.string.call_standby))
|
|
|
|
- showMessage(R.string.call_failed)
|
|
|
|
- //关闭分机呼叫和门灯
|
|
|
|
- SerialPortHelper.closeSoundChannel(interactionVO.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
- val doorAddr = getDoorLightAddr(interactionVO.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
- if (!TextUtils.isEmpty(doorAddr)) {
|
|
|
|
- SerialPortHelper.closeDoorLight(doorAddr)
|
|
|
|
|
|
+ if (tcpModel.data != null) {
|
|
|
|
+ val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
|
+ Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
|
|
+ updateCallText(getString(R.string.call_standby))
|
|
|
|
+ showMessage(R.string.call_failed)
|
|
|
|
+ //关闭分机呼叫和门灯
|
|
|
|
+ SerialPortHelper.closeSoundChannel(interactionVO.fromEthIp.toUpperCase(Locale.ROOT))
|
|
|
|
+ val doorAddr = getDoorLightAddr(interactionVO.fromEthIp.toUpperCase(Locale.ROOT))
|
|
|
|
+ if (!TextUtils.isEmpty(doorAddr)) {
|
|
|
|
+ SerialPortHelper.closeDoorLight(doorAddr)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else if (tcpModel.getAction() == TcpAction.VoiceAction.HANDOFF) {
|
|
} else if (tcpModel.getAction() == TcpAction.VoiceAction.HANDOFF) {
|
|
//对方挂断,不论我方呼出或呼入
|
|
//对方挂断,不论我方呼出或呼入
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
//从呼叫列表移除
|
|
//从呼叫列表移除
|
|
- outCallList.remove(interactionVO.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
|
|
+ outCallList.remove(interactionVO.fromEthIp.toUpperCase(Locale.ROOT))
|
|
|
|
|
|
//if (curInteractionVO!!.id == interactionVO.id) {
|
|
//if (curInteractionVO!!.id == interactionVO.id) {
|
|
- //callTimer.cancel()
|
|
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
updateCallText(getString(R.string.call_standby))
|
|
updateCallText(getString(R.string.call_standby))
|
|
showMessage(R.string.call_end)
|
|
showMessage(R.string.call_end)
|
|
//关闭分机呼叫和门灯
|
|
//关闭分机呼叫和门灯
|
|
if (interactionVO.fromDeviceType == DeviceTypeEnum.SIMULATE_BED_DEVICE.value()) {
|
|
if (interactionVO.fromDeviceType == DeviceTypeEnum.SIMULATE_BED_DEVICE.value()) {
|
|
- if (!TextUtils.isEmpty(interactionVO.fromEthMac)) {
|
|
|
|
- SerialPortHelper.closeSoundChannel(interactionVO.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
- val doorAddr = getDoorLightAddr(interactionVO.fromEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
|
|
+ if (!TextUtils.isEmpty(interactionVO.fromEthIp)) {
|
|
|
|
+ SerialPortHelper.closeSoundChannel(interactionVO.fromEthIp.toUpperCase(Locale.ROOT))
|
|
|
|
+ val doorAddr = getDoorLightAddr(interactionVO.fromEthIp.toUpperCase(Locale.ROOT))
|
|
if (!TextUtils.isEmpty(doorAddr)) {
|
|
if (!TextUtils.isEmpty(doorAddr)) {
|
|
SerialPortHelper.closeDoorLight(doorAddr)
|
|
SerialPortHelper.closeDoorLight(doorAddr)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- if (!TextUtils.isEmpty(interactionVO.toEthMac)) {
|
|
|
|
- SerialPortHelper.closeSoundChannel(interactionVO.toEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
- //val doorAddr = getDoorLightAddr(interactionVO.toEthMac)
|
|
|
|
|
|
+ if (!TextUtils.isEmpty(interactionVO.toEthIp)) {
|
|
|
|
+ SerialPortHelper.closeSoundChannel(interactionVO.toEthIp.toUpperCase(Locale.ROOT))
|
|
|
|
+ //val doorAddr = getDoorLightAddr(interactionVO.toEthIp)
|
|
//if (!TextUtils.isEmpty(doorAddr)) {
|
|
//if (!TextUtils.isEmpty(doorAddr)) {
|
|
// SerialPortHelper.closeDoorLight(doorAddr)
|
|
// SerialPortHelper.closeDoorLight(doorAddr)
|
|
//}
|
|
//}
|
|
@@ -1580,7 +1585,7 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
updateCallText(getString(R.string.call_standby))
|
|
updateCallText(getString(R.string.call_standby))
|
|
showMessage("Call cancel")
|
|
showMessage("Call cancel")
|
|
RingPlayHelper.stopRingTone()
|
|
RingPlayHelper.stopRingTone()
|
|
- SerialPortHelper.closeSoundChannel(interactionVO.toEthMac.toUpperCase(Locale.ROOT))
|
|
|
|
|
|
+ SerialPortHelper.closeSoundChannel(interactionVO.toEthIp.toUpperCase(Locale.ROOT))
|
|
//}
|
|
//}
|
|
}
|
|
}
|
|
//485分机操作
|
|
//485分机操作
|
|
@@ -1613,7 +1618,7 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
outCallList.remove(ethMac.toUpperCase(Locale.ROOT))
|
|
outCallList.remove(ethMac.toUpperCase(Locale.ROOT))
|
|
}
|
|
}
|
|
RingPlayHelper.stopRingTone()
|
|
RingPlayHelper.stopRingTone()
|
|
- VoiceUtil.acceptAudioCall(curDeviceId, fromId, curInteractionVO!!.id)
|
|
|
|
|
|
+ VoiceUtil.acceptAudioCall(tid, curDeviceId, fromId, curInteractionVO!!.id)
|
|
showCallFragment()
|
|
showCallFragment()
|
|
} else if (tcpModel.action == TcpAction.VoiceAction.RS485HANDOFF) {
|
|
} else if (tcpModel.action == TcpAction.VoiceAction.RS485HANDOFF) {
|
|
/*EventBus.getDefault().post(MessageEvent("handoff", Constant.EVENT_END_CALL))
|
|
/*EventBus.getDefault().post(MessageEvent("handoff", Constant.EVENT_END_CALL))
|
|
@@ -1652,7 +1657,7 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
val sosInteractionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
val sosInteractionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
if (tcpModel.action == TcpAction.SOSAction.CANCEL) {
|
|
if (tcpModel.action == TcpAction.SOSAction.CANCEL) {
|
|
//紧急呼叫已处理
|
|
//紧急呼叫已处理
|
|
- val addr = sosInteractionVO.fromEthMac.toUpperCase(Locale.ROOT)
|
|
|
|
|
|
+ val addr = sosInteractionVO.fromEthIp.toUpperCase(Locale.ROOT)
|
|
cancelSosCall(addr)
|
|
cancelSosCall(addr)
|
|
//删除sosList中对应item
|
|
//删除sosList中对应item
|
|
var iterator = sosList.iterator()
|
|
var iterator = sosList.iterator()
|
|
@@ -1827,7 +1832,7 @@ class MainActivity :BaseActivity<MainActivityPresenter, MainActivityLayoutBindin
|
|
|
|
|
|
fun handoffCall() {
|
|
fun handoffCall() {
|
|
EventBus.getDefault().post(MessageEvent("handoff", Constant.EVENT_END_CALL))
|
|
EventBus.getDefault().post(MessageEvent("handoff", Constant.EVENT_END_CALL))
|
|
- VoiceUtil.handoffAudioCall(curDeviceId, fromId, curInteractionVO!!.id)
|
|
|
|
|
|
+ VoiceUtil.handoffAudioCall(tid, curDeviceId, fromId, curInteractionVO!!.id)
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
}
|
|
}
|
|
|
|
|