Giter VIP home page Giter VIP logo

android-nrf-blinky's Introduction

nRF Blinky for Android

nRF Blinky is an application targeting an audience of developers who are new to Bluetooth Low Energy.

The app can be easily converted to work with other devices and may act as a template app.

This very simple application contains two basic features:

  • turning on a LED on a connected Bluetooth LE device,
  • receiving a Button press and release events from the device.

Scanner Blinky

It demonstrates how the BleManager class from Android BLE Library library can be used from a View Model (see Architecture Components).

Structure

The new version of nRF Blinky application has been created in Jetpack Compose.

Dependencies

It is using the following libraries:

The gradle script was written in Kotlin Script (gradle.kts) and is using version catalog for dependency management.

Modules

The application consists of the following modules:

  • :app - the main module, contains the application code
  • :scanner - contains the scanner screen destination
  • :blinky:spec - contains the Blinky device specification, e.g. Blinky API or the Service UUID
  • :blinky:ble - contains the BLE related code, e.g. BlinkyManager implementation
  • :blinky:ui - contains the UI related code, e.g. BlinkyScreen or BlinkyViewModel implementation

The :blinky:ui and :blinky:spec modules are transport agnostic. The Bluetooth LE transport is set using Hilt @Binds dependency injection here.

The app is based on :navigation module from the Nordic Common Library, which is using NavHost under the hood, and adds type-safety to the navigation graph.

Each screen defines a DestinationId (with input and output types) and NavigationDestination, which declares the composable, inner navigation or a dialog target. See BlinkyDestination for an example.

Navigation between destinations is done using Navigator object, available using Hilt form a ViewModel. When a new destination is selected, the input parameters are available from SavedStateHandle (see BlinkyModule class).

Nordic LED and Button Service (LBS)

Service UUID: 00001523-1212-EFDE-1523-785FEABCD123

A simplified proprietary service by Nordic Semiconductor, containing two characteristics:

  • LED state (On/Off).

    • UUID: 00001525-1212-EFDE-1523-785FEABCD123
    • Properties: Write or Write Without Response
      • Value: 0x01 => LED On
      • Value: 0x00 => LED Off
  • Button state (Pressed/Released).

    • UUID: 00001524-1212-EFDE-1523-785FEABCD123
    • Properties: Notify
      • Value: 0x01 => Button Pressed
      • Value: 0x00 => Button Released

For documentation for nRF5 SDK, check out this link and for one based on nRF Connect SDK this link.

Requirements

  • This application depends on Android BLE Library.
  • Android 4.3 or newer is required.
  • Any nRF5 DK or another device is required in order to test the BLE Blinky service. The service can also be emulated using nRF Connect for Android, iOS or Desktop.

Installation and usage

Program your device with LED Button sample from nRF5 SDK (blinky sample) or nRF Connect SDK (LBS sample).

The device should appear on the scanner screen after granting required permissions.

Required permissions

On Android 6 - 11 nRF Blinky will ask for Location Permission and Location services. This permission is required on Android in order to obtain Bluetooth LE scan results. The app does not use location in any way and has no Internet permission so can be used safely.

This permission is not required from Android 12 onwards, where new Bluetooth permissions were introduced. The BLUETOOTH_SCAN permission can now be requested with usesPermissionFlags="neverForLocation" parameter, which excludes location related data from the scan results, making requesting location not needed anymore.

android-nrf-blinky's People

Contributors

philips77 avatar roshanrajaratnam avatar robincaroff avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.