- 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
- getEnv
- getEnv
- getEnv
- clearEnv
- clearEnv
- sendProtobufRequest
- UnprotectDeviceResult
- GetProtectionStateResult
- sinon
- 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
- LinuxDevice
- NetworkStatus
- convertInterfaceAddress
- convertIpv4Address
- convertIpv6Address
- NetworkDevice
- getDevices
- openDeviceById
- openNativeUsbDevice
- getEdlDevices
- 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.
optionsObject? 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.
devinfo
Open the device.
optionsObject? Options.options.concurrentRequestsNumber? 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.
optionsObject? Options.
Returns Promise
Send a control request to the device.
typeNumber Request type.data(Buffer | String) Request data.optionsObject? 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.timeoutNumber? 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)
optionsObject? Options. (optional, default{})options.timeoutNumber? 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)
optionsObject? Options. (optional, default{})options.timeoutNumber? 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.
optionsObject? 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)
optionsObject? Options. (optional, default{})options.timeoutNumber? 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)
optionsObject? Options. (optional, default{})options.noReconnectWaitBoolean? 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.timeoutNumber? 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)
optionsObject? Options. (optional, default{})options.timeoutNumber? 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)
optionsObject? Options. (optional, default{})options.timeoutNumber? 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)
optionsObject? Options. (optional, default{})options.timeoutNumber? 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)
optionsObject? Options. (optional, default{})options.timeoutNumber? 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)
optionsObject? Options. (optional, default{})options.timeoutNumber? 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)
optionsObject? Options. (optional, default{})options.timeoutNumber? 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)
$0Object (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')
$0Object (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.
dataBuffer 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.
optionsObject Options.options.idString Handler ID.options.streamString Output stream:Serial,Serial1,USBSerial1, etc.options.formatString? Message format:default,json.options.levelString? Default logging level:trace,info,warn,error,none,all.options.filtersArray? Category filters.options.baudRateNumber? 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.
paramObject Parameters.param.actionStringprepare,confirmorreset.param.serverNonceBuffer? Server nonce. Mandatory ifactionisprepare.param.serverSignatureBuffer? Server signature. Mandatory ifactionisconfirm.param.serverPublicKeyFingerprintBuffer? Fingerprint of the server public key. Mandatory ifactionisconfirm.
Returns Promise<UnprotectDeviceResult>
Check if device protection is enabled.
Returns GetProtectionStateResult
Type: Object
Type: Object
envObject<string, EnvValue> Environment variables.snapshotObject? Snapshot info.snapshot.hashString Snapshot hash.
Get all defined environment variables.
Supported platforms:
- Gen 3 (since Device OS 6.4.0)
- Gen 4 (since Device OS 6.4.0)
Returns Promise<GetEnvResult>
Type: Object
needResetBoolean Iftrue, a system reset is needed to apply the changes.
Clear all defined environment variables.
Supported platforms:
- Gen 3 (since Device OS 6.4.0)
- Gen 4 (since Device OS 6.4.0)
Returns Promise<ClearEnvResult>
Sends a protobuf encoded request to Device and decodes response. Use higher level methods like getSerialNumber() than this if possible.
-
protobufMessageNameString The protobuf message name, see DeviceOSProtobuf.getDefinitions() for valid values. -
protobufMessageDataObject data that will be encoded into the protobuf request before sending to device (optional, default{}) -
optsany 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
protectedBoolean Iftrue, device protection is enabled.deviceNonceBuffer? Device nonce.deviceSignatuteBuffer? Device signature.devicePublicKeyFingerprintBuffer? Fingerprint of the device public key.
Type: Object
protectedBoolean Iftrue, device protection is enabled.overriddenBoolean 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.
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.
settingnumber The alternate interface index to set.
Returns Promise
Perform DFU download of binary data to the device.
optionsObject 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
datawValuenumber The value to be sent as part of the request.reqBuffer 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.
statePredicatefunction 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.
descstring The memory descriptor string.
Returns object Memory map information.
Send a DfuSe command to the DFU device.
commandnumber The DfuSe command to send.paramnumber Optional. The parameter for the command.lennumber Optional. The length of the command payload.
Returns Promise
Get the memory segment that contains the given address.
addrnumber 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.
addrnumber The address to find the corresponding sector start address.segmentobject 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.
addrnumber The address to find the corresponding sector end address.segmentobject 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.
-
startAddrnumber The starting address of the memory range to be erased. -
lengthnumber 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.
resultargs...any
Extends UsbError
USB stall error.
args...any
Extends DeviceError
Device Protection error.
resultargs...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
Extends DeviceBase
Base class for Linux devices.
This class is not meant to be instantiated directly. Use getDevices and openDeviceById to create device instances.
Get the device mode.
Returns Promise<DeviceMode>
Network status.
Converts a given interface IP address into a string
ifaceAddrobject Object with address and prefixLength keys
Returns string address in ${ip}/${prefixLength} format
Converts an IPv4 to a string
addrobject Object with the IP encoded as int32 in the address key
Returns string address in dotted-decimal format
Converts an IPv6 to a string
addrobject 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.
optionsObject Options.
Returns Promise<Array<Device>>
Open a Particle USB device with the specified ID.
idString Device ID.optionsObject? Options (see DeviceBase#open).
Open a Particle USB device from a native browser or node USB device handle
nativeUsbDeviceObject A WebUSB (browser) or node-usb USB deviceoptionsObject? Options (see DeviceBase#open).
Get devices in Qualcomm EDL mode.
Returns Promise<Array<EdlDevice>>
Get an object that maps values from a Protobuf enum value to a string value and vice versa, using the provided mapping.
pbEnumObject Protobuf enum object, imported from @particle/device-os-protobufmapObject Object where the keys are application strings and values are Protobuf stringsunknownValString? 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
valueThe value to checkmappingA 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.
resultNumber Result code.
Returns String Error message.
src/set-device-prototype.js:22-47
This constant has a structure like this: // photon: klass {}, // electron: klass {}, // p2: klass {}, // ... // }
src/set-device-prototype.js:58-70
Determines the the class and inheritance hierarchy of a Particle USB device based on it's platform characteristics *
usbDeviceany 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
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.
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