Send want_config_id on connect to trigger initial sync (#6)
CI / build + unit (push) Successful in 39s

Send want_config_id on connect to trigger initial sync (#6)

Firmware only streams myInfo/channels/configComplete after receiving a
ToRadio with want_config_id — the service previously wrote nothing on
connect, so /api/channels stayed [] and myNodeNum null. v0.1.4.
This commit was merged in pull request #6.
This commit is contained in:
2026-09-23 22:42:03 +02:00
parent 3062f40899
commit adfbc9800b
6 changed files with 97 additions and 10 deletions
+9
View File
@@ -9,8 +9,10 @@ import * as net from 'node:net';
import {
PORT_TEXT_MESSAGE_APP,
buildTextToRadio,
buildWantConfigToRadio,
decodeFromRadio,
extractFrames,
frame,
} from './codec.js';
@Injectable()
@@ -94,6 +96,13 @@ export class MeshService implements OnModuleInit, OnModuleDestroy {
// fresh sync on every (re)connect — drop stale channels from the old session
this.channelMap = new Map();
this.logger.log(`bridge connected ${this.host}:${this.port}`);
const nonce = Math.floor(Math.random() * 0xffffffff) || 1;
buildWantConfigToRadio(nonce)
.then((bytes) => socket.write(frame(bytes)))
.catch((err: unknown) =>
this.logger.error(`want_config failed: ${String(err)}`),
);
this.logger.log(`requested initial sync (want_config_id=${nonce})`);
});
socket.on('data', (chunk) => {
const merged = new Uint8Array(this.buffer.length + chunk.length);