Skip to content

aromajoin/controller-sdk-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English / 日本語

Controller SDK for Android

Maven Central License Join the community on Spectrum

The Android version of AromaShooterController library which is used to communicate with Aroma Shooter devices.

Table of Contents

  1. Supported devices
  2. Prerequisites
  3. Installation
  4. Usage
  5. License

Supported devices

  • Aroma Shooter Bluetooth BLE version
  • Aroma Shooter USB version

Prerequisites

  • Android 4.4 and later
  • For USB connection: USB OTG is required

Installation

The Gradle dependency is available via Maven Central.

Please add the controller-sdk dependence in your module's build.gradle file:

dependencies {
    implementation "com.aromajoin.sdk:core:2.5.2"
    implementation "com.aromajoin.sdk:android:2.4.6"
}

Usage

Connect

There are small differences between BLE connection and USB connetion.

Bluetooth BLE

In case you are working with Aroma Shooter via Bluetooth BLE connection. There are 3 options to have connection screen in your application.

  1. Extend ASBaseActivity which has a bar button to go to the default connection Screen
  2. Use Intent to go to the default connection screen normally
  Intent intent = new Intent(YourCurrentActivity.this, ASConnectionActivity.class);  
  startActivity(intent);
  1. Write your own connection part using APIs
    • Get the reference of AndroidBLEController

       AndroidBLEController controller = AndroidBLEController.getInstance(); 
    • Discover

       controller.startScan(context, discoverCallback);

      Don't forget to stop scanning when pause or stop activity/fragment:

       protected void onPause() {
         super.onPause();
         controller.stopScan(context);
       }
    • Connect

       controller.connect(aromaShooter, connectCallback);  
    • Disconnect

       controller.disconnect(aromaShooter, disconnectCallback);  

USB

Note: currently, it can control only 1 Aroma Shooter.

  • Initialize an AndroidUSBController object
    AndroidUSBController controller =  new AndroidUSBController(usbManager);
  • Discover
    controller.scan(discoverCallback);
  • Connect
    controller.connect(aromaShooter. connectCallback);  
  • Disconnect
    controller.disconnect(aromaShooter, disconnectCallback);  

Get connected devices

List<AromaShooter> aromaShooters = controller.getConnectedDevices();

Diffuse scents

/**
 * Diffuses aroma at device's ports.
 *
 * @param duration diffusing duration in milliseconds.
 * @param booster whether booster is used or not.
 * @param ports port numbers to diffuse aroma.
 */
controller.diffuseAll(duration, booster, ports);
  • Diffuse scents method for AS2 (AromaShooter 2) devices only
/**
 * Diffuses aroma at specific ports from all connected devices.
 * @param duration              diffusing duration in milliseconds.
 * @param boosterIntensity      booster port. Value: 0~100.
 * @param fanIntensity          fan port. Value: 0~100.
 * @param ports                 array of ports. Value: Port(portNumber, portIntensity)
 */
controller.diffuseAll(duration, boosterIntensity, fanIntensity, ports);

Stop diffusing

/**
 * Stops all ports of current connected devices if they are diffusing.
 */
controller.stopAllPorts();

/**
 * Stops all ports if they are diffusing aroma.
 *
 * @param aromaShooter device to communicate.
 */
controller.stopAllPorts(AromaShooter aromaShooter);

For more information, please checkout this repository and refer to the sample project.
If you get any issues or require any new features, please create a new issue.

License

Please check the LICENSE file for the details.