command-queue


License

License

MIT
GroupId

GroupId

com.high-mobility
ArtifactId

ArtifactId

command-queue
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

aar
Description

Description

command-queue
command-queue
Project URL

Project URL

https://github.com/highmobility/command-queue-android
Source Code Management

Source Code Management

https://github.com/highmobility/command-queue-android

Download command-queue

How to add to project

<!-- https://jarcasting.com/artifacts/com.high-mobility/command-queue/ -->
<dependency>
    <groupId>com.high-mobility</groupId>
    <artifactId>command-queue</artifactId>
    <version>1.1.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.high-mobility/command-queue/
implementation 'com.high-mobility:command-queue:1.1.0'
// https://jarcasting.com/artifacts/com.high-mobility/command-queue/
implementation ("com.high-mobility:command-queue:1.1.0")
'com.high-mobility:command-queue:aar:1.1.0'
<dependency org="com.high-mobility" name="command-queue" rev="1.1.0">
  <artifact name="command-queue" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.high-mobility', module='command-queue', version='1.1.0')
)
libraryDependencies += "com.high-mobility" % "command-queue" % "1.1.0"
[com.high-mobility/command-queue "1.1.0"]

Dependencies

compile (7)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-android-extensions-runtime jar 1.4.10
com.high-mobility : hmkit-android jar 2.0.5
com.high-mobility : hmkit-crypto jar 1.4.6
com.high-mobility : hmkit-utils jar 1.4.5
com.high-mobility : hmkit-auto-api jar 3.12.0
com.google.code.findbugs : jsr305 jar 3.0.2
com.jakewharton.timber : timber jar 4.7.1

Project Modules

There are no modules declared in this project.

Queue can be used to send multiple commands in a row. It is meant to be used as a layer between HMKit and the app, where all link communication is forwarded to the queue. It returns the response commands or failure indications if the commands fail.

See BleCommandQueue or TelematicsCommandQueue for more info about using the queue.

ConnectedLink link;
BleCommandQueue queue;

void sendCommands() {
  queue = new BleCommandQueue(iQueue);
  // get the VehicleStatus and wait for a response before sending OpenGasFlap.
  queue.queue(new VehicleStatus.GetVehicleStatus(), VehicleStatus.State.class);
  // send OpenGasFlap and only wait for the ack, not the GasFlapState response.
  queue.queue(new Fueling.ControlGasFlap(LockState.LOCKED, Position.CLOSED));
  // send HonkAndFlash straight after the OpenGasFlap ack.
  queue.queue(new HonkHornFlashLights.HonkFlash(3, new Duration(3d, Duration.Unit.SECONDS)));
}

// forward all link communication to the queue.

// MARK: LinkListener

@Override
public void onCommandReceived(Link link, Bytes bytes) {
  queue.onCommandReceived(bytes);
}

@Override
public void onLinkLost(ConnectedLink connectedLink) {
  queue.purge;
}

// MARK: CommandQueue

IBleCommandQueue iQueue = new IBleCommandQueue() {
  @Override public void onCommandAck(Command sentCommand) {
    // An ack was received for a queue command.
  }

  @Override public void onCommandReceived(Command command, Command sentCommand) {
    // One of the queue commands got a response.
  }

  @Override public void onCommandFailed(CommandFailure reason, Command sentCommand) {
    // A command failed. All commands in queue are cancelled.
  }

  @Override public void sendCommand(Command command) {
    // Send a queue command via link 
    link.sendCommand(command, new Link.CommandCallback() {
        @Override public void onCommandSent() {
          queue.onCommandSent(command);
        }

        @Override public void onCommandFailed(LinkError linkError) {
          queue.onCommandFailedToSend(command, linkError);
        }
    });
  }
};
com.high-mobility

HIGH MOBILITY

Versions

Version
1.1.0