From e022748f71ca21d9dbd4c3ff886e9e2fb9ebe2ca Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 6 May 2025 18:36:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=B8=80=E4=B8=AA=E9=97=B9?= =?UTF-8?q?=E9=92=9F=E8=A6=86=E7=9B=96=E5=BF=83=E8=B7=B3=E3=80=81=E6=8B=8D?= =?UTF-8?q?=E7=85=A7=E3=80=81=E9=87=87=E6=A0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/MicroPhoto.cpp | 20 ++++++++----- .../com/xypower/mpapp/MicroPhotoService.java | 28 +++++++++++++++++-- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/app/src/main/cpp/MicroPhoto.cpp b/app/src/main/cpp/MicroPhoto.cpp index 60e24dce..62272f38 100644 --- a/app/src/main/cpp/MicroPhoto.cpp +++ b/app/src/main/cpp/MicroPhoto.cpp @@ -428,7 +428,18 @@ Java_com_xypower_mpapp_MicroPhotoService_notifyToTakePhoto( uint8_t type = (uint8_t)mediaType; // std::thread th(&Runner::RequestCapture, pTerminal, (unsigned int)channel, (unsigned int)preset, type, (uint64_t)scheduleTime, 0, true); // th.detach(); - if (channel < 0x100) + if (channel == 0x200) + { + // Heartbeat + + } + else if (channel >= 0x100) + { + uint32_t packetType = channel; + packetType &= 0xFF; + pTerminal->RequestSampling(packetType, (uint64_t)scheduleTime, 0); + } + else { if (mediaType == XY_MEDIA_TYPE_PHOTO || mediaType == XY_MEDIA_TYPE_VIDEO) { @@ -446,12 +457,7 @@ Java_com_xypower_mpapp_MicroPhotoService_notifyToTakePhoto( { pTerminal->StopStream(channel, preset, 0); } - } - else - { - uint32_t packetType = channel; - packetType &= 0xFF; - pTerminal->RequestSampling(packetType, (uint64_t)scheduleTime, 0); + } return JNI_TRUE; diff --git a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java index 58d939ca..990f00f2 100644 --- a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java +++ b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java @@ -527,7 +527,12 @@ public class MicroPhotoService extends Service { int preset = (int) ((val & 0xFF0L) >> 4); int mediaType = (int)(val & 0xFL); - if (channel >= 256) + if (channel == 0x200) + { + // Heartbeat + infoLog("HB Timer Fired"); + } + else if (channel >= 256) { infoLog("SERIAL Timer Fired: CH=" + (channel - 256) + " PR=" + preset); } @@ -536,6 +541,16 @@ public class MicroPhotoService extends Service { infoLog("IMG Timer Fired: CH=" + channel + " PR=" + preset); } mService.notifyToTakePhoto(mService.mNativeHandle, channel, preset, ts, null, mediaType); + + if (channel == 0x200) + { + // Try to turn off GPS + try { + mService.detectGpsStatus(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } } } @@ -734,6 +749,9 @@ public class MicroPhotoService extends Service { private void registerHeartbeatTimer(long timeoutMs) { + if (true) { + return; + } // 创建延迟意图 long triggerTime = System.currentTimeMillis() + timeoutMs; triggerTime -= (triggerTime % 1000); @@ -765,7 +783,13 @@ public class MicroPhotoService extends Service { val = schedules.get(idx).longValue(); channel = ((val & 0XFFFF000) >> 12); intent.putExtra(EXTRA_PARAM_SCHEDULE + idx, schedules.get(idx).longValue()); - if (channel > 0xFF) + if (channel == 0x200) + { + channelStr.append("(HB) "); + intent.putExtra("HeartbeatDuration", (int)((val & 0XFF0) >> 4) * 60000); + intent.putExtra("HeartbeatTime", scheduleTime * 1000); + } + else if (channel > 0xFF) { channel &= 0xFF; channelStr.append("(" + channel + "-" + Long.toString (((val & 0XFF0) >> 4), 16).toUpperCase() + "/SERIAL) ");