Constructor
new DroneCommand(project, class_, command)
Creates a new DroneCommand instance
Parameters:
Name | Type | Description |
---|---|---|
project |
object | Project node from the xml spec |
class_ |
object | Class node from the xml spec |
command |
object | Command node from the xml spec |
- Source:
Example
const parser = new CommandParser();
const backFlip = parser.getCommand('minidrone', 'Animations', 'Flip', {direction: 'back'});
const frontFlip = backFlip.clone();
backFlip.direction = 'front';
drone.runCommand(backFlip);
Members
argumentNames
Get the argument names. These names are also mapped to the instance
- Source:
arguments
Array containing the drone arguments
- Source:
bufferFlag
Get the command buffer flag based on it's type
- Source:
bufferType
Get the command buffer type
- Source:
classId
The class id
- Source:
className
The class name
- Source:
commandId
The command id
- Source:
commandName
The command name
- Source:
deprecated
Get if the command has been deprecated
- Source:
description
Get the command description
- Source:
projectId
The project id
- Source:
projectName
The project name (minidrone, common, etc)
- Source:
sendCharacteristicUuid
Get the send characteristic uuid based on the buffer type
- Source:
timeoutAction
Indicates the required action to be taken in case the command times out The value of this attribute can be either POP, RETRY or FLUSH, defaulting to POP
- Source:
Methods
clone() → {DroneCommand}
Clones the instance
- Source:
Returns:
- Cloned instance
- Type
- DroneCommand
getToken() → {string}
Get the token representation of the command. This is useful for registering sensors for example
- Source:
Returns:
- Command token
- Type
- string
Example
const backFlip = parser.getCommand('minidrone', 'Animations', 'Flip', {direction: 'back'});
backFlip.getToken() === 'minidrone-Animations-Flip';
hasArgument(key) → {boolean}
Checks if the command has a certain argument
Parameters:
Name | Type | Description |
---|---|---|
key |
string | Argument name |
- Source:
Returns:
- If the argument exists
- Type
- boolean
hasArguments() → {boolean}
Returns if the command has any arguments
- Source:
Returns:
- command has any arguments
- Type
- boolean
toBuffer() → {Buffer}
Converts the command to it's buffer representation
- Source:
Throws:
TypeError
Returns:
- Command buffer
- Type
- Buffer
toString(debug) → {string}
Returns a string representation of a DroneCommand
Parameters:
Name | Type | Default | Description |
---|---|---|---|
debug |
boolean | false | If extra debug information should be shown |
- Source:
Returns:
- String representation if the instance
- Type
- string
Examples
const str = command.toString();
str === 'minidrone PilotingSettingsState PreferredPilotingModeChanged mode="medium"(1)';
const str = command.toString(true);
str === 'minidrone PilotingSettingsState PreferredPilotingModeChanged (enum)mode="medium"(1)';
Events
connected
Drone connected event You can control the drone once this event has been triggered.
- Source:
disconnected
Drone disconnected event Fired when the bluetooth connection has been disconnected
- Source: