Updates to sms

This commit is contained in:
2026-02-27 08:36:21 -07:00
parent 9e51aac570
commit 621042806a
7 changed files with 619 additions and 62 deletions

View File

@@ -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() {

View File

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