The goal of this project is to demonstrate how to communicate with Opper devices produced by Yuanxin Tech.
The following components must be installed in order to go through the Usage Instructions.
- Gradle Build Tool.
- Latest LTS release of the Adoptium OpenJDK.
- Git client.
- Android Studio version 3.1 or later.
- Download this repository extract and copy the oppersdk aar library under /app/libs to your own android project.
- Add required repositories to settings.gradle, looks like bellow:
pluginManagement { repositories { google() mavenCentral() gradlePluginPortal() maven("https://www.jitpack.io") // add this line } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven("https://jitpack.io") // add this line } - Implements the dependencies below:
implementation(files("libs/oppersdk-XXX.aar")) // the oppersdk implementation("com.github.tbruyelle:rxpermissions:0.10.2") implementation("com.neovisionaries:nv-bluetooth:1.8") implementation("io.reactivex.rxjava2:rxjava:2.2.9") implementation("io.reactivex.rxjava2:rxandroid:2.1.1") - Ready to roll
- Create an application class and do some initializing works, make sure to initialize
OpperHelperunder that application context, e.g.OpperHelper.init([application context], new OpperHelper.Weigh() { @Override public int unit() { return Settings.unit; } @Override public int decimalPlaces() { return Settings.decimals; } @Override public double tare() { return Settings.tare; } @Override public void onTareChange(double v) { Settings.tare = v; } @Override public int vibrateGrams() { return Settings.vibrateGrams; } }); - Implements
OpperHelper.OnBleListener, OpperHelper.OnFirmwareListeneron your own Activity class then setup OpperHelper:OpperHelper.setOnBleListener(this); // for the weighing logic OpperHelper.setOnFirmwareListener(this); // for firmware update - Connect Opper device through BLE (Bluetooth Low Energy) technology. Something like bellow:
OpperHelper.connect([replace with your own bluetooth MAC address]) - For more usage, please refer to the demo.