Skip to content

Commit

Permalink
Add -port
Browse files Browse the repository at this point in the history
  • Loading branch information
Luligu committed Apr 10, 2024
1 parent a61a0b1 commit 2ca99f0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/matterbridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export class Matterbridge extends EventEmitter {
public bridgeMode: 'bridge' | 'childbridge' | 'controller' | '' = '';
public debugEnabled = false;

private port = 5540;
private log!: AnsiLogger;
private hasCleanupStarted = false;
private registeredPlugins: RegisteredPlugin[] = [];
Expand Down Expand Up @@ -236,6 +237,8 @@ export class Matterbridge extends EventEmitter {
process.exit(0);
}

// Set the first port to use
this.port = getIntParameter('port') ?? 5540;
// Set Matterbridge logger
if (hasParameter('debug')) this.debugEnabled = true;
this.log = new AnsiLogger({ logName: 'Matterbridge', logTimestampFormat: TimestampFormat.TIME_MILLIS, logDebug: this.debugEnabled });
Expand Down Expand Up @@ -1603,6 +1606,7 @@ export class Matterbridge extends EventEmitter {
if (!allStarted) this.log.info(`***Waiting in start matter server interval for plugin ${plg}${plugin.name}${db} to load (${plugin.loaded}) and start (${plugin.started}) ...`);
});
if (!allStarted) return;
clearInterval(startMatterInterval);
this.log.info('Starting matter server...');

// Setting reachability to true
Expand Down Expand Up @@ -1636,7 +1640,7 @@ export class Matterbridge extends EventEmitter {
await this.showCommissioningQRCode(plugin.commissioningServer, plugin.storageContext, plugin.nodeContext, plugin.name);
}
Logger.defaultLogLevel = this.debugEnabled ? Level.DEBUG : Level.INFO;
clearInterval(startMatterInterval);
//clearInterval(startMatterInterval);
}, 1000);
}
}
Expand Down Expand Up @@ -1834,7 +1838,7 @@ export class Matterbridge extends EventEmitter {
this.log.debug(`Creating matter commissioning server for plugin ${plg}${pluginName}${db} with softwareVersion ${softwareVersion} softwareVersionString ${softwareVersionString}`);
this.log.debug(`Creating matter commissioning server for plugin ${plg}${pluginName}${db} with hardwareVersion ${hardwareVersion} hardwareVersionString ${hardwareVersionString}`);
const commissioningServer = new CommissioningServer({
port: undefined,
port: this.port++,
passcode: undefined,
discriminator: undefined,
deviceName,
Expand Down

0 comments on commit 2ca99f0

Please sign in to comment.