Skip to content

Commit

Permalink
Added bluetooth to the controller
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Nov 24, 2023
1 parent 8a4b567 commit f36d6c9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src-admin/src/Tabs/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,20 @@ class Controller extends React.Component {
label={I18n.t('Bluetooth')}
/>
</div> : null}
{this.props.matter.controller.enabled && this.props.matter.controller.ble ? <div>
<TextField
fullWidth
style={{ maxWidth: 600 }}
type="number"
label={I18n.t('Bluetooth HCI ID')}
value={this.props.matter.controller.hciId || ''}
onChange={e => {
const matter = JSON.parse(JSON.stringify(this.props.matter));
matter.controller.hciId = e.target.value;
this.props.updateConfig(matter);
}}
/>
</div> : null}
{this.props.matter.controller.enabled && this.props.matter.controller.ble ? <div>
<TextField
fullWidth
Expand Down
11 changes: 10 additions & 1 deletion src/matter/ControllerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Endpoint, CommissioningControllerNodeOptions,
PairedNode,
} from '@project-chip/matter-node.js/device';
import { toHexString } from '@project-chip/matter-node.js/util';
import { toHexString, singleton } from '@project-chip/matter-node.js/util';
import {
asClusterServerInternal,
ClusterServerObj,
Expand All @@ -28,6 +28,9 @@ import {
GeneralCommissioning,
} from '@project-chip/matter-node.js/cluster';

import { BleNode } from '@project-chip/matter-node-ble.js/ble';
import { Ble } from '@project-chip/matter-node.js/ble';

import { MatterAdapter } from '../main';
import Factories from './clusters/factories';
import Base from './clusters/Base';
Expand All @@ -45,6 +48,7 @@ export interface ControllerOptions {
wifiPasword?: string;
threadNetworkname?: string;
threadOperationalDataSet?: string;
hciId?: number;
}

interface AddDeviceResult {
Expand Down Expand Up @@ -87,6 +91,7 @@ interface Device {
connectionStatusId?: string;
}


class Controller {
private matterServer: MatterServer | undefined;
private parameters: ControllerOptions;
Expand Down Expand Up @@ -121,6 +126,10 @@ class Controller {
});

this.matterServer?.addCommissioningController(this.commissioningController, { uniqueStorageKey: this.parameters.uuid });

if (this.parameters.ble) {
Ble.get = singleton(() => new BleNode({ hciId: this.parameters.hciId }));
}
}

initEventHandlers(originalNodeId: NodeId | null, options?: any): any {
Expand Down

0 comments on commit f36d6c9

Please sign in to comment.