Git Product home page Git Product logo

ble_server's Introduction

Bluetooth Low Energy Server with BLESSED-ANDROID library (original)

This is the original BLE Peripheral (server) example using the code in https://github.com/weliem/bluetooth-server-example.

The code is minimal changed to get a basis for further enhancements and to be compatible with the sample client-app of the library (see below).

The library in use (BLESSED-ANDROID) is available here: https://github.com/weliem/blessed-android provided by Martijn van Welie.

For a general overview on Bluetooth Low Energy (BLE) see this perfect article: "The Ultimate Guide to Android Bluetooth Low Energy", available as PDF in the docs folder as well: https://punchthrough.com/android-ble-guide/.

Screenshot of the running app after startup:

server_view_after_starting

To check that the server is up and running I recommend to install another app on a second device that allows to connect to the "Server", I'm using nRF Connect for Mobile and it is available on the Google's PlayStore: https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp&hl=de&gl=US. I
provide a simple manual on how to work with the nRF Connect-app here: nRFConnect_manual or my article on Medium: https://medium.com/@androidcrypto/connect-the-android-nrf-connect-mobile-app-with-a-bluetooth-low-energy-device-8ba900d70286

To get the Server app to build you need 2 additional dependencies, add them in build.gradle(app):

    implementation 'com.jakewharton.timber:timber:5.0.1'
    implementation 'com.github.weliem:blessed-android:2.3.4'

Additionally a new line is necessary in the settings.gradle file (project settings):

add the line maven { url 'https://jitpack.io' }:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

You may notice that the AndroidManifest.xml does not contain any Bluetooth related permissions - they are all
set within the library but you are asked to grant some runtime permissions during startup (depending on the Android SDK version running on your Smartphone the server is running on).

Notice regarding a bug in the blessed-library's log system: in BluetoothServer.java you will notice an "error" on line 183 ("Cannot resolve method 'plant(timber.log.Timber.DebugTree)'"):

Timber.plant(new Timber.DebugTree());

This error is filed as a Timber issue and may get corrected in a newer version. The good news is - you can build your app regardless of this "error" and you still see the logged messages in your LogCat.

Important notice when working with an emulated device running on a Smartphone (e.g. the BleServerBlessedOriginal): For security reasons the address the server can get connected is changing very often so when using a client app like the nRF Connect-app it is often necessary to (re)run a scan AND choose the newest entry (mostly the most bottom down one).

Some technical details on this app:

minimum SDK is 21
compiled/target SDK is 33
Gradle version is 7.4

The library blessed-android is MIT-licensed.

ble_server's People

Contributors

androidcrypto avatar michaelsplayground avatar sohnguyen avatar

Watchers

 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.