-
Notifications
You must be signed in to change notification settings - Fork 142
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
84 changed files
with
19,115 additions
and
4,419 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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7,311 changes: 7,311 additions & 0 deletions
7,311
Firmwares/nRF51_SDK11.0.0/ble_app_blinky_s130_pca10028.hex
Large diffs are not rendered by default.
Oops, something went wrong.
9,940 changes: 9,940 additions & 0 deletions
9,940
Firmwares/nRF52_SDK14.2/ble_app_blinky_pca10040_s132.hex
Large diffs are not rendered by default.
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,14 +1,47 @@ | ||
# nRF BLINKY | ||
nRF Blinky is an application developed targeting an audience of developers who are new to Bluetooth Smart. This is a simple application with two basic features to turn on LED 1 on the nRF DK and to recieve the Button 1 press event from a nRF DK on the nRF Blinky Application. | ||
|
||
## Nordic LED Button Service | ||
A simplified LED Button Service proprietary to Nordic Semiconductor, containing two characteristics to turn on the led 1 and to receive the button 1 press event on the nRF Development Kit. | ||
nRF Blinky is an application developed targeting an audience of developers who are new to Bluetooth Low Energy. | ||
This is a very simple application with two basic features to turn on LED 1 on the nRF DK and to recieve the Button 1 press event from a nRF DK on the nRF Blinky Application. | ||
It is a siple example of how to use the **BleManager** class from [Android nRF Blinky](https://github.com/NordicSemiconductor/Android-BLE-Library/) library. | ||
|
||
## Nordic LED and Button Service | ||
|
||
### Note: | ||
Service UUID: `00001523-1212-EFDE-1523-785FEABCD123` | ||
|
||
*Android 4.3 or newer is required. | ||
A simplified proprietary service by Nordic Semiconductor, containing two characteristics one to control LED 3 and Button 1: | ||
|
||
*Tested on Samsung S3 with Android 4.3 and on Nexus 5, 6 and 9 with lollipop and Marshmallow. | ||
- First characteristic controls the LED state (On/Off). | ||
- UUID: **`00001525-1212-EFDE-1523-785FEABCD123`** | ||
- Value: **`1`** => LED On | ||
- Value: **`0`** => LED Off | ||
|
||
*Location Services need to be enabled for scanning from android 6.0 Marshmallow and in addition, runtime persmission ACCESS_COARSE_LOCATION is also required. | ||
- Second characteristic notifies central of the button state on change (Pressed/Released). | ||
- UUID: **`00001524-1212-EFDE-1523-785FEABCD123`** | ||
- Value: **`1`** => Button Pressed | ||
- Value: **`0`** => Button Released | ||
|
||
### Requirements | ||
|
||
* In order to compile the project you have to clone [Android BLE Library](https://github.com/NordicSemiconductor/Android-BLE-Library/) to the same root folder (for example into AndroidstudioProjects). | ||
|
||
* Android 4.3 or newer is required. | ||
|
||
### Installation and usage: | ||
|
||
* Prepare your Development kit. | ||
- Plug in the Development Kit to your computer via USB. | ||
- Power On the Development Kit. | ||
- The Development Kit will now appear as a Mass storage device. | ||
- Drag (or copy/paste) the appropriate HEX file onto that new device. | ||
- The Development Kit lEDS will flash and it will disconnect and reconnect. | ||
- The Development Kit is now ready and flashed with the nRFBlinky example firmware. | ||
|
||
* For your conveninence, we have bundled two firmwares in this project under the Firmwares directory. | ||
|
||
* To get the latest firmwares and check the source code, you may go directly to our [Developers website](http://developer.nordicsemi.com/nRF5_SDK/) and download the SDK version you need, then you can find the source code and hex files to the blinky demo in the directory `/examples/ble_peripheral/ble_app_blinky/`. | ||
|
||
* More information about the nRFBlinky example firmware can be found in the [Infocenter](https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.2.0%2Fble_sdk_app_blinky.html). | ||
|
||
### Note | ||
|
||
* In order to scan for Bluetooth LE device the Location permission must be granted and, on some phones, the Location must be enabled. This app will not use the location information in any way. |
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
105 changes: 105 additions & 0 deletions
105
app/src/main/java/no/nordicsemi/android/blinky/BlinkyActivity.java
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 |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright (c) 2015, Nordic Semiconductor | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* Neither the name of copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
package no.nordicsemi.android.blinky; | ||
|
||
import android.arch.lifecycle.ViewModelProviders; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.widget.LinearLayout; | ||
import android.widget.Switch; | ||
import android.widget.TextView; | ||
|
||
import no.nordicsemi.android.blinky.adapter.ExtendedBluetoothDevice; | ||
import no.nordicsemi.android.blinky.viewmodels.BlinkyViewModel; | ||
|
||
public class BlinkyActivity extends AppCompatActivity { | ||
public static final String EXTRA_DEVICE = "no.nordicsemi.android.blinky.EXTRA_DEVICE"; | ||
|
||
@Override | ||
protected void onCreate(final Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_blinky); | ||
|
||
final Intent intent = getIntent(); | ||
final ExtendedBluetoothDevice device = intent.getParcelableExtra(EXTRA_DEVICE); | ||
final String deviceName = device.getName(); | ||
final String deviceAddress = device.getAddress(); | ||
|
||
final Toolbar toolbar = findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
getSupportActionBar().setTitle(deviceName); | ||
getSupportActionBar().setSubtitle(deviceAddress); | ||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | ||
|
||
// Configure the view model | ||
final BlinkyViewModel viewModel = ViewModelProviders.of(this).get(BlinkyViewModel.class); | ||
viewModel.connect(device); | ||
|
||
// Set up views | ||
final TextView ledState = findViewById(R.id.led_state); | ||
final Switch led = findViewById(R.id.led_switch); | ||
final TextView buttonState = findViewById(R.id.button_state); | ||
final LinearLayout progressContainer = findViewById(R.id.progress_container); | ||
final TextView connectionState = findViewById(R.id.connection_state); | ||
final View content = findViewById(R.id.device_container); | ||
|
||
led.setOnClickListener(view -> viewModel.toggleLED(led.isChecked())); | ||
viewModel.isDeviceReady().observe(this, deviceReady -> { | ||
progressContainer.setVisibility(View.GONE); | ||
content.setVisibility(View.VISIBLE); | ||
}); | ||
viewModel.getConnectionState().observe(this, connectionState::setText); | ||
viewModel.isConnected().observe(this, connected -> { | ||
if (!connected) { | ||
finish(); | ||
} | ||
}); | ||
viewModel.getLEDState().observe(this, isOn -> { | ||
ledState.setText(isOn ? R.string.turn_on : R.string.turn_off); | ||
led.setChecked(isOn); | ||
}); | ||
viewModel.getButtonState().observe(this, pressed -> buttonState.setText(pressed ? R.string.button_pressed : R.string.button_released)); | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(final MenuItem item) { | ||
switch (item.getItemId()) { | ||
case android.R.id.home: | ||
onBackPressed(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
Oops, something went wrong.