Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ZigBee on Host #1308

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/adapter/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export abstract class Adapter extends events.EventEmitter<AdapterEventMap> {
zstack: ['./z-stack/adapter/zStackAdapter', 'ZStackAdapter'],
zboss: ['./zboss/adapter/zbossAdapter', 'ZBOSSAdapter'],
zigate: ['./zigate/adapter/zigateAdapter', 'ZiGateAdapter'],
zoh: ['./zoh/adapter/zohAdapter', 'ZoHAdapter'],
};
const [adapter, path] = await discoverAdapter(serialPortOptions.adapter, serialPortOptions.path);
const detectedAdapter = adapterLookup[adapter];
Expand Down
5 changes: 5 additions & 0 deletions src/adapter/adapterDiscovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ function matchUSBFingerprint(
}

export async function matchUSBAdapter(adapter: Adapter, path: string): Promise<boolean> {
// no point in matching this
if (adapter === 'zoh') {
return false;
}

const isWindows = platform() === 'win32';
const portList = await getSerialPortList();

Expand Down
4 changes: 2 additions & 2 deletions src/adapter/socketPortUtils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function isTcpPath(path: string): boolean {
export function isTcpPath(path: string): boolean {
// tcp path must be:
// tcp://<host>:<port>
const regex = /^(?:tcp:\/\/)[\w.-]+[:][\d]+$/gm;
return regex.test(path);
}

function parseTcpPath(path: string): {host: string; port: number} {
export function parseTcpPath(path: string): {host: string; port: number} {
const str = path.replace('tcp://', '');
return {
host: str.substring(0, str.indexOf(':')),
Expand Down
2 changes: 1 addition & 1 deletion src/adapter/tstype.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type Adapter = 'deconz' | 'ember' | 'zstack' | 'zboss' | 'zigate' | 'ezsp';
export type Adapter = 'deconz' | 'ember' | 'zstack' | 'zboss' | 'zigate' | 'ezsp' | 'zoh';
export type DiscoverableUSBAdapter = 'deconz' | 'ember' | 'zstack' | 'zboss' | 'zigate';

export type USBAdapterFingerprint = {
Expand Down
27 changes: 27 additions & 0 deletions src/adapter/zoh/adapter/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @param value 64-bit bigint
* @returns 16-length hex string in big-endian
*/
export function bigUInt64ToHexBE(value: bigint): string {
return value.toString(16).padStart(16, '0');
}

/**
* @param value 64-bit bigint
* @returns 8-bytelength buffer in little-endian
*/
export function bigUInt64ToBufferLE(value: bigint): Buffer {
const b = Buffer.alloc(8);
b.writeBigUInt64LE(value, 0);
return b;
}

/**
* @param value 64-bit bigint
* @returns 8-bytelength buffer in big-endian
*/
export function bigUInt64ToBufferBE(value: bigint): Buffer {
const b = Buffer.alloc(8);
b.writeBigUInt64BE(value, 0);
return b;
}
Loading
Loading