Giter VIP home page Giter VIP logo

android-ble's Introduction

Android-BLE

Installation

Add the following to your root build.gradle

   allprojects {
      repositories {
         ...
         maven { url 'https://jitpack.io' }
      }
   }

Add the dependency

   dependencies {
      compile 'com.github.cicdevelopmentnz:Android-BLE:v0.0.4'
   }

Usage

Example Advertisement

{
   "id": "Gateway-Node",
   "messages": [{
      "id": "Gateway-Id",
      "value": "UxayxL"
   }, {
      "id": "Gateway-Key",
      "value": "UDP-123"
   }]
}

Beacon (Peripheral/Advertiser)

Data container

with Map

   Map messages = new HashMap<String, String>();
   messages.put("Gateway-Id", "UxayxL");
   messages.put("Gateway-Key", "UDP-123");   
   Beacon beacon = new Beacon("Gateway-Node", messages);

with Json

   String jsonString = "...example advertisement...";
   Beacon beacon = new Beacon(jsonString);

Beacon Manager

   BeaconManager beaconManager = new BeaconManager(this);
   
   beaconManager.setRange(RANGE_OPTION);
   beaconManager.setFrequency(FREQ_OPTION);

   beaconManager.start().subscribe(
      status -> {
         if(status){
            beaconManager.addBeacon(beacon);
         }else{
            //Failed to start advertising
         }
      }
Frequency Options

Default: AdvertiseSettings.ADVERTISE_MODE_BALANCED

Name
AdvertiseSettings.ADVERTISE_MODE_LOW_POWER
AdvertiseSettings.ADVERTISE_MODE_BALANCED
AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY
Range Options

Default: AdvertiseSettings.ADVERTISE_TX_POWER_LOW

Name
AdvertiseSettings.ADVERTISE_TX_POWER_ULTRA_LOW
AdvertiseSettings.ADVERTISE_TX_POWER_LOW
AvdertiseSettings.ADVERTISE_TX_POWER_MEDIUM
AdvertiseSettings.ADVERTISE_TX_POWER_HIGH

Scanner (Central/Discovery)

   Scanner scanner = new Scanner(this);
   scanner.start().subscribe(
      jsonInfo -> {
         //JSONObject containing raw advertised information
      }
   );

   scanner.startFiltered("Gateway-Node", new String[]{"Gateway-Id", "Gateway-Key"}).subscribe(
      filteredInfo -> {
         //JsonObject containing filtered information
      }
   );

android-ble's People

Contributors

deathslocus avatar jitpack-io avatar larsgrefer avatar pluscubed avatar jawnnypoo avatar

Watchers

James Cloos 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.