Skip to content

Commit 47b3140

Browse files
committed
Readme and license
1 parent 2f4c1c1 commit 47b3140

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

LICENSE

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Copyright (c) 2015, Nordic Semiconductor
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
* Neither the name of Nordic Semiconductor ASA nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+

README.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Android BLE Library
2+
3+
This library has been extracted from [nRF Toolbox](https://github.com/NordicSemiconductor/Android-nRF-Toolbox)
4+
project. It contains classes useful when doing a connection to a Bluetooth LE device.
5+
6+
### Features
7+
8+
**BleManager** class provides the following features:
9+
10+
1. Connection
11+
2. Service discovery
12+
3. Bonding (optional)
13+
4. Enabling Service Changed indications
14+
5. Device initialization
15+
6. Async BLE operations using queue
16+
7. Reading Battery Level value
17+
8. Requesting MTU and connection priority
18+
9. Error handling
19+
10. Logging (in LogCat and optionally nRF Logger)
20+
21+
It may be used for a single connection (see [nRF Toolbox](https://github.com/NordicSemiconductor/Android-nRF-Toolbox) -> RSC profile)
22+
or when multiple connections are required (see nRF Toolbox -> Proximity profile),
23+
from a Service (see nRF Toolbox -> RSC profile),
24+
ViewModel's repo (see [Architecture Components](https://developer.android.com/topic/libraries/architecture/index.html) and [nRF Blinky](https://github.com/NordicSemiconductor/Android-nRF-Blinky)),
25+
or as a singleton (not recommended, see nRF Toolbox -> HRM).
26+
27+
**BleManager** exposes a high level API instead of low level BLE operations.
28+
If autoConnect option is to be used, the manager also handles initial connection (with autoConnect = false),
29+
which is much faster, and then reconnects in case of link loss with this parameter set to true.
30+
Just return *true* from `shouldAutoConnect()` method in your manager.
31+
32+
### How to include it in your project
33+
34+
Clone this project and add *ble* module as a dependency to your project:
35+
36+
1. In *settings.gradle* file add the following lines:
37+
```groovy
38+
include ':ble'
39+
project(':ble').projectDir = file('../Android-BLE-Library/ble')
40+
```
41+
2. In *app/build.gradle* file add `implementation project(':ble')` inside dependencies.
42+
3. Sync project and build it
43+
44+
See example projects listed below.
45+
46+
### How to use it
47+
48+
1. Define your device API by extending BleManagerCallbacks: [example](https://github.com/NordicSemiconductor/Android-nRF-Blinky/blob/master/app/src/main/java/no/nordicsemi/android/blinky/profile/BlinkyManagerCallbacks.java)
49+
2. Extend BleManager class and implement required methods: [example](https://github.com/NordicSemiconductor/Android-nRF-Blinky/blob/master/app/src/main/java/no/nordicsemi/android/blinky/profile/BlinkyManager.java)
50+
51+
### Example
52+
53+
Find the simple example here [Android nRF Blinky](https://github.com/NordicSemiconductor/Android-nRF-Blinky).
54+
55+
For an example how to use it from an Activity or a Service, check the base Activity and Service classes in [nRF Toolbox](https://github.com/NordicSemiconductor/Android-nRF-Toolbox/tree/master/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile).

0 commit comments

Comments
 (0)