Skip to content

Commit

Permalink
feat: added is connectable from scan result object
Browse files Browse the repository at this point in the history
  • Loading branch information
gmiszewski-intent committed Oct 13, 2023
1 parent 1d8c26e commit 410ca20
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
1 change: 0 additions & 1 deletion android/src/main/java/com/bleplx/adapter/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.List;
import java.util.UUID;

/** @noinspection unused*/
public class Device {

private String id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
package com.bleplx.adapter.utils.mapper;

import static com.polidea.rxandroidble2.scan.IsConnectable.CONNECTABLE;

import com.bleplx.adapter.AdvertisementData;
import com.bleplx.adapter.ScanResult;
import com.bleplx.adapter.utils.Constants;

public class RxScanResultToScanResultMapper {

public ScanResult map(com.polidea.rxandroidble2.scan.ScanResult rxScanResult) {
return new ScanResult(
rxScanResult.getBleDevice().getMacAddress(),
rxScanResult.getBleDevice().getName(),
rxScanResult.getRssi(),
Constants.MINIMUM_MTU,
false, //isConnectable flag is not available on Android
null, //overflowServiceUUIDs are not available on Android
AdvertisementData.parseScanResponseData(rxScanResult.getScanRecord().getBytes())
);
}
public ScanResult map(com.polidea.rxandroidble2.scan.ScanResult rxScanResult) {
return new ScanResult(
rxScanResult.getBleDevice().getMacAddress(),
rxScanResult.getBleDevice().getName(),
rxScanResult.getRssi(),
Constants.MINIMUM_MTU,
rxScanResult.isConnectable() == CONNECTABLE,
null, //overflowServiceUUIDs are not available on Android
AdvertisementData.parseScanResponseData(rxScanResult.getScanRecord().getBytes())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public WritableMap toJSObject(@NonNull ScanResult scanResult) {
result.putString(Metadata.NAME, scanResult.getDeviceName());
result.putInt(Metadata.RSSI, scanResult.getRssi());
result.putInt(Metadata.MTU, scanResult.getMtu());
result.putBoolean(Metadata.IS_CONNECTABLE, scanResult.isConnectable());

AdvertisementData advData = scanResult.getAdvertisementData();
result.putString(Metadata.MANUFACTURER_DATA,
Expand Down Expand Up @@ -88,7 +89,6 @@ public WritableMap toJSObject(@NonNull ScanResult scanResult) {
}

// Attributes which are not accessible on Android
result.putNull(Metadata.IS_CONNECTABLE);
result.putNull(Metadata.OVERFLOW_SERVICE_UUIDS);
return result;
}
Expand Down

0 comments on commit 410ca20

Please sign in to comment.