Skip to content

Latest commit

 

History

History
2586 lines (1460 loc) · 65.3 KB

reference.md

File metadata and controls

2586 lines (1460 loc) · 65.3 KB

Table of Contents

CellularDevice

src/cellular-device.js:12-54

Cellular device.

This class is not meant to be instantiated directly. Use getDevices and openDeviceById to create device instances.

Parameters

  • base

CloudConnectionStatus

src/cloud-device.js:12-21

Cloud connection status.

Type: String

DISCONNECTED

src/cloud-device.js:14-14

Disconnected.

CONNECTING

src/cloud-device.js:16-16

Connecting.

CONNECTED

src/cloud-device.js:18-18

Connected.

DISCONNECTING

src/cloud-device.js:20-20

Disconnecting.

ServerProtocol

src/cloud-device.js:28-33

Server protocol types.

Type: String

TCP

src/cloud-device.js:30-30

TCP.

UDP

src/cloud-device.js:32-32

UDP.

CloudDevice

src/cloud-device.js:43-379

Cloud-enabled device.

This class is not meant to be instantiated directly. Use getDevices and openDeviceById to create device instances.

Parameters

  • base

config

src/config.js:23-25

Set global options.

Parameters

  • options Object? Options.
    • options.requestTimeout Number Default request timeout (milliseconds). (optional, default 60000)
    • options.log Object? Logger instance. The logger is expected to have the following methods: trace(String), info(String), warn(String), error(String).

Returns Object Current options.

PollingPolicy

src/device-base.js:57-60

Predefined polling policies.

Type: Function

DEFAULT

src/device-base.js:59-59

Default polling policy.

Parameters

  • n

DeviceBase

src/device-base.js:85-738

Extends EventEmitter

Base class for a Particle USB device.

This class is not meant to be instantiated directly. Use getDevices and openDeviceById to create device instances.

Parameters

  • dev
  • info

open

src/device-base.js:117-169

Open the device.

Parameters

  • options Object? Options.
    • options.concurrentRequests Number? Maximum number of requests that can be sent to the device concurrently. Requests that exceed this limit are queued. By default, this parameter is set to the maximum number of concurrent requests supported by the device.

Returns Promise

close

src/device-base.js:181-210

Close the device.

Parameters

  • options Object? Options.
    • options.processPendingRequests Boolean Whether to complete processing of the pending requests before closing the device. (optional, default true)
    • options.timeout Number? Timeout for processing pending requests (milliseconds). By default, the device is kept open until all requests are processed.

Returns Promise

sendControlRequest

src/device-base.js:226-276

Send a control request to the device.

Parameters

  • type Number Request type.
  • data (Buffer | String) Request data.
  • options Object? Request options.
    • options.pollingPolicy (Function | Number) Request polling policy. This parameter specifies how frequently the device will be polled to determine the result of the request. The argument can either be a function that returns the number of milliseconds to wait before polling the device again or a number that specifies a fixed interval. (optional, default PollingPolicy.DEFAULT)
    • options.timeout Number? Request timeout. The default timeout can be configured via config.

Returns Promise<Object> Response object.

reset

src/device-base.js:285-290

Perform the system reset.

This method only works in DFU mode.

Returns Promise

isOpen

src/device-base.js:295-297

Set to true if the device is open.

id

src/device-base.js:304-306

Device ID.

This property is set to null if the device is closed.

firmwareVersion

src/device-base.js:313-315

Device OS system version.

This property is set to null if the device is closed or the version could not be determined.

type

src/device-base.js:320-322

Device type (photon, boron, tracker, etc)

platformId

src/device-base.js:327-329

Platform ID

vendorId

src/device-base.js:334-336

USB vendor ID.

productId

src/device-base.js:341-343

USB product ID.

isInDfuMode

src/device-base.js:348-350

Set to true if this device is in the DFU mode.

usbDevice

src/device-base.js:355-357

Internal USB device handle.

quirks

src/device-base.js:362-364

Device USB quirks

BOOTLOADER

src/device.js:13-13

Bootloader module.

SYSTEM_PART

src/device.js:15-15

System part module.

USER_PART

src/device.js:17-17

User part module.

MONO_FIRMWARE

src/device.js:19-19

Monolithic firmware module.

NCP_FIRMWARE

src/device.js:21-21

Network co-processor firmware module

RADIO_STACK

src/device.js:23-23

Radio stack module

FirmwareModule

src/device.js:31-42

Firmware module types.

Type: String

FirmwareModuleStore

src/device.js:49-54

Firmware module store.

Type: String

FirmwareModuleDisplayNames

src/device.js:73-84

Firmware module readable names

Type: String

DeviceMode

src/device.js:91-96

Device modes.

Type: String

NORMAL

src/device.js:93-93

Device is in normal mode.

LISTENING

src/device.js:95-95

Device is in listening mode.

LogLevel

src/device.js:103-116

Logging levels.

Type: String

ALL

src/device.js:105-105

Enables logging of all messages.

TRACE

src/device.js:107-107

Enables logging of trace messages.

INFO

src/device.js:109-109

Enables logging of info messages.

WARN

src/device.js:111-111

Enables logging of warning messages.

ERROR

src/device.js:113-113

Enables logging of error messages.

NONE

src/device.js:115-115

Disables logging of any messages.

Device

src/device.js:165-1210

Extends DeviceBase

Basic functionality supported by most of Particle devices.

This class is not meant to be instantiated directly. Use getDevices and openDeviceById to create device instances.

getSerialNumber

src/device.js:177-184

Get the device's serial number.

Supported platforms:

  • Gen 3 (since Device OS 0.9.0)
  • Gen 2 (since Device OS 1.5.0)

Parameters

  • options Object? Options. (optional, default {})
    • options.timeout Number? Timeout (milliseconds). (optional, default globalOptions.requestTimeout)

Returns Promise<String>

getDeviceId

src/device.js:197-204

Get the device's id.

Supported platforms:

  • Gen 3 (since Device OS 0.9.0)
  • Gen 2 (since Device OS 1.5.0)

Parameters

  • options Object? Options. (optional, default {})
    • options.timeout Number? Timeout (milliseconds). (optional, default globalOptions.requestTimeout)

Returns Promise<String>

reset

src/device.js:224-238

Perform the system reset.

Note: The only safe operation that can be performed on the device instance after the device resets is closing it via DeviceBase#close.

Supported platforms:

  • Gen 3 (since Device OS 0.9.0)
  • Gen 2 (since Device OS 0.8.0)

The force option is supported since Device OS 2.0.0.

Parameters

  • options Object? Options. (optional, default {})
    • options.force Boolean? Reset the device immediately, even if it is busy performing some blocking operation, such as writing to flash. (optional, default false)
    • options.timeout Number? Timeout (milliseconds). (optional, default globalOptions.requestTimeout)

Returns Promise

factoryReset

src/device.js:254-256

Perform the factory reset.

Note: The only safe operation that can be performed on the device instance after the device resets is closing it via DeviceBase#close.

Supported platforms:

  • Gen 3 (since Device OS 0.9.0)
  • Gen 2 (since Device OS 0.8.0)

Parameters

  • options Object? Options. (optional, default {})
    • options.timeout Number? Timeout (milliseconds). (optional, default globalOptions.requestTimeout)

Returns Promise

enterDfuMode

src/device.js:275-297

Reset and enter the DFU mode.

Note: The only safe operation that can be performed on the device instance after the device resets is closing it via DeviceBase#close.

Supported platforms:

  • Gen 3 (since Device OS 0.9.0)
  • Gen 2 (since Device OS 0.8.0)

Parameters

  • options Object? Options. (optional, default {})
    • options.noReconnectWait Boolean? After entering DFU mode, do not attempt to connect to the device to make sure it's in DFU mode. This can be useful in a web browser because connecting to the device in DFU mode may prompt the user to authorize access to the device. (optional, default false)
    • options.timeout Number? Timeout (milliseconds). (optional, default globalOptions.requestTimeout)

Returns Promise

enterSafeMode

src/device.js:314-319

Reset and enter the safe mode.

Note: The only safe operation that can be performed on the device instance after the device resets is closing it via DeviceBase#close.

Supported platforms:

  • Gen 3 (since Device OS 0.9.0)
  • Gen 2 (since Device OS 0.8.0)

Parameters

  • options Object? Options. (optional, default {})
    • options.timeout Number? Timeout (milliseconds). (optional, default globalOptions.requestTimeout)

Returns Promise

enterListeningMode

src/device.js:332-356

Enter listening mode.

Supported platforms:

  • Gen 3 (since Device OS 0.9.0)
  • Gen 2 (since Device OS 0.8.0)

Parameters

  • options Object? Options. (optional, default {})
    • options.timeout Number? Timeout (milliseconds). (optional, default globalOptions.requestTimeout)

Returns Promise Resolves when either device is confirmed to be in listening mode, throws an error, or timeout exceeded.

leaveListeningMode

src/device.js:369-371

Leave the listening mode.

Supported platforms:

  • Gen 3 (since Device OS 0.9.0)
  • Gen 2 (since Device OS 0.8.0)

Parameters

  • options Object? Options. (optional, default {})
    • options.timeout Number? Timeout (milliseconds). (optional, default globalOptions.requestTimeout)

Returns Promise

getDeviceMode

src/device.js:384-387

Get the device mode.

Supported platforms:

  • Gen 3 (since Device OS 0.9.0)
  • Gen 2 (since Device OS 1.1.0)

Parameters

  • options Object? Options. (optional, default {})
    • options.timeout Number? Timeout (milliseconds). (optional, default globalOptions.requestTimeout)

Returns Promise<DeviceMode>

startNyanSignal

src/device.js:400-402

Start the Nyan LED indication.

Supported platforms:

  • Gen 3 (since Device OS 0.9.0)
  • Gen 2 (since Device OS 0.8.0)

Parameters

  • options Object? Options. (optional, default {})
    • options.timeout Number? Timeout (milliseconds). (optional, default globalOptions.requestTimeout)

Returns Promise

stopNyanSignal

src/device.js:415-417

Stop the Nyan LED indication.

Supported platforms:

  • Gen 3 (since Device OS 0.9.0)
  • Gen 2 (since Device OS 0.8.0)

Parameters

  • options Object? Options. (optional, default {})
    • options.timeout Number? Timeout (milliseconds). (optional, default globalOptions.requestTimeout)

Returns Promise

updateFirmware

src/device.js:432-459

Perform the firmware update.

Supported platforms:

  • Gen 3 (since Device OS 0.9.0)
  • Gen 2 (since Device OS 0.8.0)

Parameters

  • data Buffer Firmware data.
  • options Object? Options. (optional, default {})
    • options.timeout Number? Timeout (milliseconds). (optional, default DEFAULT_FIRMWARE_UPDATE_TIMEOUT)
    • options.progress Function? User's callback function to log progress of the flashing process.

Returns Promise

getFirmwareModule

src/device.js:474-488

Get firmware module data.

Parameters

Returns Promise<Buffer>

Meta

  • deprecated: This method is not guaranteed to work with recent versions of Device OS and it will be removed in future versions of this library.

    Supported platforms:

    • Gen 2 (since Device OS 0.8.0, deprecated in 2.0.0)

getAssetInfo

src/device.js:499-524

Get asset info.

Supported platforms:

  • Gen 3+ (since Device OS 5.6.0)

Parameters

  • $0 Object (optional, default {})
    • $0.timeout (optional, default globalOptions.timeout)

Returns Promise<Array> List of asssets available on the device.

getFirmwareModuleInfo

src/device.js:537-598

Get firmware module info.

Supported platforms:

  • Gen 3 (since Device OS 0.9.0)
  • Gen 2 (since Device OS 0.8.0)
  • New format since 5.6.0 (old format in 'modules_deprecated')

Parameters

  • $0 Object (optional, default {})
    • $0.timeout (optional, default globalOptions.requestTimeout)

Returns Promise<Array> List of modules installed into the device and their dependencies

hasModularFirmware

src/device.js:611-613

Check if the device runs a modular firmware.

Returns Promise<Boolean>

Meta

  • deprecated: This method is not guaranteed to work with recent versions of Device OS and it will be removed in future versions of this library.

    Supported platforms:

    • Gen 2 (since Device OS 0.8.0, deprecated in 2.0.0)

setFactoryFirmware

src/device.js:627-634

Set factory firmware.

Parameters

Returns Promise

Meta

  • deprecated: This method is not guaranteed to work with recent versions of Device OS and it will be removed in future versions of this library.

    Supported platforms:

    • Gen 2 (since Device OS 0.8.0, deprecated in 2.0.0)

getFactoryFirmware

src/device.js:647-658

Get factory firmware.

Returns Promise<Buffer>

Meta

  • deprecated: This method is not guaranteed to work with recent versions of Device OS and it will be removed in future versions of this library.

    Supported platforms:

    • Gen 2 (since Device OS 0.8.0, deprecated in 2.0.0)

readConfigData

src/device.js:673-680

Read configuration data.

Parameters

Returns Promise<Buffer>

Meta

  • deprecated: This method is not guaranteed to work with recent versions of Device OS and it will be removed in future versions of this library.

    Supported platforms:

    • Gen 2 (since Device OS 0.8.0, deprecated in 2.0.0)

writeConfigData

src/device.js:695-702

Write configuration data.

Parameters

Returns Promise

Meta

  • deprecated: This method is not guaranteed to work with recent versions of Device OS and it will be removed in future versions of this library.

    Supported platforms:

    • Gen 2 (since Device OS 0.8.0, deprecated in 2.0.0)

getConfigDataSize

src/device.js:715-722

Get size of the configuration data.

Returns Promise<Number>

Meta

  • deprecated: This method is not guaranteed to work with recent versions of Device OS and it will be removed in future versions of this library.

    Supported platforms:

    • Gen 2 (since Device OS 0.8.0, deprecated in 2.0.0)

readEeprom

src/device.js:737-744

Read from EEPROM.

Parameters

Returns Promise<Buffer>

Meta

  • deprecated: This method is not guaranteed to work with recent versions of Device OS and it will be removed in future versions of this library.

    Supported platforms:

    • Gen 2 (since Device OS 0.8.0, deprecated in 2.0.0)

writeEeprom

src/device.js:759-766

Write to EEPROM.

Parameters

Returns Promise

Meta

  • deprecated: This method is not guaranteed to work with recent versions of Device OS and it will be removed in future versions of this library.

    Supported platforms:

    • Gen 2 (since Device OS 0.8.0, deprecated in 2.0.0)

clearEeprom

src/device.js:779-786

Clear EEPROM.

Returns Promise

Meta

  • deprecated: This method is not guaranteed to work with recent versions of Device OS and it will be removed in future versions of this library.

    Supported platforms:

    • Gen 2 (since Device OS 0.8.0, deprecated in 2.0.0)

getEepromSize

src/device.js:799-806

Get size of the EEPROM.

Returns Promise<Number>

Meta

  • deprecated: This method is not guaranteed to work with recent versions of Device OS and it will be removed in future versions of this library.

    Supported platforms:

    • Gen 2 (since Device OS 0.8.0, deprecated in 2.0.0)

addLogHandler

src/device.js:823-878

Add a log handler.

Parameters

  • options Object Options.
    • options.id String Handler ID.
    • options.stream String Output stream: Serial, Serial1, USBSerial1, etc.
    • options.format String? Message format: default, json.
    • options.level String? Default logging level: trace, info, warn, error, none, all.
    • options.filters Array? Category filters.
    • options.baudRate Number? Baud rate.

Returns Promise

Meta

  • deprecated: This method is not guaranteed to work with recent versions of Device OS and it will be removed in future versions of this library.

removeLogHandler

src/device.js:890-892

Remove a log handler.

Parameters

Returns Promise

Meta

  • deprecated: This method is not guaranteed to work with recent versions of Device OS and it will be removed in future versions of this library.

getLogHandlers

src/device.js:902-907

Get the list of active log handlers.

Returns Promise<Array<Object>>

Meta

  • deprecated: This method is not guaranteed to work with recent versions of Device OS and it will be removed in future versions of this library.

unprotectDevice

src/device.js:927-979

Request the device to temporarily disable device protection.

Parameters

  • param Object Parameters.
    • param.action String prepare, confirm or reset.
    • param.serverNonce Buffer? Server nonce. Mandatory if action is prepare.
    • param.serverSignature Buffer? Server signature. Mandatory if action is confirm.
    • param.serverPublicKeyFingerprint Buffer? Fingerprint of the server public key. Mandatory if action is confirm.

Returns Promise<UnprotectDeviceResult>

getProtectionState

src/device.js:992-1003

Check if device protection is enabled.

Returns GetProtectionStateResult

sendProtobufRequest

src/device.js:1013-1036

Sends a protobuf encoded request to Device and decodes response. Use higher level methods like getSerialNumber() than this if possible.

Parameters

  • protobufMessageName String The protobuf message name, see DeviceOSProtobuf.getDefinitions() for valid values.

  • protobufMessageData Object data that will be encoded into the protobuf request before sending to device (optional, default {})

  • opts any See sendControlRequest(), same options are here.

  • Throws RequestError thrown when message isn't supported by device or other USB related failures

Returns Object Depends on schema defined by req.reply

UnprotectDeviceResult

src/device.js:927-979

Type: Object

Properties

  • protected Boolean If true, device protection is enabled.
  • deviceNonce Buffer? Device nonce.
  • deviceSignatute Buffer? Device signature.
  • devicePublicKeyFingerprint Buffer? Fingerprint of the device public key.

GetProtectionStateResult

src/device.js:992-1003

Type: Object

Properties

  • protected Boolean If true, device protection is enabled.
  • overridden Boolean If true, device protection was disabled temporarily.

require

src/device.test.js:6-6

We deliberately don't use fakeUSB in these tests because it mocks out src/device.js which is the object under test in this file. Instead, we take a different mocking strategy that also mocks out USB hardware, but doesn't mock src/device.js.

require

src/wifi-device-legacy.js:9-9

All of the functionality in this class is deprecated. However, it can still be used on Paticle Photon devices running Device OS systems firmware from 0.8.0 to pre 2.0.0.

DfuError

src/dfu.js:26-31

Extends DeviceError

A generic DFU error.

Parameters

  • args ...any

DfuseCommand

src/dfu.js:129-137

DFU with ST Microsystems extensions.

AN3156: USB DFU protocol used in the STM32 bootloader.

open

src/dfu.js:168-176

Open DFU interface.

Returns Promise

close

src/dfu.js:183-187

Close DFU interface.

Returns Promise

leave

src/dfu.js:194-205

Leave DFU mode.

Returns Promise

enterSafeMode

src/dfu.js:212-219

Enter safe mode.

Returns Promise

clearSecurityModeOverride

src/dfu.js:226-230

Re-enable device protection.

Returns Promise

getProtectionState

src/dfu.js:238-259

Get the protection state of the device. A device with protection enabled will have all segments not readable and not writeable.

Returns Promise Object with property 'protected'

setAltSetting

src/dfu.js:267-302

Set the alternate interface for DFU and initialize memory information.

Parameters

  • setting number The alternate interface index to set.

Returns Promise

doDownload

src/dfu.js:315-386

Perform DFU download of binary data to the device.

Parameters

  • options Object Options.
    • options.startAddr number The starting address to write the data.
    • options.data Buffer The binary data to write.
    • options.noErase boolean? Skip erasing the device memory.
    • options.leave boolean? Leave DFU mode after download.
    • options.progress function? Callback function used to log progress.

Returns Promise

_sendDnloadRequest

src/dfu.js:426-434

Sends a download request to the DFU device with the specified request and value. This request is sent via nodeusb or webusb

Parameters

  • data
  • wValue number The value to be sent as part of the request.
  • req Buffer The request data buffer to be sent to the device.

_getStatus

src/dfu.js:463-499

Retrieves the status from the DFU (Device Firmware Upgrade) device.

  • Throws DfuError If parsing the DFU_GETSTATUS response fails or the status/state is invalid.

Returns Promise<object> A Promise that resolves with the status object containing status, pollTimeout, and state.

_pollUntil

src/dfu.js:507-523

Poll until the given statePredicate is true or the device goes into dfuERROR state.

Parameters

  • statePredicate function The function to check the device state.

Returns object The DFU status object after polling.

_clearStatus

src/dfu.js:528-536

Sends the DFU_CLRSTATUS request to the DFU device to clear any error status.

_parseMemoryDescriptor

src/dfu.js:544-586

Parse the memory descriptor string and create a memory map.

Parameters

  • desc string The memory descriptor string.

Returns object Memory map information.

_dfuseCommand

src/dfu.js:596-633

Send a DfuSe command to the DFU device.

Parameters

  • command number The DfuSe command to send.
  • param number Optional. The parameter for the command.
  • len number Optional. The length of the command payload.

Returns Promise

_getSegment

src/dfu.js:641-653

Get the memory segment that contains the given address.

Parameters

  • addr number The address to find the corresponding memory segment.

Returns (object | null) The memory segment containing the address, or null if not found.

_getSectorStart

src/dfu.js:662-673

Get the start address of the sector containing the given address.

Parameters

  • addr number The address to find the corresponding sector start address.
  • segment object Optional. The memory segment containing the address. If not provided, it will be looked up.

Returns number The start address of the sector.

_getSectorEnd

src/dfu.js:682-693

Get the end address of the sector containing the given address.

Parameters

  • addr number The address to find the corresponding sector end address.
  • segment object Optional. The memory segment containing the address. If not provided, it will be looked up.

Returns number The end address of the sector.

_erase

src/dfu.js:703-741

Erases the memory of the DFU device starting from the specified address and for the given length. This method erases memory sectors that are marked as erasable in the memory map.

Parameters

  • startAddr number The starting address of the memory range to be erased.

  • length number The length of the memory range to be erased in bytes.

  • progress

  • Throws Error If the start address or the length is outside the memory map bounds, or if erasing fails.

DeviceError

src/error.js:4-9

Extends Error

Generic device error. This is a base class for all errors reported by the library.

Parameters

  • args ...any

NotFoundError

src/error.js:14-19

Extends DeviceError

An error reported when a requested resource cannot be found.

Parameters

  • args ...any

NotAllowedError

src/error.js:24-29

Extends DeviceError

An error reported when a requested operation is not permitted.

Parameters

  • args ...any

StateError

src/error.js:34-39

Extends DeviceError

An error reported when an object is not in an appropriate state to perform an operation.

Parameters

  • args ...any

TimeoutError

src/error.js:44-49

Extends DeviceError

Timeout error.

Parameters

  • args ...any

MemoryError

src/error.js:54-59

Extends DeviceError

An error reported when a device has no enough memory to perform an operation.

Parameters

  • args ...any

ProtocolError

src/error.js:64-69

Extends DeviceError

Protocol error.

Parameters

  • args ...any

UsbError

src/error.js:74-79

Extends DeviceError

USB error.

Parameters

  • args ...any

InternalError

src/error.js:84-89

Extends DeviceError

Internal error.

Parameters

  • args ...any

RequestError

src/error.js:94-100

Extends DeviceError

Request error.

Parameters

  • result
  • args ...any

UsbStallError

src/error.js:105-110

Extends UsbError

USB stall error.

Parameters

  • args ...any

DeviceProtectionError

src/error.js:115-121

Extends DeviceError

Device Protection error.

Parameters

  • result
  • args ...any

UnsupportedDfuseCommandError

src/error.js:126-131

Extends DeviceError

An error reported when the issued DfuSe command is not supported by the device.

Parameters

  • args ...any

Gen3Device

src/gen3-device.js:11-31

Gen 3 device.

This class is not meant to be instantiated directly. Use getDevices and openDeviceById to create device instances.

Parameters

  • base

NetworkStatus

src/network-device.js:14-17

Network status.

convertInterfaceAddress

src/network-device.js:58-65

Converts a given interface IP address into a string

Parameters

  • ifaceAddr object Object with address and prefixLength keys

Returns string address in ${ip}/${prefixLength} format

convertIpv4Address

src/network-device.js:73-79

Converts an IPv4 to a string

Parameters

  • addr object Object with the IP encoded as int32 in the address key

Returns string address in dotted-decimal format

convertIpv6Address

src/network-device.js:87-93

Converts an IPv6 to a string

Parameters

  • addr object Object with the IP encoded as a buffer in the address key

Returns string address in colon-separated format

NetworkDevice

src/network-device.js:103-255

Network device.

This class is not meant to be instantiated directly. Use getDevices and openDeviceById to create device instances.

Parameters

  • base

getDevices

src/particle-usb.js:22-24

Enumerate Particle USB devices attached to the host.

Parameters

  • options Object Options.
    • options.types Array<String>? Device types (photon, boron, tracker, etc). By default, this function enumerates devices of all platforms supported by the library.
    • options.includeDfu Boolean Whether to include devices in DFU mode. (optional, default true)

Returns Promise<Array<Device>>

openDeviceById

src/particle-usb.js:33-35

Open a Particle USB device with the specified ID.

Parameters

Returns Promise<Device>

openNativeUsbDevice

src/particle-usb.js:44-46

Open a Particle USB device from a native browser or node USB device handle

Parameters

Returns Promise<Device>

fromProtobufEnum

src/protobuf-util.js:11-46

Get an object that maps values from a Protobuf enum value to a string value and vice versa, using the provided mapping.

Parameters

  • pbEnum Object Protobuf enum object, imported from @particle/device-os-protobuf
  • map Object Object where the keys are application strings and values are Protobuf strings
  • unknownVal String? Value to return when the Protobuf value is unknown. Defaults to UNKNOWN

Returns Readonly<{fromProtobuf: ((function (any): (any | string)) | any), toProtobuf: (function (any): any)}> Object with toProtobuf and fromProtobuf functions

extractBits

src/protobuf-util.js:134-150

Checks for each bit in a value and returns an array of strings for each bit that is set

Parameters

  • value The value to check
  • mapping A mapping created by fromProtobufEnum

Returns Array<String> Array of strings for each bit that is set

Result

src/result.js:137-140

Request result codes.

Type: Number

messageForResultCode

src/result.js:148-150

Return a message for the result code.

Parameters

Returns String Error message.

DEVICE_CLASSES

src/set-device-prototype.js:19-39

This constant has a structure like this: // photon: klass {}, // electron: klass {}, // p2: klass {}, // ... // }

setDevicePrototype

src/set-device-prototype.js:50-62

Determines the the class and inheritance hierarchy of a Particle USB device based on it's platform characteristics *

Parameters

  • usbDevice any An object with a .type field that is a string like "p1", "argon", "p2", etc representing the short name of the device platform.

Returns any an instance of a class like WifiDevice, CellularDevice with the correct inheritance hierachy

WifiAntenna

src/wifi-device-legacy.js:16-20

WiFi antenna types.

WifiSecurity

src/wifi-device-legacy.js:25-33

WiFi security types.

WifiCipher

src/wifi-device-legacy.js:38-42

WiFi cipher types.

EapMethod

src/wifi-device-legacy.js:47-50

EAP methods.

WifiDeviceLegacy

src/wifi-device-legacy.js:91-199

Wi-Fi device.

This class is not meant to be instantiated directly. Use getDevices and openDeviceById to create device instances.

Parameters

  • base

WiFiSecurity

src/wifi-device.js:11-19

Wi-Fi security types.

Type: String

WifiDevice

src/wifi-device.js:29-234

Wi-Fi device.

This class is not meant to be instantiated directly. Use getDevices and openDeviceById to create device instances.

Parameters

  • base