-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
178 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
import * as TsType from './tstype'; | ||
import Adapter from './adapter'; | ||
import {ZStackAdapter} from './z-stack/adapter'; | ||
import * as Events from './events'; | ||
|
||
export { | ||
TsType, Adapter, ZStackAdapter, Events, | ||
TsType, Adapter, Events, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import SerialPort from 'serialport'; | ||
import {EqualsPartial} from '../utils'; | ||
|
||
interface PortInfoMatch { | ||
manufacturer: string; | ||
vendorId: string; | ||
productId: string; | ||
} | ||
|
||
async function find(matchers: PortInfoMatch[]): Promise<string[]> { | ||
let devices = await SerialPort.list(); | ||
devices = devices.filter((device) => matchers.find((matcher) => EqualsPartial(device, matcher)) != null); | ||
// @ts-ignore; not sure why this is needed as path exists (definition is wrong?) | ||
return devices.map((device) => device.path); | ||
} | ||
|
||
async function is(path: string, matchers: PortInfoMatch[]): Promise<boolean> { | ||
const devices = await SerialPort.list(); | ||
// @ts-ignore; not sure why this is needed as path exists (definition is wrong?) | ||
const device = devices.find((device) => device.path === path); | ||
return matchers.find((matcher) => EqualsPartial(device, matcher)) != null; | ||
} | ||
|
||
export default {is, find}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.