battery: send alerts on channel "testowy" (index 2), not the pinned send channel
CI / build + unit (pull_request) Successful in 1m0s

Owner request. BatteryAlertService reads new env BATTERY_ALERT_CHANNEL
(default 2) at construction and passes it through MeshService.sendText,
which gains an optional trailing channel argument defaulting to the
pinned MESH_SEND_CHANNEL — every other sender is untouched. Threshold,
cooldown, merged one-message-per-cycle format and @mentions unchanged.
This commit is contained in:
2026-09-25 13:02:56 +00:00
parent 6f6b704dcf
commit 1b712f7eee
5 changed files with 60 additions and 17 deletions
+10 -9
View File
@@ -490,22 +490,23 @@ export class MeshService implements OnModuleInit, OnModuleDestroy {
return [...this.telemetryHistory].reverse();
}
/** Send `text` to node `to` on the pinned test channel; returns the packet id. Optional `replyId` marks the message as a reply to an earlier packet (the recipient app renders it as a threaded quote). Throws ServiceUnavailable when the bridge is down. */
async sendText(to: number, text: string, replyId?: number): Promise<number> {
/** Send `text` to node `to`; returns the packet id. Rides the pinned test channel unless an explicit `channel` index is given (e.g. battery alerts on "testowy"). Optional `replyId` marks the message as a reply to an earlier packet (the recipient app renders it as a threaded quote). Throws ServiceUnavailable when the bridge is down. */
async sendText(
to: number,
text: string,
replyId?: number,
channel?: number,
): Promise<number> {
if (!this.connected || !this.socket)
throw new ServiceUnavailableException('bridge not connected');
const { bytes, id } = await buildTextToRadio(
to,
text,
this.sendChannel,
replyId,
);
const ch = channel ?? this.sendChannel;
const { bytes, id } = await buildTextToRadio(to, text, ch, replyId);
const rec: MessageRecord = {
id,
dir: 'tx',
to,
text,
channel: this.sendChannel,
channel: ch,
at: Date.now(),
status: 'pending',
};