All Projects → Jaosrikate → iBeacon-Android

Jaosrikate / iBeacon-Android

Licence: Apache-2.0 license
iBeacon scanner and simulator - Android application example

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to iBeacon-Android

PiBeacon
Low-cost iBeacon using Raspberry Pi
Stars: ✭ 41 (+46.43%)
Mutual labels:  ibeacon, beacon, ibeacon-support, ibeacons
react-native-ibeacon-simulator
Simulate device act as an iBeacon, or transmit as an iBeacon signal from your phone
Stars: ✭ 48 (+71.43%)
Mutual labels:  simulator, ibeacon, beacon, ibeacon-support
React Native Beacons Manager
React-Native library for detecting beacons (iOS and Android)
Stars: ✭ 467 (+1567.86%)
Mutual labels:  ibeacon, beacon
simple beacons flutter
A flutter plugin project to range & monitor iBeacons.
Stars: ✭ 29 (+3.57%)
Mutual labels:  ibeacon, ibeacon-support
React Native Ibeacons
React Native library for detecting beacons (iOS and Android)
Stars: ✭ 9 (-67.86%)
Mutual labels:  ibeacon, beacon
Reactivebeacons
Android library scanning BLE beacons nearby with RxJava
Stars: ✭ 171 (+510.71%)
Mutual labels:  ibeacon, beacon
Android Sdk
Beaconstac ADVANCED SDK for Android devices
Stars: ✭ 18 (-35.71%)
Mutual labels:  ibeacon, beacon
React Native Kontaktio
React Native (iOS and Android) library for Kontakt.io beacons (and all other beacons)
Stars: ✭ 87 (+210.71%)
Mutual labels:  ibeacon, beacon
ios
CoThings's iOS application. CoThings is a realtime counter for shared things.
Stars: ✭ 13 (-53.57%)
Mutual labels:  ibeacon, beacon
Luch
Small and easy to use Android library for BLE beacon monitoring
Stars: ✭ 55 (+96.43%)
Mutual labels:  ibeacon, beacon
win-beacon
Managed BT stack for Windows able to detect and act as an iBeacon.
Stars: ✭ 49 (+75%)
Mutual labels:  ibeacon, beacon
device-simulator
基于netty的设备模拟器,模拟设备消息收发,压力测试。
Stars: ✭ 35 (+25%)
Mutual labels:  simulator
ravel
A RISC-V simulator
Stars: ✭ 24 (-14.29%)
Mutual labels:  simulator
open-simulator
K8s cluster simulator for capacity planning
Stars: ✭ 158 (+464.29%)
Mutual labels:  simulator
mima
MIninmal MAchine Assembler and Simulator
Stars: ✭ 19 (-32.14%)
Mutual labels:  simulator
XWorld
A C++/Python simulator package for reinforcement learning
Stars: ✭ 82 (+192.86%)
Mutual labels:  simulator
rtlsdr-wsprd
WSPR daemon for RTL receivers
Stars: ✭ 93 (+232.14%)
Mutual labels:  beacon
stonne
STONNE: A Simulation Tool for Neural Networks Engines
Stars: ✭ 57 (+103.57%)
Mutual labels:  simulator
cas
Cellular Automata Simulator
Stars: ✭ 22 (-21.43%)
Mutual labels:  simulator
Thunder-Lightning
An Open Source Futuristic Action Flight Simulator Game Inspired By Carrier Command
Stars: ✭ 29 (+3.57%)
Mutual labels:  simulator

iBeacon

Just install the apps in 2 devices for simulated the role of scanner and broadcaster :)

Build from Android Studio 3.5 tested on Xiaomi MI MIX3 and Samsung galaxy S8

App Demo

This app shows the example about iBeacon simulator is a company device (employer) and Scanner is an employee's device that check-in when arrived the area of the company.

iBeacon Simulator - touch the iBeacon stone for start broadcasting

iBeacon Scanner - Click the scan button for scan iBeacon (that broadcasting from this Apps.)

Simulator

Referance Library : https://github.com/AltBeacon/android-beacon-library

//Init beacon device
beacon = new Beacon.Builder()
                .setId1(getString(R.string.beacon_uuid_simulator)) // UUID for beacon
                .setId2(getString(R.string.beacon_major_simulator)) // Major for beacon
                .setId3(getString(R.string.beacon_minor_simulator)) // Minor for beacon
                .setManufacturer(0x004C) // Radius Networks.0x0118  Change this for other beacon layouts//0x004C for iPhone
                .setTxPower(-56) // Power in dB
                .setDataFields(Arrays.asList(new Long[]{0l})) // Remove this for beacon layouts without d: fields
                .build();

Beacon layout list : https://beaconlayout.wordpress.com/

//set iBeacon layout
beaconTransmitter = new BeaconTransmitter (getActivity(), new BeaconParser()
                .setBeaconLayout ("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
//start and stop beacon trasmitter
if (beaconTransmitter.isStarted()) {
    beaconTransmitter.stopAdvertising();
} else {
    beaconTransmitter.startAdvertising(beacon, new AdvertiseCallback() {
      @Override
      public void onStartFailure(int errorCode) {
            Log.e(TAG, "Advertisement start failed with code: " + errorCode);
      }

      @TargetApi(Build.VERSION_CODES.LOLLIPOP)
      @Override
      public void onStartSuccess(AdvertiseSettings settingsInEffect) {
        Log.i(TAG, "Advertisement start succeeded." + settingsInEffect.toString());
      }
    });
}

Scanner

Referance : https://github.com/kiteflo/iBeaconAndroidDemo/

Example Scanner : TimeAttendantFastFragment.java

        btManager = (BluetoothManager) getActivity().getSystemService(Context.BLUETOOTH_SERVICE);
        btAdapter = btManager.getAdapter();
\\init LE scanner for API Level >= 21
        if (Build.VERSION.SDK_INT >= 21) {
            mLEScanner = btAdapter.getBluetoothLeScanner();
            settings = new ScanSettings.Builder()
                    .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
                    .build();
            filters = new ArrayList<>();
        }  
mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    if (Build.VERSION.SDK_INT < 21) {
                        Log.i(TAG, "runnable stop SDK_INT < 21");
                        btAdapter.stopLeScan(leScanCallback);
                    } else {
                        Log.i(TAG, "runnable stop SDK_INT >= 21");
                        mLEScanner.stopScan(mScanCallback);
                    }
                }
            }, SCAN_PERIOD);
if (Build.VERSION.SDK_INT < 21) {
     btAdapter.startLeScan(leScanCallback);
} else {
     mLEScanner.startScan(filters, settings, mScanCallback);
}

Scancallback - Retrieved ScanResult to Byte

    private ScanCallback mScanCallback = new ScanCallback() {
        @Override
        public void onScanResult(int callbackType, ScanResult result) {
            Log.i(TAG, "callbackType " + String.valueOf(callbackType));
            byte[] scanRecord = result.getScanRecord().getBytes();
            findBeaconPattern(scanRecord);
        }

        @Override
        public void onBatchScanResults(List<ScanResult> results) {
            for (ScanResult sr : results) {
                Log.i(TAG, "ScanResult - Results" + sr.toString());
            }
        }

        @Override
        public void onScanFailed(int errorCode) {
            Log.e(TAG, "Scan Failed Error Code: " + errorCode);
        }
    };

LeScanCallback

  private BluetoothAdapter.LeScanCallback leScanCallback = new BluetoothAdapter.LeScanCallback() {
        @Override
        public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] scanRecord) {
            findBeaconPattern(scanRecord);
        }
    };

Find Beacon pattern and Convert to a Beacon profile

private void findBeaconPattern(byte[] scanRecord) {
        int startByte = 2;
        boolean patternFound = false;
        while (startByte <= 5) {
            if (((int) scanRecord[startByte + 2] & 0xff) == 0x02 && //Identifies an iBeacon
                    ((int) scanRecord[startByte + 3] & 0xff) == 0x15) { //Identifies correct data length
                patternFound = true;
                break;
            }
            startByte++;
        }

        if (patternFound) {
            //Convert to hex String
            byte[] uuidBytes = new byte[16];
            System.arraycopy(scanRecord, startByte + 4, uuidBytes, 0, 16);
            String hexString = bytesToHex(uuidBytes);

            //UUID detection
            String uuid = hexString.substring(0, 8) + "-" +
                    hexString.substring(8, 12) + "-" +
                    hexString.substring(12, 16) + "-" +
                    hexString.substring(16, 20) + "-" +
                    hexString.substring(20, 32);

            // major
            final int major = (scanRecord[startByte + 20] & 0xff) * 0x100 + (scanRecord[startByte + 21] & 0xff);

            // minor
            final int minor = (scanRecord[startByte + 22] & 0xff) * 0x100 + (scanRecord[startByte + 23] & 0xff);

            Log.i(TAG, "UUID: " + uuid + "\\nmajor: " + major + "\\nminor" + minor);
        }
    }
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].