实现一个闹钟覆盖心跳、拍照、采样

lowmem
Matthew 1 month ago
parent c6405cf287
commit e022748f71

@ -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;

@ -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) ");

Loading…
Cancel
Save