- CellularDevice
- CloudConnectionStatus
- ServerProtocol
- CloudDevice
- config
- PollingPolicy
- DeviceBase
- BOOTLOADER
- SYSTEM_PART
- USER_PART
- MONO_FIRMWARE
- NCP_FIRMWARE
- RADIO_STACK
- FirmwareModule
- FirmwareModuleStore
- FirmwareModuleDisplayNames
- DeviceMode
- LogLevel
- Device
- getSerialNumber
- getDeviceId
- reset
- factoryReset
- enterDfuMode
- enterSafeMode
- enterListeningMode
- leaveListeningMode
- getDeviceMode
- startNyanSignal
- stopNyanSignal
- updateFirmware
- getFirmwareModule
- getAssetInfo
- getFirmwareModuleInfo
- hasModularFirmware
- setFactoryFirmware
- getFactoryFirmware
- readConfigData
- writeConfigData
- getConfigDataSize
- readEeprom
- writeEeprom
- clearEeprom
- getEepromSize
- addLogHandler
- removeLogHandler
- getLogHandlers
- unprotectDevice
- getProtectionState
- sendProtobufRequest
- UnprotectDeviceResult
- GetProtectionStateResult
- require
- require
- DfuError
- DfuseCommand
- open
- close
- leave
- enterSafeMode
- clearSecurityModeOverride
- getProtectionState
- setAltSetting
- doDownload
- _sendDnloadRequest
- _getStatus
- _pollUntil
- _clearStatus
- _parseMemoryDescriptor
- _dfuseCommand
- _getSegment
- _getSectorStart
- _getSectorEnd
- _erase
- DeviceError
- NotFoundError
- NotAllowedError
- StateError
- TimeoutError
- MemoryError
- ProtocolError
- UsbError
- InternalError
- RequestError
- UsbStallError
- DeviceProtectionError
- UnsupportedDfuseCommandError
- Gen3Device
- NetworkStatus
- convertInterfaceAddress
- convertIpv4Address
- convertIpv6Address
- NetworkDevice
- getDevices
- openDeviceById
- openNativeUsbDevice
- fromProtobufEnum
- extractBits
- Result
- messageForResultCode
- DEVICE_CLASSES
- setDevicePrototype
- WifiAntenna
- WifiSecurity
- WifiCipher
- EapMethod
- WifiDeviceLegacy
- WiFiSecurity
- WifiDevice
Cellular device.
This class is not meant to be instantiated directly. Use getDevices and openDeviceById to create device instances.
base
Cloud connection status.
Type: String
Disconnected.
Connecting.
Connected.
Disconnecting.
Server protocol types.
Type: String
TCP.
UDP.
Cloud-enabled device.
This class is not meant to be instantiated directly. Use getDevices and openDeviceById to create device instances.
base
Set global options.
options
Object? Options.
Returns Object Current options.
Predefined polling policies.
Type: Function
Default polling policy.
n
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.
dev
info
Open the device.
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 the device.
options
Object? Options.
Returns Promise
Send a control request to the device.
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, defaultPollingPolicy.DEFAULT
)options.timeout
Number? Request timeout. The default timeout can be configured via config.
Returns Promise<Object> Response object.
Perform the system reset.
This method only works in DFU mode.
Returns Promise
Set to true
if the device is open.
Device ID.
This property is set to null
if the device is closed.
Device OS system version.
This property is set to null
if the device is closed or the version could not be determined.
Device type (photon, boron, tracker, etc)
Platform ID
USB vendor ID.
USB product ID.
Set to true
if this device is in the DFU mode.
Internal USB device handle.
Device USB quirks
Bootloader module.
System part module.
User part module.
Monolithic firmware module.
Network co-processor firmware module
Radio stack module
Firmware module types.
Type: String
Firmware module store.
Type: String
Firmware module readable names
Type: String
Device modes.
Type: String
Device is in normal mode.
Device is in listening mode.
Logging levels.
Type: String
Enables logging of all messages.
Enables logging of trace messages.
Enables logging of info messages.
Enables logging of warning messages.
Enables logging of error messages.
Disables logging of any messages.
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.
Get the device's serial number.
Supported platforms:
- Gen 3 (since Device OS 0.9.0)
- Gen 2 (since Device OS 1.5.0)
options
Object? Options. (optional, default{}
)options.timeout
Number? Timeout (milliseconds). (optional, defaultglobalOptions.requestTimeout
)
Get the device's id.
Supported platforms:
- Gen 3 (since Device OS 0.9.0)
- Gen 2 (since Device OS 1.5.0)
options
Object? Options. (optional, default{}
)options.timeout
Number? Timeout (milliseconds). (optional, defaultglobalOptions.requestTimeout
)
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.
options
Object? Options. (optional, default{}
)
Returns Promise
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)
options
Object? Options. (optional, default{}
)options.timeout
Number? Timeout (milliseconds). (optional, defaultglobalOptions.requestTimeout
)
Returns Promise
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)
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, defaultfalse
)options.timeout
Number? Timeout (milliseconds). (optional, defaultglobalOptions.requestTimeout
)
Returns Promise
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)
options
Object? Options. (optional, default{}
)options.timeout
Number? Timeout (milliseconds). (optional, defaultglobalOptions.requestTimeout
)
Returns Promise
Enter listening mode.
Supported platforms:
- Gen 3 (since Device OS 0.9.0)
- Gen 2 (since Device OS 0.8.0)
options
Object? Options. (optional, default{}
)options.timeout
Number? Timeout (milliseconds). (optional, defaultglobalOptions.requestTimeout
)
Returns Promise Resolves when either device is confirmed to be in listening mode, throws an error, or timeout exceeded.
Leave the listening mode.
Supported platforms:
- Gen 3 (since Device OS 0.9.0)
- Gen 2 (since Device OS 0.8.0)
options
Object? Options. (optional, default{}
)options.timeout
Number? Timeout (milliseconds). (optional, defaultglobalOptions.requestTimeout
)
Returns Promise
Get the device mode.
Supported platforms:
- Gen 3 (since Device OS 0.9.0)
- Gen 2 (since Device OS 1.1.0)
options
Object? Options. (optional, default{}
)options.timeout
Number? Timeout (milliseconds). (optional, defaultglobalOptions.requestTimeout
)
Returns Promise<DeviceMode>
Start the Nyan LED indication.
Supported platforms:
- Gen 3 (since Device OS 0.9.0)
- Gen 2 (since Device OS 0.8.0)
options
Object? Options. (optional, default{}
)options.timeout
Number? Timeout (milliseconds). (optional, defaultglobalOptions.requestTimeout
)
Returns Promise
Stop the Nyan LED indication.
Supported platforms:
- Gen 3 (since Device OS 0.9.0)
- Gen 2 (since Device OS 0.8.0)
options
Object? Options. (optional, default{}
)options.timeout
Number? Timeout (milliseconds). (optional, defaultglobalOptions.requestTimeout
)
Returns Promise
Perform the firmware update.
Supported platforms:
- Gen 3 (since Device OS 0.9.0)
- Gen 2 (since Device OS 0.8.0)
Returns Promise
Get firmware module data.
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)
Get asset info.
Supported platforms:
- Gen 3+ (since Device OS 5.6.0)
$0
Object (optional, default{}
)$0.timeout
(optional, defaultglobalOptions.timeout
)
Returns Promise<Array> List of asssets available on the device.
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')
$0
Object (optional, default{}
)$0.timeout
(optional, defaultglobalOptions.requestTimeout
)
Returns Promise<Array> List of modules installed into the device and their dependencies
Check if the device runs a modular firmware.
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)
Set factory firmware.
data
Buffer Firmware data.
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)
Get factory firmware.
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)
Read configuration data.
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)
Write configuration data.
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)
Get size of the configuration data.
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)
Read from EEPROM.
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)
Write to 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)
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)
Get size of the EEPROM.
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)
Add a log handler.
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.
Remove a log handler.
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.
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.
Request the device to temporarily disable device protection.
param
Object Parameters.param.action
Stringprepare
,confirm
orreset
.param.serverNonce
Buffer? Server nonce. Mandatory ifaction
isprepare
.param.serverSignature
Buffer? Server signature. Mandatory ifaction
isconfirm
.param.serverPublicKeyFingerprint
Buffer? Fingerprint of the server public key. Mandatory ifaction
isconfirm
.
Returns Promise<UnprotectDeviceResult>
Check if device protection is enabled.
Returns GetProtectionStateResult
Sends a protobuf encoded request to Device and decodes response. Use higher level methods like getSerialNumber() than this if possible.
-
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
Type: Object
protected
Boolean Iftrue
, device protection is enabled.deviceNonce
Buffer? Device nonce.deviceSignatute
Buffer? Device signature.devicePublicKeyFingerprint
Buffer? Fingerprint of the device public key.
Type: Object
protected
Boolean Iftrue
, device protection is enabled.overridden
Boolean Iftrue
, device protection was disabled temporarily.
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.
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.
Extends DeviceError
A generic DFU error.
args
...any
DFU with ST Microsystems extensions.
AN3156: USB DFU protocol used in the STM32 bootloader.
Open DFU interface.
Returns Promise
Close DFU interface.
Returns Promise
Leave DFU mode.
Returns Promise
Enter safe mode.
Returns Promise
Re-enable device protection.
Returns Promise
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'
Set the alternate interface for DFU and initialize memory information.
setting
number The alternate interface index to set.
Returns Promise
Perform DFU download of binary data to the device.
options
Object Options.
Returns Promise
Sends a download request to the DFU device with the specified request and value. This request is sent via nodeusb or webusb
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.
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.
Poll until the given statePredicate is true or the device goes into dfuERROR state.
statePredicate
function The function to check the device state.
Returns object The DFU status object after polling.
Sends the DFU_CLRSTATUS request to the DFU device to clear any error status.
Parse the memory descriptor string and create a memory map.
desc
string The memory descriptor string.
Returns object Memory map information.
Send a DfuSe command to the DFU device.
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
Get the memory segment that contains the given address.
addr
number The address to find the corresponding memory segment.
Returns (object | null) The memory segment containing the address, or null if not found.
Get the start address of the sector containing the given address.
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.
Get the end address of the sector containing the given address.
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.
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.
-
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.
Extends Error
Generic device error. This is a base class for all errors reported by the library.
args
...any
Extends DeviceError
An error reported when a requested resource cannot be found.
args
...any
Extends DeviceError
An error reported when a requested operation is not permitted.
args
...any
Extends DeviceError
An error reported when an object is not in an appropriate state to perform an operation.
args
...any
Extends DeviceError
Timeout error.
args
...any
Extends DeviceError
An error reported when a device has no enough memory to perform an operation.
args
...any
Extends DeviceError
Protocol error.
args
...any
Extends DeviceError
USB error.
args
...any
Extends DeviceError
Internal error.
args
...any
Extends DeviceError
Request error.
result
args
...any
Extends UsbError
USB stall error.
args
...any
Extends DeviceError
Device Protection error.
result
args
...any
Extends DeviceError
An error reported when the issued DfuSe command is not supported by the device.
args
...any
Gen 3 device.
This class is not meant to be instantiated directly. Use getDevices and openDeviceById to create device instances.
base
Network status.
Converts a given interface IP address into a string
ifaceAddr
object Object with address and prefixLength keys
Returns string address in ${ip}/${prefixLength} format
Converts an IPv4 to a string
addr
object Object with the IP encoded as int32 in the address key
Returns string address in dotted-decimal format
Converts an IPv6 to a string
addr
object Object with the IP encoded as a buffer in the address key
Returns string address in colon-separated format
Network device.
This class is not meant to be instantiated directly. Use getDevices and openDeviceById to create device instances.
base
Enumerate Particle USB devices attached to the host.
options
Object Options.
Returns Promise<Array<Device>>
Open a Particle USB device with the specified ID.
id
String Device ID.options
Object? Options (see DeviceBase#open).
Open a Particle USB device from a native browser or node USB device handle
nativeUsbDevice
Object A WebUSB (browser) or node-usb USB deviceoptions
Object? Options (see DeviceBase#open).
Get an object that maps values from a Protobuf enum value to a string value and vice versa, using the provided mapping.
pbEnum
Object Protobuf enum object, imported from @particle/device-os-protobufmap
Object Object where the keys are application strings and values are Protobuf stringsunknownVal
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
Checks for each bit in a value and returns an array of strings for each bit that is set
value
The value to checkmapping
A mapping created by fromProtobufEnum
Returns Array<String> Array of strings for each bit that is set
Request result codes.
Type: Number
Return a message for the result code.
result
Number Result code.
Returns String Error message.
src/set-device-prototype.js:19-39
This constant has a structure like this: // photon: klass {}, // electron: klass {}, // p2: klass {}, // ... // }
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 *
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
src/wifi-device-legacy.js:16-20
WiFi antenna types.
src/wifi-device-legacy.js:25-33
WiFi security types.
src/wifi-device-legacy.js:38-42
WiFi cipher types.
src/wifi-device-legacy.js:47-50
EAP methods.
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.
base
Wi-Fi security types.
Type: String
Wi-Fi device.
This class is not meant to be instantiated directly. Use getDevices and openDeviceById to create device instances.
base