Skip to content

Commit

Permalink
Rename gateway to Serial Bridge Proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
bcopy committed Oct 12, 2024
1 parent 92cc70d commit 6e776c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { HomieDevice, HomieNode, HomieProperty, createMqttHomieObserver } from '


/**
* The Gateway controls a radio bridge Microbit and multiple wireless Microbit terminals,
* The BridgeProxy controls a radio bridge Microbit and multiple wireless Microbit terminals,
* using the WebUSB serial port as a communication medium.
*/
class Gateway {
class SerialBridgeProxy {
constructor(homieObserver) {
this.homieObserver = homieObserver;
this.terminals = new Map();
Expand Down Expand Up @@ -239,14 +239,14 @@ class Gateway {
}
}

async function initializeGateway(mqttUrl) {
async function initialize(mqttUrl) {
const homieObserver = createMqttHomieObserver(mqttUrl);

homieObserver.subscribe("homie/terminal-+/#");

const gateway = new Gateway(homieObserver);
const bridgeProxy = new SerialBridgeProxy(homieObserver);

return gateway;
return bridgeProxy;
}

export {initializeGateway, Gateway};
export {initialize, SerialBridgeProxy};
8 changes: 4 additions & 4 deletions src/vote-aggregator.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {initializeGateway} from './homie-lit-components/gateway';
import {initialize as initializeBridgeProxy} from './homie-lit-components/SerialBridgeProxy';

document.getElementById('connectButton').addEventListener('click', async () => {
try {
const gateway = await initializeGateway('ws://localhost:9001');
const bridgeProxy = await initializeBridgeProxy('ws://localhost:9001');
document.getElementById('status').textContent = 'Connected successfully!';

// Add mode switching buttons
const votingButton = document.createElement('button');
votingButton.textContent = 'Switch to Voting Mode';
votingButton.addEventListener('click', () => gateway.switchMode('VOTING'));
votingButton.addEventListener('click', () => bridgeProxy.switchMode('VOTING'));
document.body.appendChild(votingButton);

const sensorButton = document.createElement('button');
sensorButton.textContent = 'Switch to Sensor Mode';
sensorButton.addEventListener('click', () => gateway.switchMode('SENSOR'));
sensorButton.addEventListener('click', () => bridgeProxy.switchMode('SENSOR'));
document.body.appendChild(sensorButton);

} catch (error) {
Expand Down

0 comments on commit 6e776c1

Please sign in to comment.