From 10e4ece2f9c58fffc4ab9c3c2c5be95941005888 Mon Sep 17 00:00:00 2001 From: endian11 <Dana_Lee1016@126.com> Date: 星期一, 06 一月 2020 11:36:11 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/endian11/DriveJudge --- app/src/main/java/safeluck/drive/evaluation/app.java | 2 - lib/src/main/cpp/rtk_platform/parse_net.cpp | 6 +-- lib/src/main/cpp/rtk_platform/platform.h | 1 lib/src/main/cpp/native-lib.cpp | 2 lib/src/main/cpp/rtk_module/rtk.cpp | 4 +- .idea/misc.xml | 2 lib/build.gradle | 2 lib/src/main/cpp/rtk_platform/platform.cpp | 24 +++++++++++- lib/src/main/java/com/anyun/exam/lib/RemoteService.java | 20 +++++++-- 9 files changed, 45 insertions(+), 18 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 37a7509..dfd2c79 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="JDK" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/build/classes" /> </component> <component name="ProjectType"> diff --git a/app/src/main/java/safeluck/drive/evaluation/app.java b/app/src/main/java/safeluck/drive/evaluation/app.java index 6d194ad..90930b5 100644 --- a/app/src/main/java/safeluck/drive/evaluation/app.java +++ b/app/src/main/java/safeluck/drive/evaluation/app.java @@ -32,8 +32,6 @@ public void onCreate() { super.onCreate(); //鍒濆鍖朏ragment 寤鸿鍦ˋpplication onCreate閲岄潰鍒濆鍖� - - if (SystemUtil.compareProcessName(this)){ Fragmentation.builder().stackViewMode(Fragmentation.BUBBLE).debug(false) .handleException(new ExceptionHandler() { diff --git a/lib/build.gradle b/lib/build.gradle index fb084b3..cdc5d5b 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -20,7 +20,7 @@ ndk { // Specifies the ABI configurations of your native // libraries Gradle should build and package with your APK. - abiFilters 'armeabi-v7a','arm64-v8a' + abiFilters 'armeabi-v7a' } } diff --git a/lib/src/main/cpp/native-lib.cpp b/lib/src/main/cpp/native-lib.cpp index b910b1b..db4f1e8 100644 --- a/lib/src/main/cpp/native-lib.cpp +++ b/lib/src/main/cpp/native-lib.cpp @@ -19,7 +19,7 @@ const char *RTK_PLATFORM_IP = "47.93.80.84"; const int RTK_PLATFORM_PORT = 12125; -const uint8_t phone[] = {0x20,0x19,0x10,0x15,0x00,0x00,0x00,0x02}; +const uint8_t phone[] = {0x20,0x19,0x10,0x15,0x00,0x00,0x00,0x01}; #define IMEI_LENGTH 15 diff --git a/lib/src/main/cpp/rtk_module/rtk.cpp b/lib/src/main/cpp/rtk_module/rtk.cpp index 28d7bf8..dcf3cb0 100644 --- a/lib/src/main/cpp/rtk_module/rtk.cpp +++ b/lib/src/main/cpp/rtk_module/rtk.cpp @@ -294,8 +294,8 @@ gpsStatus.bcd_time[1] = ((MM/10)<<4) + (MM%10); gpsStatus.bcd_time[2] = ((DD/10)<<4) + (DD%10); gpsStatus.bcd_time[3] = ((hh/10)<<4) + (hh%10); - gpsStatus.bcd_time[4] = ((ss/10)<<4) + (ss%10); - gpsStatus.bcd_time[5] = ((mm/10)<<4) + (mm%10); + gpsStatus.bcd_time[4] = ((mm/10)<<4) + (mm%10); + gpsStatus.bcd_time[5] = ((ss/10)<<4) + (ss%10); recved_gprmc_time = AppTimer_GetTickCount(); diff --git a/lib/src/main/cpp/rtk_platform/parse_net.cpp b/lib/src/main/cpp/rtk_platform/parse_net.cpp index 4925d8e..8ab1330 100644 --- a/lib/src/main/cpp/rtk_platform/parse_net.cpp +++ b/lib/src/main/cpp/rtk_platform/parse_net.cpp @@ -369,10 +369,7 @@ } case ID_PC_RTK_DOWNLOAD: DEBUG("ID_PC_RTK_DOWNLOAD"); - // 姹囨姤缁欏崟鐗囨満 - if (length > 0) { - SendRtkToMcu(data, length); - } + ReceivedRtk(data, length); break; default: break; @@ -936,6 +933,7 @@ uint8_t data[MAX_CONTENT_SIZE]; int x = 0; + data[x++] = 0; data[x++] = gps_status; data[x++] = BREAK_UINT32(latitude, 3); data[x++] = BREAK_UINT32(latitude, 2); diff --git a/lib/src/main/cpp/rtk_platform/platform.cpp b/lib/src/main/cpp/rtk_platform/platform.cpp index 99751dd..f1f0358 100644 --- a/lib/src/main/cpp/rtk_platform/platform.cpp +++ b/lib/src/main/cpp/rtk_platform/platform.cpp @@ -15,6 +15,7 @@ #include "parse_net.h" #include "../defs.h" #include "../rtk_module/rtk.h" +#include "../mcu/mcu_if.h" #define PARSE_BUFF_SIZE 4096 @@ -69,6 +70,7 @@ static void LoginPlatform(void); static void LoginPlatformTimeout(union sigval sig); static void TriggerHeartbeat(union sigval sig); +static void RequestRtkNoResp(union sigval sig); void InitPlatform(const uint8_t *phone, const char *domain_name, int port) { @@ -96,8 +98,6 @@ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);//detached pthread_create(&pid, &attr, StatusListenThread, NULL); - - strcpy(deviceInfo.imei, GetImei()); ConnectPlatform(domain_name, port); } @@ -346,11 +346,31 @@ } } +void ReceivedRtk(const uint8_t *data, int length) +{ + AppTimer_delete(RequestRtkNoResp); + // 姹囨姤缁欏崟鐗囨満 + if (length > 0) { + SendRtkToMcu(data, length); + } +} + +static void RequestRtkNoResp(union sigval sig) +{ + AppTimer_delete(RequestRtkNoResp); + requestPlatformSendRtk = true; +} + void RequestRtkDownload(uint32_t latitude, uint32_t longitude, uint16_t altitude, const uint8_t *bcd_time, uint16_t rtk_pkt_interval) { if (requestPlatformSendRtk) { + DisplayText("璇锋眰涓嬭浇RTK鏁版嵁"); requestPlatformSendRtk = false; + + AppTimer_delete(RequestRtkNoResp); + AppTimer_add(RequestRtkNoResp, D_SEC(5)); + SendRTKStart(latitude, longitude, altitude, bcd_time, rtk_pkt_interval); } } diff --git a/lib/src/main/cpp/rtk_platform/platform.h b/lib/src/main/cpp/rtk_platform/platform.h index 03e0ca6..84e70cf 100644 --- a/lib/src/main/cpp/rtk_platform/platform.h +++ b/lib/src/main/cpp/rtk_platform/platform.h @@ -17,6 +17,7 @@ int WritePlatform(const uint8_t * buf, uint32_t len); void DeviceRegisterCallback(uint8_t res, const uint8_t *data, int length); void DeviceLoginCallback(uint8_t res); +void ReceivedRtk(const uint8_t *data, int length); void RequestRtkDownload(uint32_t latitude, uint32_t longitude, uint16_t altitude, const uint8_t *bcd_time, uint16_t rtk_pkt_interval); diff --git a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java index af461da..90bab00 100644 --- a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java +++ b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java @@ -11,6 +11,7 @@ import com.anyun.exam.lib.util.DESUtil; import com.anyun.exam.lib.util.NetUtils; +import com.anyun.exam.lib.util.Speaker; import androidx.annotation.Nullable; @@ -30,6 +31,8 @@ private RemoteCallbackList<IListenerInterface> mListenerList = new RemoteCallbackList(); private IListenerInterface mListener; private int msgId = 0; + private Speaker speaker = null; + private IRemoteInterface.Stub iRemoteInterface = new IRemoteInterface.Stub(){ @Override public void registListener(IListenerInterface i) throws RemoteException { @@ -59,6 +62,8 @@ public void onCreate() { super.onCreate(); Log.i(TAG,"onCreate()"); + speaker = new Speaker(getApplicationContext()); + startNative(); new Thread(new Worker()).start(); } @@ -69,7 +74,7 @@ public void run() { while (!mIsServiceDestroyed.get()){ try { - Thread.sleep(4*1000); + Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } @@ -88,8 +93,12 @@ private void onMessageArrived(String json){ int N = mListenerList.getRegisteredCallbackCount(); + + Log.d(TAG, "getRegisteredCallbackCount = " + N); + mListenerList.beginBroadcast(); + for (int i = 0; i < N; i++) { - mListenerList.beginBroadcast(); + mListener = mListenerList.getBroadcastItem(i); if (mListener != null){ try { @@ -98,8 +107,9 @@ e.printStackTrace(); } } - mListenerList.finishBroadcast(); + } + mListenerList.finishBroadcast(); } public String javaGetImei() { @@ -163,9 +173,9 @@ } public void TextSpeak(String text) { -/* if (speaker != null) { + if (speaker != null) { speaker.speak(text); - }*/ + } } // Used to load the 'native-lib' library on application startup. -- Gitblit v1.8.0