npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@particle/device-control-ble-setup-library

v1.0.2

Published

Library that provides interfaces to execute the ble setup of a device

Downloads

19

Readme

@particle/device-control-ble-setup-library

Library that provides interfaces to execute the ble setup of a device

Installation

npm install @particle/device-control-ble-setup-library --save

note: you'll need to be signed into an npm account that is a member of the @particle org (docs)

API

StreamWithCallback

A class to write data to a stream. Extends the EventEmitter class.

Kind: global class


new StreamWithCallback(callback)

Constructor

| Param | Type | Description | | --- | --- | --- | | callback | StreamWithCallback~callback | The callback used to write data. |


streamWithCallback.write(data)

Writes data using a callback.

Kind: instance method of StreamWithCallback

| Param | Type | Description | | --- | --- | --- | | data | Uint8Array | The data to write. |


BLEDevice

A class that implements the BLEDevice interface.

Kind: global class


new BLEDevice(device, uuids, env)

Constructor.

| Param | Type | Description | | --- | --- | --- | | device | Device | Device instance which can be retrieved only by calling bleManager.startDeviceScan(). | | uuids | UUIDs | | | env | Object | |


bleDevice.name : string

The name of the device.

Kind: instance property of BLEDevice


bleDevice.connect(mobileSecret)

Connects to a device using its mobile secret. It first estalishes a connection, and then tries to find the device characteristic based on the UUIDs provided. It then tries to check the protocol version to finally open a control request channel using the mobile secret.

Kind: instance method of BLEDevice

| Param | Type | Description | | --- | --- | --- | | mobileSecret | string | A string of the mobile secret. |


bleDevice.disconnect()

Disconnects from a device closing the control request channel, removing the characteristics and cancelling the device connection.

Kind: instance method of BLEDevice


bleDevice.findCharacteristics(UUIDs)

Finds the characteristics of a mobile's connection service.

Kind: instance method of BLEDevice

| Param | Type | | --- | --- | | UUIDs | UUIDs |


bleDevice.getVersion() ⇒ Promise.<number>

Gets the current protocol version from the read characteristics of the connection.

Kind: instance method of BLEDevice
Returns: Promise.<number> - Promise with a number coming from a decoded base64 input.


bleDevice.checkProtocolVersion()

Checks for the protocol version. If the protocol is different that 2, it throws an error instance of type InvalidProtocolVersionError.

Kind: instance method of BLEDevice


bleDevice.openControlRequestChannel(mobileSecret)

Opens a new control request channel using the mobile's secret.

Kind: instance method of BLEDevice

| Param | Type | | --- | --- | | mobileSecret | string |


bleDevice.closeControlRequestChannel()

Closes a control requested channel.

Kind: instance method of BLEDevice


bleDevice.scanNetworks() ⇒ Promise.<void>

Scans for nearby networks. Filters invalid names and returns unique SSIDs.

Kind: instance method of BLEDevice
Returns: Promise.<void> - Returns a successful promise with the scanned networks.


bleDevice.joinNewNetwork(network, password) ⇒ Promise.<void>

Joins a scanned network.

Kind: instance method of BLEDevice
Returns: Promise.<void> - Returns a successful promise if network was joinable.

| Param | Type | Description | | --- | --- | --- | | network | INetwork | Network interface with information like the SSID and channel. | | password | string | Password to join the network. |


bleDevice.onDisconnect(listener)

Listener function triggered when disconnection happens.

Kind: instance method of BLEDevice

| Param | Type | Description | | --- | --- | --- | | listener | callback | Listener callback that gets executed when disconnecting. |


DeviceRequests

A class for capturing device requests

Kind: global class


new DeviceRequests(requestChannel)

Constructor

| Param | Type | | --- | --- | | requestChannel | * |


deviceRequests.request(RequestClass, ReplyClass, type, requestData) ⇒ Promise.<ReplyType>

Send a connection request.

Kind: instance method of DeviceRequests
Returns: Promise.<ReplyType> - Promise

| Param | Type | | --- | --- | | RequestClass | ProtobufMessage.<ReplyType> | | ReplyClass | ProtobufMessage.<ReplyType> | | type | number | | requestData | RequestType |


deviceRequests.scanNetworks() ⇒ Promise.<Array.<INetwork>>

Scans the nearby networks.

Kind: instance method of DeviceRequests
Returns: Promise.<Array.<INetwork>> - Promise containing the network information


deviceRequests.joinNewNetwork(network, password)

Sends a request to join a new network.

Kind: instance method of DeviceRequests

| Param | Type | Description | | --- | --- | --- | | network | INetwork | INetwork interface | | password | string | |


atob(input) ⇒ string

Decode base64 string into a string

Kind: global function
Returns: string - Decoded string

| Param | Type | Description | | --- | --- | --- | | input | string | Base64 encoded input |


atoi(input) ⇒ number

Decode base64 string into a number

Kind: global function
Returns: number - Decoded number

| Param | Type | Description | | --- | --- | --- | | input | string | Base64 encoded input |


Device : Object

A Device interface

Kind: global typedef


UUIDs : Object

A UUID interface

Kind: global typedef
Properties

| Name | Type | Description | | --- | --- | --- | | serviceUUID | string | The UUID of the service. | | versionCharacteristicUUID | string | The version characteristic UUID of the service. | | rxCharacteristicUUID | string | The receiver characteristic UUID of the service. | | txCharacteristicUUID | string | The transmitter UUID of the service. |


ProtobufMessage : Object

A ProtobufMessage interface

Kind: global typedef
Properties

| Name | Type | | --- | --- | | create | function |


NOTE: Unfortunately, docs have a nasty habit of falling out of date. When in doubt, check usage in tests