|
@@ -68,6 +68,7 @@ import org.greenrobot.eventbus.EventBus
|
|
|
import org.greenrobot.eventbus.Subscribe
|
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
|
import org.linphone.core.AccountCreator
|
|
|
+import org.linphone.core.Factory
|
|
|
import org.linphone.core.RegistrationState
|
|
|
import org.linphone.core.TransportType
|
|
|
import serialporttest.utils.SerialPortUtil
|
|
@@ -160,6 +161,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
|
|
|
//获取mac地址
|
|
|
Constant.LOCAL_MAC = NetHelper.getInstance().macAddress
|
|
|
+ Constant.LOCAL_IP = NetHelper.getInstance().localIP
|
|
|
|
|
|
//注册广播
|
|
|
regReceiver()
|
|
@@ -547,7 +549,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
|
|
|
//配置sip账户
|
|
|
if (WdklSipService.getCore() != null) {
|
|
|
- mAccountCreator = WdklSipService.getCore().createAccountCreator(null)
|
|
|
+ /*mAccountCreator = WdklSipService.getCore().createAccountCreator(null)
|
|
|
WdklSipService.getCore().clearAllAuthInfo()
|
|
|
WdklSipService.getCore().clearProxyConfig()
|
|
|
// 以下三项必须
|
|
@@ -561,10 +563,29 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
|
|
|
// 这里会自动创建代理配置、认证信息到 SIP核心
|
|
|
val cfg = mAccountCreator!!.createProxyConfig()
|
|
|
- cfg.expires = 12000
|
|
|
- Log.e(TAG, "sip login time: " + cfg.expires)
|
|
|
+ cfg.expires = 300
|
|
|
// 确保新创建的是最新
|
|
|
WdklSipService.getCore().defaultProxyConfig = cfg
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+ WdklSipService.getCore().clearAllAuthInfo()
|
|
|
+ WdklSipService.getCore().clearProxyConfig()
|
|
|
+ //无服务器时端口必须,固定5060,否则拨打IP时,也需加上端口号。如:sip:192.168.1.100:6666
|
|
|
+ val transports = Factory.instance().createTransports()
|
|
|
+ transports.setUdpPort(5060)
|
|
|
+ transports.setTcpPort(5060)
|
|
|
+ WdklSipService.getCore().setTransports(transports)
|
|
|
+
|
|
|
+ if (!TextUtils.isEmpty(Constant.SIP_ID) && !TextUtils.isEmpty(Constant.LOCAL_IP)) {
|
|
|
+ val accountCreator = WdklSipService.getCore().createAccountCreator(null)
|
|
|
+ accountCreator.setUsername(Constant.SIP_ID)
|
|
|
+ accountCreator.setDomain(Constant.LOCAL_IP)
|
|
|
+ accountCreator.setTransport(TransportType.Udp)
|
|
|
+ val cfg = accountCreator.createProxyConfig()
|
|
|
+ WdklSipService.getCore().setDefaultProxyConfig(cfg)
|
|
|
+ } else {
|
|
|
+ showMessage("没有IP地址或没有SIP ID")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1096,11 +1117,11 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
updateStatus(status)
|
|
|
}*/
|
|
|
|
|
|
- if (messageEvent.message is RegistrationState) {
|
|
|
+ /*if (messageEvent.message is RegistrationState) {
|
|
|
val state = messageEvent.message as RegistrationState
|
|
|
Log.d("callingbed", "sip register state: $state")
|
|
|
updateSipState(state)
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
|
|
|
//网络ping状态
|
|
@@ -1303,7 +1324,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
*/
|
|
|
if (Build.MODEL.equals("rk3128") || "WDFJ-I".equals(Build.MODEL)) {
|
|
|
var count = SettingConfig.getNetErrResetCount(this)
|
|
|
- if (!Constant.TCP_CONNECTED && TextUtils.isEmpty(NetHelper.getInstance().localIP)) {
|
|
|
+ if (!Constant.TCP_CONNECTED && TextUtils.isEmpty(Constant.LOCAL_IP)) {
|
|
|
netErrCount++
|
|
|
Log.e(TAG, "network error!!! ==> netErrCount: $netErrCount, count: $count")
|
|
|
} else {
|
|
@@ -1341,10 +1362,10 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, CallingbedMa
|
|
|
private fun updateTcpState() {
|
|
|
if (Constant.TCP_CONNECTED) {
|
|
|
view_title_layout_iv_tcp.setImageResource(R.mipmap.ic_tcp_success)
|
|
|
- //view_title_layout_tv_point.setBackgroundResource(R.color.green)
|
|
|
+ view_title_layout_tv_point.setBackgroundResource(R.color.green)
|
|
|
} else {
|
|
|
view_title_layout_iv_tcp.setImageResource(R.mipmap.ic_tcp_fail)
|
|
|
- //view_title_layout_tv_point.setBackgroundResource(R.color.red_color)
|
|
|
+ view_title_layout_tv_point.setBackgroundResource(R.color.red_color)
|
|
|
}
|
|
|
}
|
|
|
|