Publish on 'test' channel (index 3) by default (#10)
CI / build + unit (push) Successful in 34s
CI / build + unit (push) Successful in 34s
This commit was merged in pull request #10.
This commit is contained in:
@@ -57,7 +57,7 @@ export class MeshController {
|
||||
@ApiOperation({
|
||||
summary: 'Send a text message over the mesh',
|
||||
description:
|
||||
'Queues a TEXT_MESSAGE_APP packet to the resolved target (node number, node name, or broadcast). DMs are unicast and wantAck-tracked via GET /api/messages; broadcasts stay pending because firmware strips want_ack. All sends ride the pinned test channel (index 2, "testowy" — never the primary channel) regardless of DM or broadcast, since modern firmware PKI handles unicast encryption/channel anyway. Returns the Meshtastic packet id.',
|
||||
'Queues a TEXT_MESSAGE_APP packet to the resolved target (node number, node name, or broadcast). DMs are unicast and wantAck-tracked via GET /api/messages; broadcasts stay pending because firmware strips want_ack. All sends ride the pinned test channel (index 3, "test" — never the primary channel) regardless of DM or broadcast, since modern firmware PKI handles unicast encryption/channel anyway. Returns the Meshtastic packet id.',
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
@@ -93,8 +93,8 @@ export class MeshController {
|
||||
example: [
|
||||
{ index: 0, name: 'Default', uplinkEnabled: true, downlinkEnabled: true },
|
||||
{
|
||||
index: 2,
|
||||
name: 'testowy',
|
||||
index: 3,
|
||||
name: 'test',
|
||||
uplinkEnabled: false,
|
||||
downlinkEnabled: false,
|
||||
},
|
||||
@@ -118,8 +118,8 @@ export class MeshController {
|
||||
id: 456789,
|
||||
dir: 'tx',
|
||||
to: 42,
|
||||
text: 'hello testowy',
|
||||
channel: 2,
|
||||
text: 'hello test',
|
||||
channel: 3,
|
||||
at: 1758000123456,
|
||||
status: 'delivered',
|
||||
},
|
||||
|
||||
@@ -295,11 +295,11 @@ describe('MeshService connect', () => {
|
||||
});
|
||||
|
||||
describe('MeshService send', () => {
|
||||
it('sends on the test channel (index 2) by default, never primary', async () => {
|
||||
it('sends on the test channel (index 3) by default, never primary', async () => {
|
||||
const bridge = await startBridge();
|
||||
process.env.MESH_HOST = '127.0.0.1';
|
||||
process.env.MESH_PORT = String(bridge.port);
|
||||
delete process.env.MESH_SEND_CHANNEL; // default path: "testowy" (index 2)
|
||||
delete process.env.MESH_SEND_CHANNEL; // default path: "test" (index 3)
|
||||
const svc = new MeshService();
|
||||
try {
|
||||
svc.onModuleInit();
|
||||
@@ -309,7 +309,7 @@ describe('MeshService send', () => {
|
||||
|
||||
const out: Uint8Array[] = [];
|
||||
bridge.sockets[0].on('data', (c) => out.push(c));
|
||||
const id = await svc.sendText(42, 'hello testowy');
|
||||
const id = await svc.sendText(42, 'hello test');
|
||||
expect(id).toBeGreaterThan(0);
|
||||
|
||||
const readOutbound = (): P.Mesh.MeshPacket | undefined => {
|
||||
@@ -331,7 +331,7 @@ describe('MeshService send', () => {
|
||||
|
||||
await waitFor(() => readOutbound() !== undefined);
|
||||
const pkt = readOutbound()!;
|
||||
expect(pkt.channel).toBe(2); // "testowy" — never the primary channel (0)
|
||||
expect(pkt.channel).toBe(3); // "test" — never the primary channel (0)
|
||||
expect(pkt.to).toBe(42);
|
||||
const decoded =
|
||||
pkt.payloadVariant?.case === 'decoded'
|
||||
@@ -339,7 +339,7 @@ describe('MeshService send', () => {
|
||||
: undefined;
|
||||
expect(
|
||||
new TextDecoder().decode(decoded?.payload ?? new Uint8Array()),
|
||||
).toBe('hello testowy');
|
||||
).toBe('hello test');
|
||||
} finally {
|
||||
delete process.env.MESH_SEND_CHANNEL;
|
||||
svc.onModuleDestroy();
|
||||
@@ -537,13 +537,13 @@ describe('MeshService message history', () => {
|
||||
() => bridge.sockets.length === 1 && svc.status().connected,
|
||||
);
|
||||
|
||||
const id = await svc.sendText(42, 'hello testowy');
|
||||
const id = await svc.sendText(42, 'hello test');
|
||||
expect(svc.messages()[0]).toMatchObject({
|
||||
id,
|
||||
dir: 'tx',
|
||||
to: 42,
|
||||
text: 'hello testowy',
|
||||
channel: 2,
|
||||
text: 'hello test',
|
||||
channel: 3,
|
||||
status: 'pending',
|
||||
});
|
||||
|
||||
|
||||
@@ -71,9 +71,9 @@ export class MeshService implements OnModuleInit, OnModuleDestroy {
|
||||
process.env.MESH_RECONNECT_MS ?? '5000',
|
||||
10,
|
||||
);
|
||||
// sends are pinned to the test channel ("testowy", index 2) on purpose — never the primary channel
|
||||
// sends are pinned to the test channel ("test", index 3) on purpose — never the primary channel
|
||||
private readonly sendChannel = parseInt(
|
||||
process.env.MESH_SEND_CHANNEL ?? '2',
|
||||
process.env.MESH_SEND_CHANNEL ?? '3',
|
||||
10,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user