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

Add GetScannedInfo event to BLE extension #14

Open
wants to merge 1 commit into
base: extension/bluetoothle
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import java.util.List;
import java.util.Set;

import android.os.Handler;


/**
* @author Andrew McKinney ([email protected])
Expand Down Expand Up @@ -1214,11 +1216,21 @@ public void Disconnected() {
*
* @param rssi the strength of the received signal, from -100 to 0.
*/


//New Event which returns the new scanned deviceID and rssi
@SimpleEvent
public void GetScannedInfo(final String deviceID, final int rssi) {
}


@SimpleEvent(description = "Trigger event when RSSI (Received Signal Strength Indicator) of found" +
" BluetoothLE device changes")
public void RssiChanged(final int rssi) {
}



/**
* The <code>DeviceFound</code> event is run when a new Bluetooth low energy device is found.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,8 @@ public void onScanResult(final int callbackType, final ScanResult scanResult) {
public void run() {
isScanning = true;
addDevice(scanResult.getDevice(), scanResult.getRssi());
//Call GetScannedInfo() function to trigger an event
GetScannedInfo(scanResult.getDevice().getAddress(), scanResult.getRssi());
}
});
}
Expand Down Expand Up @@ -2509,6 +2511,16 @@ public void run() {
});
}

//New method for positioning, which triggers GetScannedInfo event and return the deviceID and Rssi
private void GetScannedInfo(final String deviceID, final int device_rssi) {
uiThread.postDelayed(new Runnable() {
@Override
public void run() {
EventDispatcher.dispatchEvent(outer, "GetScannedInfo", deviceID, device_rssi);
}
}, 1000);
}

private void RssiChanged(final int device_rssi) {
uiThread.postDelayed(new Runnable() {
@Override
Expand Down