|
|
|
@ -10,6 +10,7 @@ import com.yinuo.safetywatcher.watcher.bean.GetRtspUrlResponse
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.bean.LastTimeResponse
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.bean.TrafficReqInfo
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.LztekUtil
|
|
|
|
|
import com.yinuo.safetywatcher.watcher.utils.SimHelper
|
|
|
|
|
import io.reactivex.rxjava3.core.Observable
|
|
|
|
|
import retrofit2.http.Body
|
|
|
|
|
import retrofit2.http.GET
|
|
|
|
@ -23,50 +24,62 @@ import retrofit2.http.Query
|
|
|
|
|
class DevicesApi : BaseObserve<DevicesApi.Api>(Api::class.java) {
|
|
|
|
|
|
|
|
|
|
fun heartBeat(sn: String) {
|
|
|
|
|
observe(api.heartBeat(sn), object : RequestNoResultCallBack<BaseResponse>() {
|
|
|
|
|
override fun onError(error: String?) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onComplete() {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (SimHelper.isNetOk()) {
|
|
|
|
|
observe(api.heartBeat(sn), object : RequestNoResultCallBack<BaseResponse>() {
|
|
|
|
|
override fun onError(error: String?) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onComplete() {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun getPushUrl(sn: String, callBack: RequestResultCallBack<GetRtspUrlResponse>) {
|
|
|
|
|
observe(api.getPushUrl(sn), callBack)
|
|
|
|
|
if (SimHelper.isNetOk()) {
|
|
|
|
|
observe(api.getPushUrl(sn), callBack)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun updateTrafficInfo() {
|
|
|
|
|
val trafficReqInfo = TrafficReqInfo()
|
|
|
|
|
observe(api.updateTrafficInfo(trafficReqInfo), null)
|
|
|
|
|
if (SimHelper.isNetOk()) {
|
|
|
|
|
val trafficReqInfo = TrafficReqInfo()
|
|
|
|
|
observe(api.updateTrafficInfo(trafficReqInfo), null)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
suspend fun uploadGasData(
|
|
|
|
|
gasList: List<GasReqBean> = emptyList()
|
|
|
|
|
): BaseResponse? {
|
|
|
|
|
try {
|
|
|
|
|
val gasReq = GasRequest(detections = gasList)
|
|
|
|
|
return api.uploadGasData(gasReq)
|
|
|
|
|
} catch (e: Exception) {
|
|
|
|
|
e.printStackTrace()
|
|
|
|
|
if (SimHelper.isNetOk()) {
|
|
|
|
|
try {
|
|
|
|
|
val gasReq = GasRequest(detections = gasList)
|
|
|
|
|
return api.uploadGasData(gasReq)
|
|
|
|
|
} catch (e: Exception) {
|
|
|
|
|
e.printStackTrace()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
suspend fun getDetectionLastTime(): LastTimeResponse? {
|
|
|
|
|
try {
|
|
|
|
|
return api.getDetectionLastTime(LztekUtil.getSn())
|
|
|
|
|
} catch (e: Exception) {
|
|
|
|
|
e.printStackTrace()
|
|
|
|
|
if (SimHelper.isNetOk()) {
|
|
|
|
|
try {
|
|
|
|
|
return api.getDetectionLastTime(LztekUtil.getSn())
|
|
|
|
|
} catch (e: Exception) {
|
|
|
|
|
e.printStackTrace()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
suspend fun getVideoLastTime(): LastTimeResponse? {
|
|
|
|
|
try {
|
|
|
|
|
return api.getVideoLastTime(LztekUtil.getSn())
|
|
|
|
|
} catch (e: Exception) {
|
|
|
|
|
e.printStackTrace()
|
|
|
|
|
if (SimHelper.isNetOk()) {
|
|
|
|
|
try {
|
|
|
|
|
return api.getVideoLastTime(LztekUtil.getSn())
|
|
|
|
|
} catch (e: Exception) {
|
|
|
|
|
e.printStackTrace()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|