Updates to sms
This commit is contained in:
@@ -9,10 +9,12 @@ class SmsDeviceMonitorService {
|
||||
start() {
|
||||
if (this.interval) return;
|
||||
|
||||
// Initial check
|
||||
this.check().catch((err) => {
|
||||
logger.warn('Initial SMS device check failed:', err instanceof Error ? err.message : err);
|
||||
});
|
||||
// Delay initial check by 15s to stagger with response sync (avoids concurrent Termux API calls)
|
||||
setTimeout(() => {
|
||||
this.check().catch((err) => {
|
||||
logger.warn('Initial SMS device check failed:', err instanceof Error ? err.message : err);
|
||||
});
|
||||
}, 15_000);
|
||||
|
||||
this.interval = setInterval(() => {
|
||||
this.check().catch((err) => {
|
||||
@@ -20,7 +22,7 @@ class SmsDeviceMonitorService {
|
||||
});
|
||||
}, env.SMS_DEVICE_MONITOR_INTERVAL_MS);
|
||||
|
||||
logger.info(`SMS device monitor started (interval: ${env.SMS_DEVICE_MONITOR_INTERVAL_MS}ms)`);
|
||||
logger.info(`SMS device monitor started (interval: ${env.SMS_DEVICE_MONITOR_INTERVAL_MS}ms, initial delay: 15s)`);
|
||||
}
|
||||
|
||||
stop() {
|
||||
|
||||
@@ -222,7 +222,11 @@ class TermuxClient {
|
||||
if (!this.enabled) return null;
|
||||
|
||||
try {
|
||||
return await this.request<TermuxBatteryStatus>('GET', '/api/device/battery');
|
||||
// Flask endpoint returns { battery: { percentage, status, ... }, success: true }
|
||||
const data = await this.request<{ battery?: TermuxBatteryStatus } & Partial<TermuxBatteryStatus>>(
|
||||
'GET', '/api/device/battery',
|
||||
);
|
||||
return data.battery || data as unknown as TermuxBatteryStatus;
|
||||
} catch (err) {
|
||||
logger.warn('Termux getBattery failed:', err instanceof Error ? err.message : err);
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user