增加当前车辆当前位置上报功能,还有点儿小问题
This commit is contained in:
@@ -55,7 +55,7 @@ public class MoGoApplication extends MultiDexApplication {
|
||||
// TODO 这里使用的是测试的sn
|
||||
clientConfig.setThirdPartyDeviceId("test-sn-abcd-1234");
|
||||
// 设置应用服务AppId 长链、鉴权 //todo 需要卸载智慧驾驶、行车记录仪
|
||||
clientConfig.setServiceAppId("com.mogo.test");
|
||||
clientConfig.setServiceAppId("com.mogo.launcher");
|
||||
// 设置循环检测间隔时间
|
||||
clientConfig.setLoopCheckDelay(15 * 1000);
|
||||
// 设置是否属于高精定位设备
|
||||
|
||||
59
app/src/main/java/com/mogo/cloud/SPIRealTimeTestClass.java
Normal file
59
app/src/main/java/com/mogo/cloud/SPIRealTimeTestClass.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.mogo.cloud;
|
||||
|
||||
import com.elegant.spi.annotations.Service;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.realtime.api.IRealTimeProvider;
|
||||
import com.mogo.realtime.entity.DataCollectMsgDataProto;
|
||||
import com.mogo.realtime.entity.DataCollectWrapper;
|
||||
import com.mogo.realtime.entity.SocketReceiveDataProto3;
|
||||
import com.mogo.realtime.util.MortonCode;
|
||||
|
||||
import static com.mogo.cloud.socket.SocketMsgType.MSG_TYPE_UPLINK_CAR_DATA;
|
||||
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @since: 2021/1/26
|
||||
*/
|
||||
@Service(value = IRealTimeProvider.class)
|
||||
class SPIRealTimeTestClass implements IRealTimeProvider {
|
||||
|
||||
@Override
|
||||
public DataCollectWrapper.DataCollectMsg getLocationMsg() {
|
||||
|
||||
long mortonCode = MortonCode.encodeMorton(116.410871, 39.968309);
|
||||
|
||||
SocketReceiveDataProto3.LocationInfoProto locationInfoProto =
|
||||
SocketReceiveDataProto3.LocationInfoProto.newBuilder()
|
||||
.setLat(39.968309)
|
||||
.setLon(116.410871)
|
||||
.setHeading(120)
|
||||
.setSystemTime(System.currentTimeMillis())
|
||||
.setSatelliteTime(System.currentTimeMillis())
|
||||
.setAlt(55)
|
||||
.setDataAccuracy(1)
|
||||
.setSpeed(30)
|
||||
.setMortonCode(mortonCode)
|
||||
.setSn(MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.build();
|
||||
|
||||
SocketReceiveDataProto3.MyLocationReq myLocationReq = SocketReceiveDataProto3.MyLocationReq.newBuilder()
|
||||
.setLastCoordinate(locationInfoProto)
|
||||
.setDataAccuracy(1)
|
||||
.setMortonCode(mortonCode)
|
||||
.setFromType(1)
|
||||
.setSn(MoGoAiCloudClientConfig.getInstance().getSn())
|
||||
.build();
|
||||
|
||||
SocketReceiveDataProto3.OnePerSecondSendReqProto self = SocketReceiveDataProto3.OnePerSecondSendReqProto.newBuilder()
|
||||
.setSelf(myLocationReq).build();
|
||||
|
||||
DataCollectMsgDataProto.DataCollectMsgData msgData = DataCollectMsgDataProto.DataCollectMsgData.newBuilder()
|
||||
.setPayload(self.toByteString()).build();
|
||||
|
||||
return DataCollectWrapper.DataCollectMsg.newBuilder()
|
||||
.setData(msgData.toByteString())
|
||||
.setTimestamp(System.currentTimeMillis()).build();
|
||||
}
|
||||
}
|
||||
@@ -32,10 +32,10 @@ dependencies {
|
||||
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
implementation "com.mogo.cloud:network:${MOGO_NETWORK_VERSION}"
|
||||
implementation "com.mogo.cloud:socket:${MOGO_SOCKET_VERSION}"
|
||||
api "com.mogo.cloud:socket:${MOGO_SOCKET_VERSION}"
|
||||
} else {
|
||||
implementation project(":foudations:mogo-network")
|
||||
implementation project(":foudations:mogo-socket")
|
||||
api project(":foudations:mogo-socket")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.mogo.realtime.api;
|
||||
|
||||
|
||||
import com.mogo.realtime.entity.DataCollectWrapper;
|
||||
|
||||
/**
|
||||
* 蘑菇AI云平台实时定位点上报服务接口
|
||||
*/
|
||||
@@ -13,6 +16,6 @@ public interface IRealTimeProvider {
|
||||
/**
|
||||
* 发送消息,由外部传入ø
|
||||
*/
|
||||
// List<CloudLocationInfo> getLocationMsg(); // todo 数据实体替换成PB
|
||||
DataCollectWrapper.DataCollectMsg getLocationMsg(); // todo 数据实体替换成PB
|
||||
|
||||
}
|
||||
|
||||
@@ -3,4 +3,6 @@ package com.mogo.realtime.constant;
|
||||
public class RealTimeConstant {
|
||||
|
||||
public static final String TAG = "MoGoAiCloud_RealTime";
|
||||
public static final int HIGH_FREQUENCY_CHANNEL_ID = 0x040002; //高频数据
|
||||
public static final int LOW_FREQUENCY_CHANNEL_ID = 0x040003; //低频数据
|
||||
}
|
||||
|
||||
@@ -2,9 +2,13 @@ package com.mogo.realtime.core;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.cloud.socket.entity.MsgBody;
|
||||
import com.mogo.realtime.constant.RealTimeConstant;
|
||||
import com.mogo.realtime.entity.DataCollectWrapper;
|
||||
import com.mogo.realtime.socket.SocketHandler;
|
||||
import com.mogo.realtime.spi.RealTimeProviderImp;
|
||||
|
||||
|
||||
/**
|
||||
* 上报坐标服务
|
||||
*/
|
||||
@@ -53,6 +57,13 @@ public class SnapshotUploadInTime implements UploadInTimeHandler.IUploadInTimeLi
|
||||
|
||||
@Override
|
||||
public void sendLocationData() {
|
||||
// SocketHandler.getInstance().sendMsg(); // todo 构建数据传输对象
|
||||
DataCollectWrapper.DataCollectMsg dataCollectMsg =
|
||||
RealTimeProviderImp.getInstance().getLocationMsg();//SPI接口返回
|
||||
if (dataCollectMsg != null) {
|
||||
MsgBody msgBody = new MsgBody();
|
||||
msgBody.msgType(RealTimeConstant.HIGH_FREQUENCY_CHANNEL_ID);
|
||||
msgBody.content(dataCollectMsg.toByteArray());
|
||||
SocketHandler.getInstance().sendMsg(msgBody);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: A.proto
|
||||
|
||||
package com.mogo.cloud.socket.entity;
|
||||
package com.mogo.realtime.entity;
|
||||
|
||||
public final class DataCollectMsgDataProto {
|
||||
private DataCollectMsgDataProto() {}
|
||||
@@ -1,7 +1,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: DataCollectWrapper.proto
|
||||
|
||||
package com.mogo.cloud.socket.entity;
|
||||
package com.mogo.realtime.entity;
|
||||
|
||||
public final class DataCollectWrapper {
|
||||
private DataCollectWrapper() {}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,7 @@ import com.mogo.cloud.socket.SocketManager;
|
||||
import com.mogo.cloud.socket.entity.MsgBody;
|
||||
import com.mogo.cloud.socket.entity.SocketDownData;
|
||||
import com.mogo.cloud.utils.logger.Logger;
|
||||
import com.mogo.realtime.constant.RealTimeConstant;
|
||||
import com.zhidao.ptech.connsvr.protocol.MogoConnsvr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -22,8 +23,7 @@ public class SocketHandler {
|
||||
|
||||
private static volatile SocketHandler mInstance;
|
||||
private static final int HEADER_TYPE = MogoConnsvr.MsgType.mogoMsgTypeCollectSvrNoRspReq.getNumber();
|
||||
private static final int HIGH_FREQUENCY_CHANNEL_ID = 0x040002; //高频数据
|
||||
private static final int LOW_FREQUENCY_CHANNEL_ID = 0x040003; //低频数据
|
||||
|
||||
|
||||
private String mAppId;
|
||||
private final List<IMogoCloudOnMsgListener> onMsgListenerList = new ArrayList<>();
|
||||
@@ -48,8 +48,8 @@ public class SocketHandler {
|
||||
public void initSocket(Context context, String appId) {
|
||||
mAppId = appId;
|
||||
SocketManager.getInstance().init(context);
|
||||
SocketManager.getInstance().registerOnMessageListener(HIGH_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
SocketManager.getInstance().registerOnMessageListener(LOW_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
SocketManager.getInstance().registerOnMessageListener(RealTimeConstant.HIGH_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
SocketManager.getInstance().registerOnMessageListener(RealTimeConstant.LOW_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
}
|
||||
|
||||
public void registerOnMsgListener(IMogoCloudOnMsgListener onMsgListener) {
|
||||
@@ -102,8 +102,8 @@ public class SocketHandler {
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
SocketManager.getInstance().unregisterOnMessageListener(HIGH_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
SocketManager.getInstance().unregisterOnMessageListener(LOW_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
SocketManager.getInstance().unregisterOnMessageListener(RealTimeConstant.HIGH_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
SocketManager.getInstance().unregisterOnMessageListener(RealTimeConstant.LOW_FREQUENCY_CHANNEL_ID, onMessageListener);
|
||||
SocketManager.getInstance().release();
|
||||
onMsgListenerList.clear();
|
||||
mInstance = null;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.realtime.spi;
|
||||
|
||||
import com.mogo.realtime.api.IRealTimeProvider;
|
||||
import com.mogo.realtime.entity.DataCollectWrapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -27,20 +28,12 @@ public class RealTimeProviderImp implements IRealTimeProvider {
|
||||
mDelegate = RealTimeProviderDelegateManager.getInstance().getRealTimeProvider();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List<ADASRecognizedResult> getLastADASRecognizedResult() { // todo 数据实体替换成PB
|
||||
// if (mDelegate != null) {
|
||||
// return mDelegate.getLastADASRecognizedResult();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<CloudLocationInfo> getLocationMsg() { // todo 数据实体替换成PB
|
||||
// if (mDelegate != null) {
|
||||
// mDelegate.getLocationMsg();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
@Override
|
||||
public DataCollectWrapper.DataCollectMsg getLocationMsg() {
|
||||
if (mDelegate != null) {
|
||||
return mDelegate.getLocationMsg();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user