项目作者: bertrandmartel

项目描述 :
Android library interacting with Bixi bluetooth device
高级语言: Kotlin
项目地址: git://github.com/bertrandmartel/bixi-android.git
创建时间: 2017-12-11T20:21:29Z
项目社区:https://github.com/bertrandmartel/bixi-android

开源协议:MIT License

下载


Bixi Android library

CircleCI
License

Bixi library is an Android service receiving gesture events from Bixi Bluetooth devices

Download Bixi library Showcase from Google Play :

Download YoutubeTv library Showcase from Google Play

What is Bixi ?

Bixi is a small bluetooth touch-free controller with built in battery made by Bluemint Labs

bixi

Gestures

List of gesture events :

  • CENTER_TO_TOP
  • CENTER_TO_BOTTOM
  • CENTER_TO_LEFT
  • CENTER_TO_RIGHT
  • LINEAR_END
  • LINEAR_CHANGE (the specific value is given)
  • DOUBLE_TAP

How to include it in your Android project ?

with Gradle, from jcenter or maven central :

  1. compile 'fr.bmartel:bixi-service:1.1'

How to use it ?

Use BixiClient service wrapper :

  • Kotlin example :
  1. class MainActivity : Activity() {
  2. private lateinit var bixiClient: BixiClient
  3. override fun onCreate(savedInstanceState: Bundle?) {
  4. super.onCreate(savedInstanceState)
  5. bixiClient = BixiClient(this, object : IBixiListener {
  6. override fun onServiceConnected() {
  7. Log.v("bixi-lib", "service is connected - ready to receive events")
  8. //start scanning
  9. bixiClient.startScan()
  10. }
  11. override fun onStartScan() {
  12. Log.v("bixi-lib", "scan started")
  13. }
  14. override fun onEndScan() {
  15. Log.v("bixi-lib", "scan stopped")
  16. }
  17. override fun onDeviceDiscovered(device: BtDevice) {
  18. Log.v("bixi-lib", "new Bixi device discovered : " + device.deviceName)
  19. //stop scanning
  20. bixiClient.stopScan()
  21. //connect to this device
  22. bixiClient.connectDevice(device.deviceAddress)
  23. }
  24. override fun onDeviceDisconnected(device: BtDevice) {
  25. Log.v("bixi-lib", "device disconnected : " + device.deviceName)
  26. }
  27. override fun onDeviceConnected(device: BtDevice) {
  28. Log.v("bixi-lib", "device connected : " + device.deviceName)
  29. //set a listener to be notified when a gesture event occur
  30. bixiClient.getDevice(device)!!.setBixiGestureListener(object : IGestureListener {
  31. override fun onGestureChange(event: BixiEvent) {
  32. Log.v("bixi-lib", "received gesture event : " + event.gesture)
  33. }
  34. })
  35. }
  36. override fun onBluetoothOff() {
  37. Log.v("bixi-lib", "bluetooth hasn't been activated (user refused the popup)")
  38. }
  39. override fun onPermissionDenied() {
  40. Log.v("bixi-lib", "location permission was denied (necessary to scan)")
  41. }
  42. })
  43. bixiClient.init(this)
  44. }
  45. override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
  46. super.onRequestPermissionsResult(requestCode, permissions, grantResults)
  47. bixiClient.onRequestPermissionsResult(requestCode, grantResults)
  48. }
  49. }
  • Java example :
  1. public class MainActivity extends Activity {
  2. BixiClient bixiClient;
  3. @Override
  4. protected void onCreate(Bundle savedInstanceState) {
  5. super.onCreate(savedInstanceState);
  6. bixiClient = new BixiClient(this, new IBixiListener() {
  7. @Override
  8. public void onServiceConnected() {
  9. Log.v("bixi-lib", "service is connected - ready to receive events");
  10. //start scanning
  11. bixiClient.startScan();
  12. }
  13. @Override
  14. public void onStartScan() {
  15. Log.v("bixi-lib", "scan started");
  16. }
  17. @Override
  18. public void onEndScan() {
  19. Log.v("bixi-lib", "scan stopped");
  20. }
  21. @Override
  22. public void onDeviceDiscovered(BtDevice device) {
  23. Log.v("bixi-lib", "new Bixi device discovered : " + device.getDeviceName());
  24. //stop scanning
  25. bixiClient.stopScan();
  26. //connect to this device
  27. bixiClient.connectDevice(device.getDeviceAddress());
  28. }
  29. @Override
  30. public void onDeviceDisconnected(BtDevice device) {
  31. Log.v("bixi-lib", "device disconnected : " + device.getDeviceName());
  32. }
  33. @Override
  34. public void onDeviceConnected(BtDevice device) {
  35. Log.v("bixi-lib", "device connected : " + device.getDeviceName());
  36. //set a listener to be notified when a gesture event occur
  37. bixiClient.getDevice(device).setBixiGestureListener(new IGestureListener() {
  38. @Override
  39. public void onGestureChange(BixiEvent event) {
  40. Log.v("bixi-lib", "received gesture event : " + event.getGesture());
  41. }
  42. });
  43. }
  44. @Override
  45. public void onBluetoothOff() {
  46. Log.v("bixi-lib", "bluetooth hasn't been activated (user refused the popup)");
  47. }
  48. @Override
  49. public void onPermissionDenied() {
  50. Log.v("bixi-lib", "location permission was denied (necessary to scan)");
  51. }
  52. });
  53. bixiClient.init(this);
  54. }
  55. @Override
  56. public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
  57. super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  58. bixiClient.onRequestPermissionsResult(requestCode, grantResults);
  59. }
  60. }

In the app module, you can find an example using a Singleton

Requirements

This project require Android SDK 19+

Build Library

Get source code

  1. git clone git@github.com:bertrandmartel/bixi-android.git
  2. cd bixi-android

Build

  1. ./gradlew build

About

License

  1. The MIT License (MIT) Copyright (c) 2017-2018 Bertrand Martel