From 77f6516eef369d804f3e0625ed6c1e37dbb939a2 Mon Sep 17 00:00:00 2001 From: Greg Lauckhart Date: Sat, 9 Mar 2024 11:31:13 -0800 Subject: [PATCH] "protocol" -> "transport" per CR --- .../behavior/system/network/NetworkServer.ts | 26 +++++++++---------- .../system/network/ServerNetworkRuntime.ts | 4 +-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/matter.js/src/behavior/system/network/NetworkServer.ts b/packages/matter.js/src/behavior/system/network/NetworkServer.ts index bb84a75692..00cae61051 100644 --- a/packages/matter.js/src/behavior/system/network/NetworkServer.ts +++ b/packages/matter.js/src/behavior/system/network/NetworkServer.ts @@ -110,14 +110,14 @@ export class NetworkServer extends NetworkBehavior { throw new ImplementationError("Listen address is not an object"); } - let { protocol, port } = addr as Record; + let { transport, port } = addr as Record; const { address } = addr as Record; - if (protocol === undefined) { - protocol = "udp"; + if (transport === undefined) { + transport = "udp"; } - switch (protocol) { + switch (transport) { case "ble": if (Ble.enabled) { if (hasBle) { @@ -126,9 +126,9 @@ export class NetworkServer extends NetworkBehavior { hasBle = true; } if (address !== undefined) { - throw new NotImplementedError("Currently you may not specify HCI ID for BLE transport"); + throw new NotImplementedError("Currently you may not specify the BLE transport address"); } - listen.push({ protocol, address }); + listen.push({ transport: transport, address }); this.state.ble = true; } else { disabledBle = true; @@ -142,11 +142,11 @@ export class NetworkServer extends NetworkBehavior { if (port === undefined) { port = this.state.port; } - listen.push({ protocol, address, port }); + listen.push({ transport: transport, address, port }); break; default: - throw new ImplementationError(`Unknown listen protocol "${protocol}"`); + throw new ImplementationError(`Unknown listen protocol "${transport}"`); } } @@ -155,13 +155,13 @@ export class NetworkServer extends NetworkBehavior { this.state.ble = false; } else if (this.state.ble !== false && Ble.enabled) { if (!hasBle) { - listen.push({ protocol: "ble" }); + listen.push({ transport: "ble" }); } this.state.ble = true; } if (!hasUdp) { - listen.push({ protocol: "udp", port: this.state.port }); + listen.push({ transport: "udp", port: this.state.port }); } return listen; @@ -173,7 +173,7 @@ export namespace NetworkServer { * A UDP listening address. */ export interface UdpAddress { - protocol: "udp" | "udp4" | "udp6"; + transport: "udp" | "udp4" | "udp6"; /** * The hostname or IP address. Leave undefined for all addresses, "0.0.0.0" for all IPv4 addresses, and "::" @@ -193,7 +193,7 @@ export namespace NetworkServer { * TODO - currently only a single BLE transport is supported */ export interface BleAddress { - protocol: "ble"; + transport: "ble"; /** * The HCI ID of the bluetooth adapter. @@ -217,7 +217,7 @@ export namespace NetworkServer { * * Configurable also with variable "network.listen". You may configure a single listener using: * - * * `network.listen.protocol` either "ble", "udp4", "udp6" or "udp" (default is "udp" for dual IPv4/6) + * * `network.listen.transport` either "ble", "udp4", "udp6" or "udp" (default is "udp" for dual IPv4/6) * * `network.listen.address` the hostname, IP address (default all) or HCI ID (default first) to listen on * * `network.listen.port` the port for UDP listeners (default is 5540) * diff --git a/packages/matter.js/src/behavior/system/network/ServerNetworkRuntime.ts b/packages/matter.js/src/behavior/system/network/ServerNetworkRuntime.ts index c25fe82746..80cdf21022 100644 --- a/packages/matter.js/src/behavior/system/network/ServerNetworkRuntime.ts +++ b/packages/matter.js/src/behavior/system/network/ServerNetworkRuntime.ts @@ -93,13 +93,13 @@ export class ServerNetworkRuntime extends NetworkRuntime { const bleTransports = new Set(); for (const address of this.owner.state.network.listen) { - switch (address.protocol) { + switch (address.transport) { case "udp": case "udp4": case "udp6": const udp = await UdpInterface.create( this.owner.env.get(Network), - address.protocol, + address.transport, address.port, address.address, );