desc:SOS状态上报给服务器

main
xiaowusky 1 year ago
parent e4916e2f77
commit 2860630d26

@ -24,9 +24,11 @@ import com.loper7.date_time_picker.number_picker.NumberPicker
import com.yinuo.safetywatcher.R
import com.yinuo.safetywatcher.databinding.ActivityBaseBinding
import com.yinuo.safetywatcher.watcher.constant.NAMESPACE_ANDROID
import com.yinuo.safetywatcher.watcher.net.DevicesApi
import com.yinuo.safetywatcher.watcher.ui.view.CommonDialog
import com.yinuo.safetywatcher.watcher.ui.view.CommonTopBar
import com.yinuo.safetywatcher.watcher.utils.GPIOUtils
import com.yinuo.safetywatcher.watcher.utils.LztekUtil
import com.yinuo.safetywatcher.watcher.utils.PlatformUtils
import com.yinuo.safetywatcher.watcher.utils.RecordHelper
import com.yinuo.safetywatcher.watcher.utils.SoundUtils
@ -51,6 +53,8 @@ abstract class BaseActivity : AppCompatActivity() {
var lastFocusView: View? = null
var lastDialogCancelable = false
override fun onCreate(savedInstanceState: Bundle?) {
setViewFactory()
super.onCreate(null)
@ -139,6 +143,7 @@ abstract class BaseActivity : AppCompatActivity() {
loadingDialog = CommonDialog(resId)
loadingDialog!!.isCancelable = cancelable
loadingDialog!!.show(supportFragmentManager, "loading")
lastDialogCancelable = cancelable
}
}
@ -151,6 +156,7 @@ abstract class BaseActivity : AppCompatActivity() {
lifecycleScope.launchWhenResumed {
loadingDialog?.dismiss()
loadingDialog = null
lastDialogCancelable = false
}
}
@ -232,6 +238,9 @@ abstract class BaseActivity : AppCompatActivity() {
var isLeftRightLongPress = false
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
// LogUtils.w("cyy dispatchKeyEvent keyCode = ${event?.keyCode} count = ${event?.repeatCount} acton = ${event?.action}")
if (lastDialogCancelable){
closeLoadingDialog()
}
val action = event.action
if (KeyEvent.ACTION_DOWN == action) {
return dealActionDown(event)
@ -291,7 +300,19 @@ abstract class BaseActivity : AppCompatActivity() {
return super.dispatchKeyEvent(event)
}
private val devicesApi by lazy {
DevicesApi()
}
open fun onSosHelp(sos: Boolean = true) {
// 不重复上报true状态
if (sos && LztekUtil.isSosing()){
return
}
LztekUtil.setSosStatus(sos)
GlobalScope.launch(Dispatchers.IO) {
devicesApi.sendSosAlarm()
}
}
fun showVoiceArea() {

@ -0,0 +1,3 @@
package com.yinuo.safetywatcher.watcher.bean
data class SosSnReq(val deviceSn:String = "", val sosStatus:Int = 1)

@ -8,6 +8,7 @@ import com.yinuo.safetywatcher.watcher.bean.GasReqBean
import com.yinuo.safetywatcher.watcher.bean.GasRequest
import com.yinuo.safetywatcher.watcher.bean.GetRtspUrlResponse
import com.yinuo.safetywatcher.watcher.bean.LastTimeResponse
import com.yinuo.safetywatcher.watcher.bean.SosSnReq
import com.yinuo.safetywatcher.watcher.bean.TrafficReqInfo
import com.yinuo.safetywatcher.watcher.utils.LztekUtil
import com.yinuo.safetywatcher.watcher.utils.SimHelper
@ -24,7 +25,10 @@ import retrofit2.http.Query
class DevicesApi : BaseObserve<DevicesApi.Api>(Api::class.java) {
fun heartBeat(sn: String) {
observe(api.heartBeat(sn), object : RequestNoResultCallBack<BaseResponse>() {
// 1sos关闭 2sos打开
val sosStatus = if (LztekUtil.isSosing()) 2 else 1
val sosReq = SosSnReq(sn, sosStatus)
observe(api.heartBeat(sosReq), object : RequestNoResultCallBack<BaseResponse>() {
override fun onResult(result: BaseResponse) {
super.onResult(result)
SimHelper.setNetStatus(true)
@ -90,11 +94,19 @@ class DevicesApi : BaseObserve<DevicesApi.Api>(Api::class.java) {
return null
}
fun sendSosAlarm() {
if (SimHelper.isNetOk()) {
// 1sos关闭 2sos打开
val sosStatus = if (LztekUtil.isSosing()) 2 else 1
val sosReq = SosSnReq(LztekUtil.getSn(), sosStatus)
observe(api.sendSosAlarm(sosReq), null)
}
}
interface Api {
@Headers("baseurl:host")
@GET("/api/device/refresh")
fun heartBeat(@Query("deviceSn") sn: String): Observable<BaseResponse>
@POST("/api/device/refresh")
fun heartBeat(@Body body: SosSnReq): Observable<BaseResponse>
@Headers("baseurl:host")
@GET("/api/device/getRtspUrl")
@ -115,5 +127,9 @@ class DevicesApi : BaseObserve<DevicesApi.Api>(Api::class.java) {
@Headers("baseurl:host")
@GET("/api/device/getVideoLastTime")
suspend fun getVideoLastTime(@Query("deviceSn") sn: String): LastTimeResponse
@Headers("baseurl:host")
@POST("/api/device/sendSosAlarm")
fun sendSosAlarm(@Body body: SosSnReq): Observable<BaseResponse>
}
}

@ -117,9 +117,13 @@ object ParseHelper {
c18.plus(c17).plus(java.lang.Long.toBinaryString(valueHexLong)).toInt(2) / 10f.pow(
pointNum
)
// 初始化的前20s钟浓度强制设置成0避免开机就显示浓度满量程
if (!GasPortUtils.isInitOver20Second()) {
// 氧气特殊处理氧气为0会报警氧气不置0
if (type != GasTypeEnum.TYPE_O2){
value = 0f
}
}
// 量程
val rangHex: String = HexUtils.byteArrToHex(it, 25, 25 + 4)
val rangHexLong: Long = HexUtils.hexToLong(rangHex)

@ -313,18 +313,14 @@ class HomeActivity : NoOptionsActivity() {
Process.killProcess(Process.myPid())
}
private var sosShow = false
override fun onSosHelp(sos: Boolean) {
super.onSosHelp(sos)
if (sosShow == sos) {
return
}
if (sos && !sosShow) {
sosShow = true
if (sos) {
if (mBinding.tvSos.visibility == View.GONE) {
mBinding.tvSos.visibility = View.VISIBLE
}
} else {
if (sosShow) {
sosShow = false
if (mBinding.tvSos.visibility == View.VISIBLE) {
mBinding.tvSos.visibility = View.GONE
}
}

@ -21,6 +21,16 @@ object LztekUtil {
private var rtspUrl: String? = ""
private var sosing = false
fun setSosStatus(status: Boolean) {
sosing = status
}
fun isSosing(): Boolean {
return sosing
}
fun setObject(value: Lztek) {
mLztek = value
mLztek?.hideNavigationBar()

Loading…
Cancel
Save