Skip to content

Commit 27ffa13

Browse files
committed
Remove ParentControlHub, since control hubs will always be parents
1 parent 41ae6a3 commit 27ffa13

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/control-hub/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"devDependencies": {
1919
"@types/node": "^16.18.18",
2020
"@types/semver": "^7.5.0",
21+
"@types/node-forge": "^1.3.2",
2122
"typescript": "^5.0.2"
2223
},
2324
"scripts": {
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
import { ExpansionHub, ParentRevHub } from "@rev-robotics/expansion-hub";
22

3-
export interface ParentControlHub extends ParentRevHub, ControlHub {
4-
readonly serialNumber: string;
5-
}
6-
7-
export interface ControlHub extends ExpansionHub {}
3+
export interface ControlHub extends ExpansionHub, ParentRevHub {}

packages/control-hub/src/discovery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async function isControlHub(deviceClient: DeviceClient): Promise<boolean> {
4949
}
5050

5151
async function createWiFiControlHub(): Promise<ControlHub> {
52-
let hub = new ControlHubInternal();
52+
let hub = new ControlHubInternal("Placeholder");
5353

5454
if (!(await hub.isWiFiConnected())) {
5555
throw new Error("Hub is not connected via WiFi");

packages/control-hub/src/internal/ControlHub.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,28 @@ import axios from "axios";
2323
import semver from "semver";
2424
import WebSocket from "isomorphic-ws";
2525
import adb from "@u4/adbkit";
26-
import { ControlHub, ParentControlHub } from "../ControlHub.js";
26+
import { ControlHub } from "../ControlHub.js";
2727

2828
export class ControlHubInternal implements ControlHub {
2929
readonly isOpen: boolean = true;
3030
moduleAddress: number = 0;
3131
responseTimeoutMs: number = 0;
3232
type: RevHubType = RevHubType.ControlHub;
3333
webSocketConnection!: WebSocket;
34-
private readonly serialNumber?: string;
34+
readonly serialNumber: string;
35+
readonly children: ReadonlyArray<RevHub> = [];
3536

3637
keyGenerator = 0;
3738
currentActiveCommands = new Map<
3839
any,
3940
(response: any | undefined, error: any | undefined) => void
4041
>();
4142

42-
constructor(serialNumber?: string) {
43+
constructor(serialNumber: string) {
4344
this.serialNumber = serialNumber;
4445
}
4546

46-
isParent(): this is ParentControlHub {
47+
isParent(): this is ParentRevHub {
4748
return this.serialNumber !== undefined;
4849
}
4950

@@ -418,4 +419,12 @@ export class ControlHubInternal implements ControlHub {
418419
});
419420
});
420421
}
422+
423+
addChild(hub: RevHub): void {
424+
throw new Error("not implemented");
425+
}
426+
427+
addChildByAddress(moduleAddress: number): Promise<RevHub> {
428+
throw new Error("not implemented");
429+
}
421430
}

packages/sample/src/command/list.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ import { openConnectedControlHub, openUsbControlHubs } from "@rev-robotics/contr
55
export async function list() {
66
let usbControlHubs = await openUsbControlHubs();
77
for (const hub of usbControlHubs) {
8-
if (hub.isParent()) {
9-
console.log(`USB Control Hub: ${hub.serialNumber} ${hub.moduleAddress}\n\n`);
10-
} else {
11-
console.log(`\tUSB Control Hub: ${hub.moduleAddress}\n\n`);
12-
}
8+
console.log(`USB Control Hub: ${hub.serialNumber} ${hub.moduleAddress}\n\n`);
139
hub.close();
1410
}
1511

0 commit comments

Comments
 (0)