Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5e8b1e4
Support for Eddystone EID and other beacon layouts.
stoneman1 Sep 20, 2017
adf42ed
Fixed package.json from file: deps
stoneman1 Sep 20, 2017
76938b8
Merge remote-tracking branch 'upstream/master'
stoneman1 Sep 21, 2017
21e0a20
Changed react-native versions back to older ones
stoneman1 Sep 21, 2017
dcbf4ea
Deleted default parser. No need to detect iBeacons always
stoneman1 Sep 21, 2017
15131ac
Comments to be up to date. Added nullable to uuid comment
stoneman1 Sep 21, 2017
176a7f3
Updated README.md
stoneman1 Sep 21, 2017
ef40dd0
integrate eddystone to existing RNiBeacon, add example demo of eddyst…
aceisScope Sep 29, 2017
817f6be
remove unused files, update eddystone event names to be the same as i…
aceisScope Oct 2, 2017
de4a5bc
Fixed crashing on EddystoneUID
stoneman1 Oct 2, 2017
5c8dbd6
MonitoringResponse fixed. Now should not crash when uuid is null
stoneman1 Oct 3, 2017
08f5778
enable ios background scanning
aceisScope Oct 6, 2017
5ed4a03
add important comment
aceisScope Oct 6, 2017
1fbe7a7
experiment for background wakeup
aceisScope Oct 11, 2017
36938c2
Add methods to unbind manager to make it possible to rebind if there …
Oct 12, 2017
43836e5
redo monitor test code
aceisScope Oct 12, 2017
f8d8dcc
remove interface in RNEddystone
aceisScope Oct 13, 2017
a265783
Merge remote-tracking branch 'origin/master' into ios-monitor
aceisScope Oct 13, 2017
5e0c8d2
expost all eddystone apis
aceisScope Oct 13, 2017
6d3af50
fix indenting
aceisScope Oct 13, 2017
0955252
only restart eddystone scanning after 3mins from last region entering
aceisScope Oct 16, 2017
3eda5b7
remove RNEddystone since all the necessary codes are in RNiBeacon.m
aceisScope Oct 16, 2017
5d4ca1a
stop background task if app enters foreground
aceisScope Oct 16, 2017
6bcff08
fire bluetooth state change from native code
aceisScope Oct 25, 2017
75874dc
Merge pull request #1 from stoneman1/ios-monitor
stoneman1 Mar 22, 2018
0c0dc94
Send events to react context when state for region determined
May 2, 2018
91e1300
updated altbeacons lib to 2.12+
May 2, 2018
bfba4b6
Merge pull request #2 from stoneman1/did-determine-state-event
MariaSyed May 2, 2018
113bd78
Merge pull request #3 from stoneman1/update-altbeacons-lib
MariaSyed May 2, 2018
65229fc
Make sure BeaconsManager is binded
stoneman1 May 21, 2018
b022bea
Forgot to add writable map
stoneman1 May 21, 2018
b431d20
some merge conflicts or something messed up the ranging result and sh…
stoneman1 May 22, 2018
2c6f0f4
it was still trying to access region
stoneman1 May 22, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,18 @@ DeviceEventEmitter.addListener('beaconsDidRange', (data) => {
|:--------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **detectCustomBeaconLayout(parser: string): void** | Allows the detection of a custom beacon layout. For example `detectCustomBeaconLayout('m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24')` allows you to detect iBeacons beacons. |
| **detectIBeacons(): void** | Allows the detection of iBeacons. It's just like calling detectCustomBeaconLayout with the iBeacons layout. |
| **detectAltBeacons(): void** | Allows the detection of Altbeacons. It's just like calling `detectCustomBeaconLayout` with the Altbeacons layout. |
| **detectEstimotes(): void** | Allows the detection of Estimote beacons. It's just like calling `detectCustomBeaconLayout` with the Estimote layout. |
| **detectEddystoneUID(): void** | Allows the detection of EddystoneUID beacons. It's just like calling `detectCustomBeaconLayout` with the EddystoneUID layout. |
| **detectEddystoneURL(): void** | Allows the detection of EddystoneURL beacons. It's just like calling `detectCustomBeaconLayout` with the EddystoneURL layout. |
| **detectEddystoneTLM(): void** | Allows the detection of EddystoneTLM beacons. It's just like calling `detectCustomBeaconLayout` with the EddystoneTLM layout. |
| **detectEddystoneEID(): void** | Allows the detection of EddystoneEID beacons. It's just like calling `detectCustomBeaconLayout` with the EddystoneEID layout. |
| **bindManager(): promise** | Binds the service (use after detect methods |
| **checkTransmissionSupported(): promise** | Checks if the device can use the Bluetooth to detect the beacons. |
| **setForegroundScanPeriod(period: number): void** | Sets the duration in milliseconds of each Bluetooth LE scan cycle to look for beacons (in foreground). For more info [take a look at the official docs](https://altbeacon.github.io/android-beacon-library/javadoc/index.html) |
| **setBackgroundScanPeriod(period: number): void** | Sets the duration in milliseconds of each Bluetooth LE scan cycle to look for beacons (in background). For more info [take a look at the official docs](https://altbeacon.github.io/android-beacon-library/javadoc/index.html) |
| **setBackgroundBetweenScanPeriod(period: number): void** | Sets the duration in milliseconds spent not scanning between each Bluetooth LE scan cycle when no ranging/monitoring clients are in the foreground. For more info [take a look at the official docs](https://altbeacon.github.io/android-beacon-library/javadoc/index.html) |
| **setRssiFilter(filterType: int, avgModifier: number): void** | Sets the RSSI averaging method. The parameter `filterType` must be one of the exported constants `ARMA_RSSI_FILTER` or `RUNNING_AVG_RSSI_FILTER`. The `avgModifier` param changes the rate of the averaging function For the ARMA filter it's in the range 0.1-1.0, for the running average it's the filter window in milliseconds. For more info [take a look at the docs](https://altbeacon.github.io/android-beacon-library/distance_vs_time.html) |
| **setRssiFilter(filterType: int, avgModifier: number): void** | Sets the RSSI averaging method. The parameter `filterType` must be one of the exported constants `ARMA_RSSI_FILTER` or `RUNNING_AVG_RSSI_FILTER`. The `avgModifier` param changes the rate of the averaging function For the ARMA filter it's in the range 0.1-1.0, for the running average it's the filter window in milliseconds. For more info [take a look at the docs](https://altbeacon.github.io/android-beacon-library/distance_vs_time.html) |
| **setHardwareEqualityEnforced(e: boolean): void** | Configures whether the bluetoothAddress (mac address) must be the same for two Beacons to be configured equal. This setting applies to all beacon instances in the same process. Defaults to false for backward compatibility. Useful when all the beacons you are working with have the same UUID, major and minor (they are only uniquely identifiable by their mac address), otherwise the module will detect all the beacons as if they were only one. For more info [take a look at the official docs](https://altbeacon.github.io/android-beacon-library/javadoc/index.html) |
| **getRangedRegions(): promise** | Returns a promise that resolves in an array with the regions being ranged. |
| **getMonitoredRegions(): promise** | Returns a promise that resolves in an array with the regions being monitored. |
Expand All @@ -196,7 +202,7 @@ DeviceEventEmitter.addListener('beaconsDidRange', (data) => {
- **iOS**
- [ ] add support to Eddystone
- **android**
- [ ] add support to Eddystone
- [x] add support to Eddystone


## license
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ repositories {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.facebook.react:react-native:0.12.+'
compile 'org.altbeacon:android-beacon-library:2.9.2'
compile 'org.altbeacon:android-beacon-library:2.12+'
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.RemoteException;
import android.support.annotation.Nullable;
import android.util.Log;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
Expand Down Expand Up @@ -48,9 +48,6 @@ public BeaconsAndroidModule(ReactApplicationContext reactContext) {
this.mReactContext = reactContext;
this.mApplicationContext = reactContext.getApplicationContext();
this.mBeaconManager = BeaconManager.getInstanceForApplication(mApplicationContext);
// Detect iBeacons ( http://stackoverflow.com/questions/25027983/is-this-the-correct-layout-to-detect-ibeacons-with-altbeacons-android-beacon-li )
addParser("m:0-3=4c000215,i:4-19,i:20-21,i:22-23,p:24-24");
mBeaconManager.bind(this);
}

@Override
Expand All @@ -76,6 +73,16 @@ public void setHardwareEqualityEnforced(Boolean e) {
Beacon.setHardwareEqualityEnforced(e.booleanValue());
}

@ReactMethod
public void bindManager() {
mBeaconManager.bind(this);
}

@ReactMethod
public void unbindManager() {
mBeaconManager.unbind(this);
}

@ReactMethod
public void addParser(String parser) {
mBeaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout(parser));
Expand Down Expand Up @@ -172,6 +179,10 @@ public void onBeaconServiceConnect() {

mBeaconManager.addMonitorNotifier(mMonitorNotifier);
mBeaconManager.addRangeNotifier(mRangeNotifier);

WritableMap params = Arguments.createMap();
params.putString("status", String.valueOf(true));
sendEvent(mReactContext, "bindStatus", params);
}

@Override
Expand All @@ -186,7 +197,8 @@ public void unbindService(ServiceConnection serviceConnection) {

@Override
public boolean bindService(Intent intent, ServiceConnection serviceConnection, int i) {
return mApplicationContext.bindService(intent, serviceConnection, i);
boolean bindStatus = mApplicationContext.bindService(intent, serviceConnection, i);
return bindStatus;
}

/***********************************************************************************************
Expand All @@ -213,24 +225,31 @@ public void startMonitoring(String regionId, String beaconUuid, int minor, int m
private MonitorNotifier mMonitorNotifier = new MonitorNotifier() {
@Override
public void didEnterRegion(Region region) {
Log.d(LOG_TAG, "didEnterRegion");
sendEvent(mReactContext, "regionDidEnter", createMonitoringResponse(region));
}

@Override
public void didExitRegion(Region region) {
Log.d(LOG_TAG, "didExitRegion!");
sendEvent(mReactContext, "regionDidExit", createMonitoringResponse(region));
}

@Override
public void didDetermineStateForRegion(int i, Region region) {

Log.d(LOG_TAG, "didDetermineStateForRegion with " + i);
if (i == MonitorNotifier.INSIDE) {
sendEvent(mReactContext, "regionInside", createMonitoringResponse(region));
} else if ( i == MonitorNotifier.OUTSIDE) {
sendEvent(mReactContext, "regionOutside", createMonitoringResponse(region));
}
}
};

private WritableMap createMonitoringResponse(Region region) {
WritableMap map = new WritableNativeMap();
map.putString("identifier", region.getUniqueId());
map.putString("uuid", region.getId1().toString());
map.putString("uuid", region.getId1() != null ? region.getId1().toString() : "");
map.putInt("major", region.getId2() != null ? region.getId2().toInt() : 0);
map.putInt("minor", region.getId3() != null ? region.getId3().toInt() : 0);
return map;
Expand Down Expand Up @@ -289,8 +308,10 @@ private WritableMap createRangingResponse(Collection<Beacon> beacons, Region reg
for (Beacon beacon : beacons) {
WritableMap b = new WritableNativeMap();
b.putString("uuid", beacon.getId1().toString());
b.putInt("major", beacon.getId2().toInt());
b.putInt("minor", beacon.getId3().toInt());
if (beacon.getIdentifiers().size() > 2) {
b.putInt("major", beacon.getId2() != null ? beacon.getId2().toInt() : 0);
b.putInt("minor", beacon.getId3() != null ? beacon.getId3().toInt() : 0);
}
b.putInt("rssi", beacon.getRssi());
b.putDouble("distance", beacon.getDistance());
b.putString("proximity", getProximity(beacon.getDistance()));
Expand Down
Loading