-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
83 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,73 @@ | ||
# UDOOBluLib | ||
# UDOOBluLib | ||
|
||
Library for control Udoo Blu board (bluetooth low energy) | ||
(http://http://www.udoo.org/wp-content/uploads/2014/12/logoogo.png) | ||
|
||
# Usage | ||
|
||
*For a working implementation of this project see the `example/`.* | ||
|
||
1. Include the library as local library project or add the dependency in your build.gradle. | ||
repositories { | ||
maven { | ||
url "http://dl.bintray.com/harlem88/maven" | ||
} | ||
} | ||
|
||
... | ||
|
||
dependencies { | ||
compile 'org.udoo:udooblulib:0.1' | ||
} | ||
|
||
2. In your `onCreate` method in Application class, bind the `UdooBluManager`. | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
mUdooBluManager = new UdooBluManager(this); | ||
|
||
} | ||
|
||
public UdooBluManager getBluManager(){ | ||
return mUdooBluManager; | ||
} | ||
|
||
3. Connect ble device: | ||
|
||
mUdooBluManager.connect(address1, new IBleDeviceListener() { | ||
@Override | ||
public void onDeviceConnected() { | ||
udooBluManager.discoveryServices(address1); | ||
} | ||
|
||
@Override | ||
public void onServicesDiscoveryCompleted() { | ||
lunchGloveFragment(address1, address2); | ||
} | ||
|
||
@Override | ||
public void onDeviceDisconnect() { | ||
|
||
} | ||
}); | ||
|
||
4. Enable notification | ||
|
||
udooBluManager.enableSensor(address1, UDOOBLESensor.ACCELEROMETER, true); | ||
udooBluManager.setNotificationPeriod(address1, UDOOBLESensor.ACCELEROMETER); | ||
|
||
5. Listen notification | ||
|
||
udooBluManager.enableNotification(address1, true, UDOOBLESensor.ACCELEROMETER, new OnCharacteristicsListener() { | ||
@Override | ||
public void onCharacteristicsRead(String uuidStr, byte[] value, int status) { | ||
} | ||
|
||
@Override | ||
public void onCharacteristicChanged(String uuidStr, byte[] rawValue) { | ||
Point3D point3D = UDOOBLESensor.ACCELEROMETER.convert(rawValue); | ||
if (point3D != null) | ||
subscriber.onNext(point3D.toFloatArray()); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters