Class: DroneConnection

DroneConnection(droneFilter=opt, warmupopt)

Drone connection class

Exposes an api for controlling the drone

Constructor

new DroneConnection(droneFilter=opt, warmupopt)

Creates a new DroneConnection instance

Parameters:
Name Type Attributes Default Description
droneFilter= string <optional>

The drone name leave blank for no filter

warmup boolean <optional>
true

Warmup the command parser

Properties:
Name Type Description
parser CommandParser

CommandParser instance

Source:
Fires:

Members

connected

Source:

logLevel

Set the logger level

Source:
See:

logLevel

Get the logger level

Source:
See:

peripheral

Source:

Methods

_getStep(id) → {number}

used to count the drone command steps

Parameters:
Name Type Description
id string

Step store id

Source:
Returns:
  • step number
Type
number

_setupPeripheral() → {undefined}

Sets up a peripheral and finds all of it's services and characteristics

Source:
Returns:
Type
undefined

ack(packetId)

Acknowledge a packet

Parameters:
Name Type Description
packetId number

Id of the packet to ack

Source:

getCharacteristic(uuid) → {Characteristic}

Finds a Noble Characteristic class for the given characteristic UUID

Parameters:
Name Type Description
uuid String

The characteristics UUID

Source:
Returns:

The Noble Characteristic corresponding to that UUID

Type
Characteristic

getSensor(project, class_, command) → {DroneCommand|undefined}

Get the most recent sensor reading

Parameters:
Name Type Description
project string

Project name

class_ string

Class name

command string

Command name

Source:
See:
Returns:
  • DroneCommand instance or undefined if no sensor reading could be found
Type
DroneCommand | undefined

getSensorFromToken(token) → {DroneCommand|undefined}

Get the most recent sensor reading using the sensor token

Parameters:
Name Type Description
token string

Command token

Source:
See:
Returns:
  • DroneCommand instance or undefined if no sensor reading could be found
Type
DroneCommand | undefined

(async) runCommand(command) → {Promise}

Send a command to the drone and execute it

Parameters:
Name Type Description
command DroneCommand

Command instance to be ran

Source:
Returns:
  • Resolves when the command has been received (if ack is required)
Type
Promise

Events

sensor:

Fires when a new sensor reading has been received

Type:
Source:
Example
connection.on('sensor:minidrone-UsbAccessoryState-GunState', function(sensor) {
 if (sensor.state.value === sensor.state.enum.READY) {
   console.log('The gun is ready to fire!');
 }
});