Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added is connectable from scan result object #1116

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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