public final class P_BleManagerImpl extends java.lang.Object implements IBleManager
Modifier and Type | Method and Description |
---|---|
boolean |
ASSERT(boolean condition)
Fires a callback to
AssertListener if condition is false. |
boolean |
ASSERT(boolean condition,
java.lang.String message)
Same as
ASSERT(boolean) but with an added message. |
boolean |
canPerformAutoScan() |
void |
checkIdleStatus() |
void |
clearQueue()
This method will clear the task queue of all tasks.
|
void |
clearScanningRelatedMembers(com.idevicesinc.sweetblue.internal.PA_StateTracker.E_Intent intent) |
void |
clearSharedPreferences()
Clears all data currently being held in
SharedPreferences for all devices. |
void |
clearSharedPreferences(BleDevice device)
Convenience forwarding of
clearSharedPreferences(String) . |
void |
clearSharedPreferences(java.lang.String macAddress)
Clears all data currently being held in
SharedPreferences for a particular device. |
void |
clearShutdownSemaphore() |
void |
clearTimeTurnedOn() |
long |
currentTime() |
void |
disconnectAll_remote()
Same as
disconnectAll() but drills down to BleDevice.disconnect_remote() instead. |
void |
disconnectAll()
Disconnects all devices that are
BleDeviceState.BLE_CONNECTED . |
android.content.Context |
getApplicationContext()
Returns the
Application provided to the constructor. |
BleDevice |
getBleDevice(IBleDevice device) |
BleNode |
getBleNode(IBleNode node) |
BleServer |
getBleServer(IBleServer server) |
BleManagerConfig |
getConfigClone() |
com.idevicesinc.sweetblue.internal.P_BluetoothCrashResolver |
getCrashResolver() |
AddServiceListener |
getDefaultAddServiceListener() |
BondListener |
getDefaultBondListener() |
DeviceConnectListener |
getDefaultDeviceConnectListener() |
DeviceReconnectFilter |
getDefaultDeviceReconnectFilter() |
DeviceStateListener |
getDefaultDeviceStateListener() |
NotificationListener |
getDefaultNotificationListener() |
ReadWriteListener |
getDefaultReadWriteListener() |
ServerConnectListener |
getDefaultServerConnectListener() |
IncomingListener |
getDefaultServerIncomingListener() |
ServerReconnectFilter |
getDefaultServerReconnectFilter() |
ServerStateListener |
getDefaultServerStateListener() |
com.idevicesinc.sweetblue.internal.PA_Task.I_StateListener |
getDefaultTaskStateListener() |
IBleDevice |
getDevice(BleDeviceState state)
Returns the first device that is in the given state, or
BleDevice.NULL if no match is found. |
IBleDevice |
getDevice(int mask_BleDeviceState)
Returns the first device which returns
true for BleDevice.isAny(int) , or BleDevice.NULL if no such device is found. |
IBleDevice |
getDevice(java.lang.Object... query)
Returns the first device that matches the query, or
BleDevice.NULL if no match is found. |
IBleDevice |
getDevice(java.lang.String macAddress)
Gets a known
BleDeviceState.DISCOVERED device by MAC address, or BleDevice.NULL if there is no such device. |
int |
getDeviceCount()
Returns the total number of devices this manager is...managing.
|
int |
getDeviceCount(BleDeviceState state)
Returns the number of devices that are in the current state.
|
int |
getDeviceCount(java.lang.Object... query)
Returns the number of devices that match the given query.
|
IDeviceListener.Factory |
getDeviceListenerFactory() |
com.idevicesinc.sweetblue.internal.P_DeviceManager |
getDeviceManager_cache() |
com.idevicesinc.sweetblue.internal.P_DeviceManager |
getDeviceManager() |
java.lang.String |
getDeviceName(IBluetoothDevice device,
byte[] scanRecord) |
java.util.Set<IBleDevice> |
getDevices_bonded()
Convenience method to return a
Set of currently bonded devices. |
java.util.List<IBleDevice> |
getDevices_List_sorted()
Same as
getDevices_List() , but sorts the list using BleManagerConfig.defaultListComparator . |
java.util.List<IBleDevice> |
getDevices_List_sorted(BleDeviceState state)
Same as
getDevices_List(BleDeviceState) except the list is sorted using BleManagerConfig.defaultListComparator . |
java.util.List<IBleDevice> |
getDevices_List_sorted(int mask_BleDeviceState)
Same as
getDevices_List(int) except the list is sorted using BleManagerConfig.defaultListComparator . |
java.util.List<IBleDevice> |
getDevices_List_sorted(java.lang.Object... query)
Same as
getDevices_List(Object...) except the list is sorted using BleManagerConfig.defaultListComparator . |
java.util.List<IBleDevice> |
getDevices_List() |
java.util.List<IBleDevice> |
getDevices_List(BleDeviceState state) |
java.util.List<IBleDevice> |
getDevices_List(int mask_BleDeviceState) |
java.util.List<IBleDevice> |
getDevices_List(java.lang.Object... query) |
java.util.Iterator<java.lang.String> |
getDevices_previouslyConnected()
Returns the mac addresses of all devices that we know about from both current and previous
app sessions.
|
void |
getDevices(ForEach_Breakable<BleDevice> forEach)
Overload of
getDevices(ForEach_Void)
if you need to break out of the iteration at any point. |
void |
getDevices(ForEach_Breakable<BleDevice> forEach,
BleDeviceState state)
Overload of
getDevices(ForEach_Void, BleDeviceState)
if you need to break out of the iteration at any point. |
void |
getDevices(ForEach_Void<BleDevice> forEach) |
void |
getDevices(ForEach_Void<BleDevice> forEach,
BleDeviceState state)
Same as
getDevices(ForEach_Void) but will only return devices
in the given state provided. |
java.util.List<BleDevice> |
getDevices(android.content.Intent intentFromScan) |
com.idevicesinc.sweetblue.internal.P_DiskOptionsManager |
getDiskOptionsManager() |
Backend_HistoricalDatabase |
getHistoricalDatabase() |
HistoricalDataLoadListener |
getHistoricalDataLoadListener() |
IManagerListener |
getInternalListener() |
AdvertisingListener |
getListener_Advertising() |
DiscoveryListener |
getListener_Discovery()
Returns the discovery listener set with
setListener_Discovery(DiscoveryListener) or
BleManagerConfig.defaultDiscoveryListener , or null if not set. |
OutgoingListener |
getListener_Outgoing() |
P_Logger |
getLogger() |
IManagerListener.Factory |
getManagerListenerFactory() |
android.bluetooth.BluetoothManager |
getNative()
Returns the native manager.
|
android.bluetooth.BluetoothAdapter |
getNativeAdapter()
Returns the native bluetooth adapter.
|
com.idevicesinc.sweetblue.internal.P_BleManagerNativeManager |
getNativeManager() |
com.idevicesinc.sweetblue.internal.P_PostManager |
getPostManager() |
com.idevicesinc.sweetblue.internal.P_ScanManager |
getScanManager() |
IBleServer |
getServer()
Overload of
BleManager.getServer(IncomingListener) without any initial set-up parameters. |
IBleServer |
getServer(GattDatabase gattDatabase)
Overload of
BleManager.getServer(GattDatabase, AddServiceListener) , with no AddServiceListener set. |
IBleServer |
getServer(GattDatabase gattDatabase,
AddServiceListener addServiceListener)
Overload of
BleManager.getServer(IncomingListener, GattDatabase, AddServiceListener) , with no IncomingListener set. |
IBleServer |
getServer(IncomingListener incomingListener)
Returns a
BleServer instance. |
IBleServer |
getServer(IncomingListener incomingListener,
GattDatabase gattDatabase,
AddServiceListener addServiceListener)
Returns a
BleServer instance. |
IServerListener.Factory |
getServerListenerFactory() |
int |
getStateMask()
Returns the abstracted bitwise state mask representation of
BleManagerState for the manager instance. |
com.idevicesinc.sweetblue.internal.P_ManagerStateTracker |
getStateTracker() |
com.idevicesinc.sweetblue.internal.P_TaskManager |
getTaskManager() |
Interval |
getTimeInState(BleManagerState state)
See similar comment for
BleDevice.getTimeInState(BleDeviceState) . |
long |
getUpdateRate() |
com.idevicesinc.sweetblue.internal.P_WakeLockManager |
getWakeLockManager() |
boolean |
hasDevice(IBleDevice device)
Calls
hasDevice(String) . |
boolean |
hasDevice(java.lang.Object... query)
Returns true if we have a device that matches the given query.
|
boolean |
hasDevice(java.lang.String macAddress)
Shortcut for checking if
getDevice(String) returns BleDevice.NULL . |
boolean |
hasDevices() |
boolean |
hasServerInstance() |
boolean |
is(BleManagerState state)
Returns whether the manager is in the provided state.
|
boolean |
isAdvertisingSupported()
Checks to see if the device supports advertising BLE services.
|
boolean |
isAdvertisingSupportedByAndroidVersion()
Checks to see if the device is running an Android OS which supports
advertising.
|
boolean |
isAdvertisingSupportedByChipset()
Checks to see if the device supports advertising.
|
boolean |
isAll(BleManagerState... states)
Returns whether the manager is in all of the provided states.
|
boolean |
isAll(int mask_BleManagerState)
Returns
true if there is complete bitwise overlap between the provided value and getStateMask() . |
boolean |
isAny(BleManagerState... states)
Returns whether the manager is in any of the provided states.
|
boolean |
isAny(int mask_BleManagerState)
Returns
true if there is partial bitwise overlap between the provided value and getStateMask() . |
boolean |
isBleSupported()
Checks the underlying stack to see if BLE is supported on the phone.
|
boolean |
isBluetooth5HighSpeedSupported()
Returns
true if the android device is running Oreo (8.0), and if the hardware supports Bluetooth 5's high speed feature. |
boolean |
isBluetooth5LongRangeSupported()
Returns
true if the android device is running Oreo (8.0), and if the hardware supports Bluetooth 5's long range
feature. |
boolean |
isBluetooth5SupportedByAndroidVersion() |
boolean |
isForegrounded()
Returns this manager's knowledge of the app's foreground state.
|
boolean |
isLocationEnabledForScanning_byManifestPermissions() |
boolean |
isLocationEnabledForScanning_byOsServices() |
boolean |
isLocationEnabledForScanning_byRuntimePermissions() |
boolean |
isLocationEnabledForScanning() |
boolean |
isScanning()
Convenience method which reports
true if the BleManager is in any of the following states: BleManagerState.SCANNING , BleManagerState.SCANNING_PAUSED , BleManagerState.BOOST_SCANNING , or BleManagerState.STARTING_SCAN |
boolean |
isScanningReady() |
IBluetoothManager |
managerLayer() |
IBleDevice |
newDevice(java.lang.String macAddress)
Same as
newDevice(String, String, BleDeviceConfig) but uses an empty string for the name
and passes a null BleDeviceConfig , which results in inherited options from BleManagerConfig . |
IBleDevice |
newDevice(java.lang.String macAddress,
BleDeviceConfig config)
Same as
newDevice(String) but passes a BleDeviceConfig to be used as well. |
IBleDevice |
newDevice(java.lang.String macAddress,
java.lang.String name)
Same as
newDevice(String) but allows a custom name also. |
IBleDevice |
newDevice(java.lang.String macAddress,
java.lang.String name,
BleDeviceConfig config)
Creates a new
BleDevice or returns an existing one if the macAddress matches. |
IBleDevice |
newDevice(java.lang.String macAddress,
java.lang.String name,
byte[] scanRecord,
BleDeviceConfig config) |
HistoricalData |
newHistoricalData(byte[] data,
EpochTime epochTime)
Returns a new
HistoricalData instance using
BleNodeConfig.historicalDataFactory if available. |
HistoricalData |
newHistoricalData(byte[] data,
EpochTime epochTime,
java.lang.String macAddress)
Same as
newHistoricalData(byte[], EpochTime) but tries to use
BleNode.newHistoricalData(byte[], EpochTime) if we have a device
matching the given mac address. |
IBluetoothDevice |
newNativeDevice(java.lang.String macAddress) |
void |
nukeBle()
Similar to
BleManager.reset() , only this also calls the factoryReset method hidden in BluetoothAdapter after turning
off BLE, and running the crash resolver. |
void |
nukeBle(ResetListener resetListener)
Similar to
BleManager.reset(ResetListener) , only this also calls the factoryReset method hidden in BluetoothAdapter after turning
off BLE, and running the crash resolver. |
void |
onDiscovered_fromRogueAutoConnect(IBleDevice device,
boolean newlyDiscovered,
java.util.List<java.util.UUID> services_nullable,
byte[] scanRecord_nullable,
int rssi) |
void |
onDiscoveredFromNativeStack(java.util.List<com.idevicesinc.sweetblue.internal.P_ScanManager.DiscoveryEntry> entries) |
void |
onPause()
It's generally recommended to call this in your override of
Activity.onPause() for each Activity
in your application. |
void |
onResume()
Opposite of
onPause() , to be called from your override of Activity.onResume() for each Activity
in your application. |
void |
popWakeLock()
Opposite of
pushWakeLock() , eventually calls PowerManager.WakeLock.release() . |
void |
postEvent(GenericListener_Void listener,
Event event) |
void |
pushWakeLock()
Requires the
Manifest.permission.WAKE_LOCK permission. |
boolean |
ready() |
void |
removeAllDevicesFromCache()
Removes all
BleDevice s from SweetBlue's internal device cache list. |
void |
removeDeviceFromCache(IBleDevice device)
Removes the given
BleDevice from SweetBlue's internal device cache list. |
void |
reset()
This is essentially a big red reset button for the Bluetooth stack.
|
void |
reset(ResetListener listener)
Same as
reset() but with a convenience callback for when the reset is
completed and the native BLE stack is (should be) back to normal. |
void |
setConfig(BleManagerConfig config_nullable) |
void |
setListener_Advertising(AdvertisingListener listener)
Set a listener here to be notified of the result of starting to advertise.
|
void |
setListener_Assert(AssertListener listener_nullable)
Set a listener here to be notified whenever
ASSERT(boolean) fails. |
void |
setListener_Bond(BondListener listener_nullable)
Convenience method to set a default back up listener for all
BondListener.BondEvent s across all BleDevice instances. |
void |
setListener_DeviceConnect(DeviceConnectListener listener_nullable) |
void |
setListener_DeviceReconnect(DeviceReconnectFilter listener_nullable)
Convenience method to handle connection fail events at the manager level.
|
void |
setListener_DeviceState(DeviceStateListener listener_nullable)
Convenience method to listen for all changes in
BleDeviceState for all devices. |
void |
setListener_Discovery(DiscoveryListener listener_nullable)
Set a listener here to be notified whenever a
BleDevice is discovered, rediscovered, or undiscovered. |
void |
setListener_HistoricalDataLoad(HistoricalDataLoadListener listener_nullable)
Sets a default backup
HistoricalDataLoadListener that will be invoked
for all historical data loads to memory for all uuids for all devices. |
void |
setListener_Incoming(IncomingListener listener_nullable)
Convenience method to handle server request events at the manager level.
|
void |
setListener_Notification(NotificationListener listener_nullable) |
void |
setListener_Outgoing(OutgoingListener listener_nullable)
Convenience method to listen for completion of all outgoing messages from
BleServer instances. |
void |
setListener_Read_Write(ReadWriteListener listener_nullable)
Sets a default backup
ReadWriteListener that will be called for all BleDevice instances. |
void |
setListener_ServerConnect(ServerConnectListener listener_nullable)
Convenience method to listener for all server connections.
|
void |
setListener_ServerReconnectFilter(ServerReconnectFilter listener_nullable)
Convenience method to handle server connection fail events at the manager level.
|
void |
setListener_ServerState(ServerStateListener listener_nullable)
Convenience method to listen for all changes in
BleServerState for all servers. |
void |
setListener_ServiceAdd(AddServiceListener listener_nullable)
Convenience method to listen for all service addition events for all servers.
|
void |
setListener_State(ManagerStateListener listener_nullable)
Set a listener here to be notified whenever this manager's
BleManagerState changes. |
void |
setListener_TaskState(com.idevicesinc.sweetblue.internal.PA_Task.I_StateListener listener) |
void |
setListener_UhOh(UhOhListener listener_nullable) |
void |
shutdown()
Disconnects all devices, shuts down the BleManager, and it's backing thread, and unregisters any receivers that may be in use.
|
boolean |
startScan(ScanOptions options) |
void |
stopScan() |
void |
stopScan(com.idevicesinc.sweetblue.internal.PA_StateTracker.E_Intent intent) |
void |
stopScan(android.app.PendingIntent pendingIntent) |
void |
stopScan(ScanFilter filter) |
double |
timeForegrounded() |
long |
timeTurnedOn() |
java.lang.String |
toString() |
void |
tryPurgingStaleDevices(double scanTime) |
void |
turnOff()
Disables BLE if manager is
BleManagerState.ON . |
void |
turnOn()
Enables BLE if manager is currently
BleManagerState.OFF or BleManagerState.TURNING_OFF , otherwise does nothing. |
void |
turnOnLocationWithIntent_forOsServices(android.app.Activity callingActivity)
Overload of
turnOnLocationWithIntent_forOsServices(Activity, int) if you don't care about result. |
void |
turnOnLocationWithIntent_forOsServices(android.app.Activity callingActivity,
int requestCode) |
void |
turnOnLocationWithIntent_forPermissions(android.app.Activity callingActivity,
int requestCode)
If
isLocationEnabledForScanning_byOsServices() returns false , you can use this method to allow the user to enable location
through an OS intent. |
void |
turnOnWithIntent(android.app.Activity callingActivity,
int requestCode)
Convenience method to request your user to enable ble in a "standard" way
with an
Intent instead of using turnOn() directly. |
void |
uhOh(UhOhListener.UhOh reason) |
void |
unbondAll()
Removes bonds for all devices that are
BleDeviceState.BONDED . |
boolean |
undiscover(IBleDevice device) |
void |
undiscoverAll()
Undiscovers all devices that are
BleDeviceState.DISCOVERED . |
void |
update(double timeStep_seconds,
long currentTime)
This method is made public in case you want to tie the library in to an update loop
from another codebase.
|
boolean |
willLocationPermissionSystemDialogBeShown(android.app.Activity callingActivity)
Returns
true if turnOnLocationWithIntent_forPermissions(Activity, int) will pop a system dialog, false if it will bring
you to the OS's Application Settings. |
public final void setConfig(BleManagerConfig config_nullable)
public final BleManagerConfig getConfigClone()
public final boolean isAny(BleManagerState... states)
public final boolean isAll(BleManagerState... states)
isAny(BleManagerState...)
public final boolean is(BleManagerState state)
isAny(BleManagerState...)
public final boolean isAny(int mask_BleManagerState)
true
if there is partial bitwise overlap between the provided value and getStateMask()
.isAll(int)
public final boolean isAll(int mask_BleManagerState)
true
if there is complete bitwise overlap between the provided value and getStateMask()
.isAny(int)
public final Interval getTimeInState(BleManagerState state)
BleDevice.getTimeInState(BleDeviceState)
.BleDevice.getTimeInState(BleDeviceState)
public final boolean isBleSupported()
public final boolean isAdvertisingSupportedByAndroidVersion()
public final boolean isAdvertisingSupportedByChipset()
public final boolean isAdvertisingSupported()
public final boolean isBluetooth5SupportedByAndroidVersion()
public final boolean isBluetooth5LongRangeSupported()
true
if the android device is running Oreo (8.0), and if the hardware supports Bluetooth 5's long range
feature.public final boolean isBluetooth5HighSpeedSupported()
true
if the android device is running Oreo (8.0), and if the hardware supports Bluetooth 5's high speed feature.public final void turnOff()
BleManagerState.ON
. This disconnects all current
connections, stops scanning, and forgets all discovered devices.public final android.bluetooth.BluetoothManager getNative()
public final android.bluetooth.BluetoothAdapter getNativeAdapter()
public final void setListener_HistoricalDataLoad(HistoricalDataLoadListener listener_nullable)
HistoricalDataLoadListener
that will be invoked
for all historical data loads to memory for all uuids for all devices.public final void setListener_UhOh(UhOhListener listener_nullable)
public final void setListener_Assert(AssertListener listener_nullable)
ASSERT(boolean)
fails.
Mostly for use by internal library developers.public final void setListener_Discovery(DiscoveryListener listener_nullable)
BleDevice
is discovered, rediscovered, or undiscovered.public final DiscoveryListener getListener_Discovery()
setListener_Discovery(DiscoveryListener)
or
BleManagerConfig.defaultDiscoveryListener
, or null
if not set.public final void setListener_State(ManagerStateListener listener_nullable)
BleManagerState
changes.public final void setListener_DeviceState(DeviceStateListener listener_nullable)
BleDeviceState
for all devices.
The listener provided will get called in addition to and after the listener, if any, provided
to BleDevice.setListener_State(DeviceStateListener)
.public final void setListener_ServerReconnectFilter(ServerReconnectFilter listener_nullable)
BleServer.setListener_ReconnectFilter(ServerReconnectFilter)
. This is unlike the behavior
behind (for example) setListener_ServerState(ServerStateListener)
because
ReconnectFilter.onConnectFailed(ReconnectFilter.ConnectFailEvent)
requires a return value.public final void setListener_ServerConnect(ServerConnectListener listener_nullable)
BleServer
. However, in the case we extend that in the future, this will be here.public final void setListener_Incoming(IncomingListener listener_nullable)
BleServer.setListener_Incoming(IncomingListener)
. This is unlike the behavior (for example)
behind setListener_Outgoing(OutgoingListener)
because
IncomingListener.onEvent(IncomingListener.IncomingEvent)
requires a return value.public final void setListener_ServiceAdd(AddServiceListener listener_nullable)
BleServer.setListener_ServiceAdd(AddServiceListener)
.public final void setListener_ServerState(ServerStateListener listener_nullable)
BleServerState
for all servers.
The listener provided will get called in addition to and after the listener, if any, provided
to BleServer.setListener_State(ServerStateListener)
.public final void setListener_Outgoing(OutgoingListener listener_nullable)
BleServer
instances. The listener provided will get called in addition to and after the listener, if any, provided
to BleServer.setListener_Outgoing(OutgoingListener)
.public final void setListener_DeviceReconnect(DeviceReconnectFilter listener_nullable)
BleDevice.setListener_Reconnect(DeviceReconnectFilter)
, the return value of that one will be used
internally by SweetBlue for that BleDevice
(but the event will still be pumped to the listener provided here).public final void setListener_DeviceConnect(DeviceConnectListener listener_nullable)
public final void setListener_Bond(BondListener listener_nullable)
BondListener.BondEvent
s across all BleDevice
instances.public final void setListener_Read_Write(ReadWriteListener listener_nullable)
ReadWriteListener
that will be called for all BleDevice
instances.
public final void setListener_Notification(NotificationListener listener_nullable)
public final void setListener_Advertising(AdvertisingListener listener)
public final void setListener_TaskState(com.idevicesinc.sweetblue.internal.PA_Task.I_StateListener listener)
public final com.idevicesinc.sweetblue.internal.PA_Task.I_StateListener getDefaultTaskStateListener()
public final boolean startScan(ScanOptions options)
public final void pushWakeLock()
Manifest.permission.WAKE_LOCK
permission. Gives you access to the internal
wake lock as a convenience and eventually calls PowerManager.WakeLock.acquire()
.BleManagerConfig.manageCpuWakeLock
public final void popWakeLock()
pushWakeLock()
, eventually calls PowerManager.WakeLock.release()
.public final boolean ASSERT(boolean condition)
AssertListener
if condition is false. Will post a Log.ERROR
-level
message with a stack trace to the console as well if BleManagerConfig.loggingOptions
is not LogOptions.OFF
.public final boolean ASSERT(boolean condition, java.lang.String message)
ASSERT(boolean)
but with an added message.public final int getStateMask()
BleManagerState
for the manager instance.BleManagerState
public final void turnOn()
BleManagerState.OFF
or BleManagerState.TURNING_OFF
, otherwise does nothing.
For a convenient way to ask your user first see turnOnWithIntent(android.app.Activity, int)
.public final void reset()
turnOff()
then turnOn()
,
but also does other things like removing all bonds (similar to unbondAll()
) and
other "special sauce" such that you should use this method instead of trying to reset the
stack manually with component calls.
BleManagerState.RESETTING
public final void reset(ResetListener listener)
reset()
but with a convenience callback for when the reset is
completed and the native BLE stack is (should be) back to normal.BleManagerState.RESETTING
public final void nukeBle()
BleManager.reset()
, only this also calls the factoryReset method hidden in BluetoothAdapter
after turning
off BLE, and running the crash resolver. It's not clear what this method does, hence why this is marked as being experimental.reset()
public final void nukeBle(ResetListener resetListener)
BleManager.reset(ResetListener)
, only this also calls the factoryReset method hidden in BluetoothAdapter
after turning
off BLE, and running the crash resolver. It's not clear what this method does, hence why this is marked as being experimental.reset(ResetListener)
public final void unbondAll()
BleDeviceState.BONDED
.
Essentially a convenience method for calling BleDevice.unbond()
,
on each device individually.public final void disconnectAll()
BleDeviceState.BLE_CONNECTED
.
Essentially a convenience method for calling BleDevice.disconnect()
,
on each device individually.public final void disconnectAll_remote()
disconnectAll()
but drills down to BleDevice.disconnect_remote()
instead.public final void undiscoverAll()
BleDeviceState.DISCOVERED
.
Essentially a convenience method for calling BleDevice.undiscover()
,
on each device individually.public final void turnOnLocationWithIntent_forOsServices(android.app.Activity callingActivity, int requestCode)
public final void turnOnLocationWithIntent_forOsServices(android.app.Activity callingActivity)
turnOnLocationWithIntent_forOsServices(Activity, int)
if you don't care about result.BluetoothEnabler
public final boolean willLocationPermissionSystemDialogBeShown(android.app.Activity callingActivity)
true
if turnOnLocationWithIntent_forPermissions(Activity, int)
will pop a system dialog, false
if it will bring
you to the OS's Application Settings. The true
case happens if the app has never shown a request Location Permissions dialog or has shown a request Location Permission dialog and the user has yet to select "Never ask again". This method is used to weed out the false
negative from Activity.shouldShowRequestPermissionRationale(String)
when the Location Permission has never been requested. Make sure to use this in conjunction with isLocationEnabledForScanning_byRuntimePermissions()
which will tell you if permissions are already enabled.BluetoothEnabler
public final void turnOnLocationWithIntent_forPermissions(android.app.Activity callingActivity, int requestCode)
isLocationEnabledForScanning_byOsServices()
returns false
, you can use this method to allow the user to enable location
through an OS intent. The result of the request (i.e. what the user chose) is passed back through Activity.onRequestPermissionsResult(int, String[], int[])
with the requestCode provided as the second parameter to this method. If the user selected "Never ask again" the function will open up the app settings screen where the
user can navigate to enable the permissions.public final boolean isScanningReady()
public final boolean isScanning()
true
if the BleManager
is in any of the following states: BleManagerState.SCANNING
, BleManagerState.SCANNING_PAUSED
, BleManagerState.BOOST_SCANNING
, or BleManagerState.STARTING_SCAN
public final boolean isLocationEnabledForScanning()
public final boolean isLocationEnabledForScanning_byManifestPermissions()
public final boolean isLocationEnabledForScanning_byRuntimePermissions()
public final boolean isLocationEnabledForScanning_byOsServices()
public final void turnOnWithIntent(android.app.Activity callingActivity, int requestCode)
Intent
instead of using turnOn()
directly.
Result will be posted as normal to Activity.onActivityResult(int, int, Intent)
.
If current state is BleManagerState.ON
or BleManagerState.TURNING_ON
this method early outs and does nothing.BluetoothEnabler
public final void onResume()
public final void onPause()
Activity.onPause()
for each Activity
in your application. This doesn't do much for now, just a little bookkeeping and stops scan automatically if
BleManagerConfig.stopScanOnPause
is true
. Strictly speaking you don't *have* to call this method,
but another good reason is for future-proofing. Later releases of this library may do other more important things
in this method so it's good to have it being called just in case.public final void shutdown()
BleManager.get(Context)
, or BleManager.get(Context, BleManagerConfig)
again.BleManagerConfig.blockingShutdown
public final void clearShutdownSemaphore()
public final android.content.Context getApplicationContext()
Application
provided to the constructor.public final void stopScan()
public final void stopScan(ScanFilter filter)
public final void stopScan(android.app.PendingIntent pendingIntent)
public final IBleDevice getDevice(java.lang.String macAddress)
BleDeviceState.DISCOVERED
device by MAC address, or BleDevice.NULL
if there is no such device.public final boolean hasDevice(java.lang.String macAddress)
getDevice(String)
returns BleDevice.NULL
.public final boolean hasDevice(IBleDevice device)
hasDevice(String)
.public final IBleDevice getDevice(BleDeviceState state)
BleDevice.NULL
if no match is found.public final IBleDevice getDevice(java.lang.Object... query)
BleDevice.NULL
if no match is found.
See BleDevice.is(Object...)
for the query format.public final boolean hasDevice(java.lang.Object... query)
BleDevice.is(Object...)
for the query format.public final IBleDevice getDevice(int mask_BleDeviceState)
true
for BleDevice.isAny(int)
, or BleDevice.NULL
if no such device is found.public final java.util.List<BleDevice> getDevices(android.content.Intent intentFromScan)
public final void getDevices(ForEach_Void<BleDevice> forEach)
public final void getDevices(ForEach_Void<BleDevice> forEach, BleDeviceState state)
getDevices(ForEach_Void)
but will only return devices
in the given state provided.public final void getDevices(ForEach_Breakable<BleDevice> forEach)
getDevices(ForEach_Void)
if you need to break out of the iteration at any point.public final void getDevices(ForEach_Breakable<BleDevice> forEach, BleDeviceState state)
getDevices(ForEach_Void, BleDeviceState)
if you need to break out of the iteration at any point.public final java.util.Iterator<java.lang.String> getDevices_previouslyConnected()
public final java.util.Set<IBleDevice> getDevices_bonded()
Set
of currently bonded devices. This simply calls
BluetoothAdapter.getBondedDevices()
, and wraps all bonded devices into separate
BleDevice
classes.
NOTE: If the Bluetooth radio is turned off, some android devices return null
. In this case,
SweetBlue will just return an empty list.
public final java.util.List<IBleDevice> getDevices_List()
public final java.util.List<IBleDevice> getDevices_List_sorted()
getDevices_List()
, but sorts the list using BleManagerConfig.defaultListComparator
.public final int getDeviceCount()
BleDeviceState.DISCOVERED
.public final int getDeviceCount(BleDeviceState state)
public final int getDeviceCount(java.lang.Object... query)
BleDevice.is(Object...)
for the query format.public final boolean hasDevices()
public final java.util.List<IBleDevice> getDevices_List(BleDeviceState state)
public final java.util.List<IBleDevice> getDevices_List_sorted(BleDeviceState state)
getDevices_List(BleDeviceState)
except the list is sorted using BleManagerConfig.defaultListComparator
.public final java.util.List<IBleDevice> getDevices_List(java.lang.Object... query)
public final java.util.List<IBleDevice> getDevices_List_sorted(java.lang.Object... query)
getDevices_List(Object...)
except the list is sorted using BleManagerConfig.defaultListComparator
.public final java.util.List<IBleDevice> getDevices_List(int mask_BleDeviceState)
public final java.util.List<IBleDevice> getDevices_List_sorted(int mask_BleDeviceState)
getDevices_List(int)
except the list is sorted using BleManagerConfig.defaultListComparator
.public final void removeDeviceFromCache(IBleDevice device)
BleDevice
from SweetBlue's internal device cache list. You should never have to call this
yourself (and probably shouldn't), but it's here for flexibility.public final void removeAllDevicesFromCache()
BleDevice
s from SweetBlue's internal device cache list. You should never have to call this
yourself (and probably shouldn't), but it's here for flexibility.public final HistoricalData newHistoricalData(byte[] data, EpochTime epochTime)
HistoricalData
instance using
BleNodeConfig.historicalDataFactory
if available.public final HistoricalData newHistoricalData(byte[] data, EpochTime epochTime, java.lang.String macAddress)
newHistoricalData(byte[], EpochTime)
but tries to use
BleNode.newHistoricalData(byte[], EpochTime)
if we have a device
matching the given mac address.public final IBleServer getServer()
BleManager.getServer(IncomingListener)
without any initial set-up parameters.public final IBleServer getServer(IncomingListener incomingListener)
BleServer
instance. which for now at least is a singleton.public final IBleServer getServer(GattDatabase gattDatabase)
BleManager.getServer(GattDatabase, AddServiceListener)
, with no AddServiceListener
set.public final IBleServer getServer(GattDatabase gattDatabase, AddServiceListener addServiceListener)
BleManager.getServer(IncomingListener, GattDatabase, AddServiceListener)
, with no IncomingListener
set.public final IBleServer getServer(IncomingListener incomingListener, GattDatabase gattDatabase, AddServiceListener addServiceListener)
BleServer
instance. This is now the preferred method to retrieve the server instance.public final boolean hasServerInstance()
public final IBleDevice newDevice(java.lang.String macAddress)
newDevice(String, String, BleDeviceConfig)
but uses an empty string for the name
and passes a null
BleDeviceConfig
, which results in inherited options from BleManagerConfig
.public final IBleDevice newDevice(java.lang.String macAddress, java.lang.String name)
newDevice(String)
but allows a custom name also.public final IBleDevice newDevice(java.lang.String macAddress, BleDeviceConfig config)
newDevice(String)
but passes a BleDeviceConfig
to be used as well.public final IBleDevice newDevice(java.lang.String macAddress, java.lang.String name, BleDeviceConfig config)
BleDevice
or returns an existing one if the macAddress matches.
GenericListener_Void.onEvent(Event)
will be called if a new device
is created.
BleDevice.isNull()
check on this method's return value just in case. Android
documentation says that underlying stack will always return a valid BluetoothDevice
instance (which is required to create a valid BleDevice
instance), but you really never know.public final IBleDevice newDevice(java.lang.String macAddress, java.lang.String name, byte[] scanRecord, BleDeviceConfig config)
public final boolean undiscover(IBleDevice device)
public final void clearQueue()
public final void clearSharedPreferences(BleDevice device)
clearSharedPreferences(String)
.clearSharedPreferences(String)
public final void clearSharedPreferences(java.lang.String macAddress)
SharedPreferences
for a particular device.public final void clearSharedPreferences()
SharedPreferences
for all devices.public final void update(double timeStep_seconds, long currentTime)
BleManagerConfig.autoUpdateRate
alone and let the library handle the calling of this method.public final boolean isForegrounded()
public final java.lang.String toString()
toString
in class java.lang.Object
public final com.idevicesinc.sweetblue.internal.P_BluetoothCrashResolver getCrashResolver()
public final com.idevicesinc.sweetblue.internal.P_ManagerStateTracker getStateTracker()
public final P_Logger getLogger()
public final com.idevicesinc.sweetblue.internal.P_TaskManager getTaskManager()
public final void tryPurgingStaleDevices(double scanTime)
public final long timeTurnedOn()
public final void clearTimeTurnedOn()
public final double timeForegrounded()
public final BleDevice getBleDevice(IBleDevice device)
public final BleServer getBleServer(IBleServer server)
public final void checkIdleStatus()
public final void stopScan(com.idevicesinc.sweetblue.internal.PA_StateTracker.E_Intent intent)
public final void onDiscoveredFromNativeStack(java.util.List<com.idevicesinc.sweetblue.internal.P_ScanManager.DiscoveryEntry> entries)
public final IBluetoothManager managerLayer()
public final boolean canPerformAutoScan()
public final void uhOh(UhOhListener.UhOh reason)
public final void postEvent(GenericListener_Void listener, Event event)
public final com.idevicesinc.sweetblue.internal.P_ScanManager getScanManager()
public final com.idevicesinc.sweetblue.internal.P_PostManager getPostManager()
public final com.idevicesinc.sweetblue.internal.P_BleManagerNativeManager getNativeManager()
public final com.idevicesinc.sweetblue.internal.P_WakeLockManager getWakeLockManager()
public final com.idevicesinc.sweetblue.internal.P_DeviceManager getDeviceManager_cache()
public final com.idevicesinc.sweetblue.internal.P_DeviceManager getDeviceManager()
public final void clearScanningRelatedMembers(com.idevicesinc.sweetblue.internal.PA_StateTracker.E_Intent intent)
public final boolean ready()
public final IBluetoothDevice newNativeDevice(java.lang.String macAddress)
public OutgoingListener getListener_Outgoing()
public final AdvertisingListener getListener_Advertising()
public final Backend_HistoricalDatabase getHistoricalDatabase()
public final HistoricalDataLoadListener getHistoricalDataLoadListener()
public final com.idevicesinc.sweetblue.internal.P_DiskOptionsManager getDiskOptionsManager()
public final ReadWriteListener getDefaultReadWriteListener()
public final NotificationListener getDefaultNotificationListener()
public final ServerStateListener getDefaultServerStateListener()
public final ServerConnectListener getDefaultServerConnectListener()
public final void onDiscovered_fromRogueAutoConnect(IBleDevice device, boolean newlyDiscovered, java.util.List<java.util.UUID> services_nullable, byte[] scanRecord_nullable, int rssi)
public final DeviceConnectListener getDefaultDeviceConnectListener()
public final DeviceReconnectFilter getDefaultDeviceReconnectFilter()
public final BondListener getDefaultBondListener()
public final java.lang.String getDeviceName(IBluetoothDevice device, byte[] scanRecord) throws java.lang.Exception
java.lang.Exception
public final DeviceStateListener getDefaultDeviceStateListener()
public final IncomingListener getDefaultServerIncomingListener()
public final long currentTime()
public IDeviceListener.Factory getDeviceListenerFactory()
public IServerListener.Factory getServerListenerFactory()
public IManagerListener.Factory getManagerListenerFactory()
public IManagerListener getInternalListener()
public final long getUpdateRate()
public final ServerReconnectFilter getDefaultServerReconnectFilter()
public final AddServiceListener getDefaultAddServiceListener()