Constructor
new AdapterFactory(singletonToken, bleDrivers, options)
Shall not be called by user. Called by the factory method `this.getInstance()`.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
singletonToken |
Symbol
|
Symbol to ensure that only one instance of `AdapterFactory` ever exists. |
bleDrivers |
Object
|
Object mapping version to pc-ble-driver AddOn. |
options |
Object
|
Options for customizing the behavior of the adapter factory. |
Fires:
Methods
(static) getInstance(bleDriversopt, optionsopt) → {AdapterFactory}
Get the singleton `AdapterFactory` instance.
The mapping of SoftDevice API version to pc-ble-driver AddOn can be overridden
by providing a custom `bleDrivers` argument. By default the AdapterFactory will
poll for added/removed adapters every 2 seconds and emit 'added' and 'removed'
events. This can be disabled by passing `enablePolling: false` as part of the
options object.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
bleDrivers |
Object
|
<optional> |
Optional object mapping version to pc-ble-driver AddOn. |
options |
Object
|
<optional> |
Optional object for customizing the behavior of the adapter factory. |
createAdapter(sdVersion, comName, instanceId) → {Adapter}
Create Adapter with custom serialport
- Source:
Parameters:
Name | Type | Description |
---|---|---|
sdVersion |
string
|
Softdevice API version: 'v2' or 'v3'. |
comName |
string
|
Serialport name (eg. 'COM7' on windows). |
instanceId |
string
|
The unique Id that identifies this Adapter instance. |
getAdapters(callback) → {void}
Get connected adapters.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
callback |
null
|
function
|
Optional callback signature: (err, adapters) => {}. |
Returns:
- Type:
-
void
Events
adapterClosed
Adapter closed event.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
adapter |
object
|
The adapter instance that was closed. |
adapterOpened
Adapter opened event.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
adapter |
object
|
The adapter instance that was opened. |
added
Adapter added event. Fired when a new devkit is found.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
adapter |
object
|
The adapter instance that was added. |
error
Error event.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
error |
Error
|
Error object with a human-readable message. |
logMessage
Log message event.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
severity |
string
|
Severity of the log event. |
message |
string
|
Human-readable log message. |
removed
Adapter removed event. Fired when a devkit is removed.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
adapter |
object
|
The adapter instance that was removed. |