public class BleNodeConfig
extends java.lang.Object
BleServer.setConfig(BleNodeConfig)
.
This class is also a super class of BleManagerConfig
, which you can pass
to BleManager.get(Context, BleManagerConfig)
or BleManager.setConfig(BleManagerConfig)
to set default base options for all servers at once.
For all options in this class, you may set the value to null
when passed to BleServer.setConfig(BleNodeConfig)
and the value will then be inherited from the BleManagerConfig
passed to BleManager.get(Context, BleManagerConfig)
.
Otherwise, if the value is not null
it will override any option in the BleManagerConfig
.
If an option is ultimately null
(null
when passed to BleServer.setConfig(BleNodeConfig)
*and* BleManager.get(Context, BleManagerConfig)
) then it is interpreted as false
or Interval.DISABLED
.
Interval.DISABLED
instead of null
to disable any time-based options, for code readability's sake.
newNulled()
(or nullOut()
) then only set the few options you want for BleServer.setConfig(BleNodeConfig)
.Modifier and Type | Class and Description |
---|---|
static class |
BleNodeConfig.DefaultHistoricalDataLogFilter
Default implementation of
BleNodeConfig.HistoricalDataLogFilter set on historicalDataLogFilter
that logs the most recent data reading to memory only, flushing the previous one. |
static class |
BleNodeConfig.DefaultTaskTimeoutRequestFilter
Default implementation of
TaskTimeoutRequestFilter that simply sets the timeout
for all BleTask instances to BleNodeConfig.DefaultTaskTimeoutRequestFilter.DEFAULT_TASK_TIMEOUT seconds. |
static interface |
BleNodeConfig.HistoricalDataFactory
Provide an instance to
historicalDataFactory to return custom subclasses
of HistoricalData if you would like. |
static interface |
BleNodeConfig.HistoricalDataLogFilter
Provide an instance of this class to
historicalDataLogFilter to control
how/if historical data from BLE operations is logged. |
Modifier and Type | Field and Description |
---|---|
java.lang.Boolean |
alwaysUseAutoConnect
Default is
false - see the boolean autoConnect parameters of
BluetoothDevice.connectGatt(Context, boolean, android.bluetooth.BluetoothGattCallback)
and BluetoothGattServer.connect(BluetoothDevice, boolean) . |
boolean |
autoStripeWrites
Default is
true - this will automatically stripe writes that are larger than the MTU size into multiple WRITE requests for you. |
static int |
DEFAULT_MAX_CONNECTION_FAIL_HISTORY_SIZE
The default size of the list that keeps track of a
BleNode 's connection failure history. |
static int |
DEFAULT_MTU_SIZE
The default MTU size in bytes for gatt reads/writes/notifies/etc.
|
java.lang.Boolean |
disconnectIsCancellable
Default is
true - controls whether the library is allowed to optimize fast disconnect/reconnect cycles
by actually not disconnecting in the native stack at all. |
static int |
GATT_READ_MTU_OVERHEAD
The overhead in bytes that is subtracted from the total mtu size (e.g.
|
static int |
GATT_WRITE_MTU_OVERHEAD
The overhead in bytes that is subtracted from the total mtu size (e.g.
|
BleNodeConfig.HistoricalDataFactory |
historicalDataFactory
Implement this to override the default behavior, which is simply to return an instance created with
the constructor
HistoricalData.HistoricalData(byte[], com.idevicesinc.sweetblue.utils.EpochTime) . |
BleNodeConfig.HistoricalDataLogFilter |
historicalDataLogFilter
Default is an instance of
BleNodeConfig.DefaultHistoricalDataLogFilter -
set an implementation here to control how/if data is logged. |
static int |
INVALID_TX_POWER
Constant for an invalid or unknown transmission power.
|
ReconnectFilter |
reconnectFilter
Default is an instance of
DefaultReconnectFilter using the timings that are public static final members thereof - set your own implementation here to
have fine-grain control over reconnect behavior while a device is BleDeviceState.RECONNECTING_LONG_TERM or BleDeviceState.RECONNECTING_SHORT_TERM . |
TaskTimeoutRequestFilter |
taskTimeoutRequestFilter
Default is an instance of
BleNodeConfig.DefaultTaskTimeoutRequestFilter - set an implementation here to
have fine control over how long individual BleTask instances can take before they
are considered "timed out" and failed. |
Constructor and Description |
---|
BleNodeConfig()
Creates a
BleNodeConfig with all default options set. |
BleNodeConfig(org.json.JSONObject jo)
Creates a
BleNodeConfig with all default options set. |
Modifier and Type | Method and Description |
---|---|
BleNodeConfig |
clone() |
static double |
getTimeout(TaskTimeoutRequestFilter.TaskTimeoutRequestEvent event) |
static BleNodeConfig |
newNulled()
Convenience method that returns a nulled out
BleNodeConfig , which is useful
when using BleServer.setConfig(BleNodeConfig) to only override a few options
from BleManagerConfig passed to BleManager.get(Context, BleManagerConfig)
or BleManager.setConfig(BleManagerConfig) . |
void |
nullOut()
Sets all
Nullable options in BleNodeConfig , BleDeviceConfig , BleManagerConfig to null
so for example it's easier to cherry-pick just a few options to override from BleManagerConfig when using BleDevice.setConfig(BleDeviceConfig) . |
void |
readJSON(org.json.JSONObject jo)
Accepts a JSON object that represents a set of configuration options.
|
org.json.JSONObject |
writeJSON()
Creates and returns a JSONObject that represents all of the mutable settings of this object.
|
public static final int DEFAULT_MTU_SIZE
public static final int GATT_WRITE_MTU_OVERHEAD
DEFAULT_MTU_SIZE
) to
give you the effective payload size that your application can send. For Android this
payload size is almost always 23-3=20 bytes.public static final int GATT_READ_MTU_OVERHEAD
DEFAULT_MTU_SIZE
) to
give you the effective payload size that your application can receive. For Android this
payload size is almost always 23-1=22 bytes.public static final int INVALID_TX_POWER
public static final int DEFAULT_MAX_CONNECTION_FAIL_HISTORY_SIZE
BleNode
's connection failure history. This is to prevent
the list from growing too large, if the device is unable to connect, and you have a large long term reconnect time set
with reconnectFilter
.public java.lang.Boolean alwaysUseAutoConnect
false
- see the boolean autoConnect
parameters of
BluetoothDevice.connectGatt(Context, boolean, android.bluetooth.BluetoothGattCallback)
and BluetoothGattServer.connect(BluetoothDevice, boolean)
.
ReconnectFilter.onConnectFailed(ReconnectFilter.ConnectFailEvent)
returned from ReconnectFilter.onConnectFailed(ReconnectFilter.ConnectFailEvent)
(or the equivalent
structures that are inner structures of BleServer
).
public java.lang.Boolean disconnectIsCancellable
true
- controls whether the library is allowed to optimize fast disconnect/reconnect cycles
by actually not disconnecting in the native stack at all. For example, if this option is true
and your
BleDevice
is BleDeviceState.BLE_CONNECTED
, calling BleDevice.disconnect()
then BleDevice.connect()
again won't result in a native disconnect/reconnect - your actual physical ble device firmware won't know that a disconnect was requested.public boolean autoStripeWrites
true
- this will automatically stripe writes that are larger than the MTU size into multiple WRITE requests for you.
If you are using BleDevice.negotiateMtu(int)
, this may make things unstable.public TaskTimeoutRequestFilter taskTimeoutRequestFilter
BleNodeConfig.DefaultTaskTimeoutRequestFilter
- set an implementation here to
have fine control over how long individual BleTask
instances can take before they
are considered "timed out" and failed.
null
will disable timeouts for all BleTask
instances,
which would probably be very dangerous to do - a task could just sit there spinning forever.public BleNodeConfig.HistoricalDataLogFilter historicalDataLogFilter
BleNodeConfig.DefaultHistoricalDataLogFilter
-
set an implementation here to control how/if data is logged.public BleNodeConfig.HistoricalDataFactory historicalDataFactory
HistoricalData.HistoricalData(byte[], com.idevicesinc.sweetblue.utils.EpochTime)
.public ReconnectFilter reconnectFilter
DefaultReconnectFilter
using the timings that are public static final
members thereof - set your own implementation here to
have fine-grain control over reconnect behavior while a device is BleDeviceState.RECONNECTING_LONG_TERM
or BleDeviceState.RECONNECTING_SHORT_TERM
.
This is basically how often and how long the library attempts to reconnect to a device that for example may have gone out of range. Set this variable to
null
if reconnect behavior isn't desired. If not null
, your app may find
BleManagerConfig.manageCpuWakeLock
useful in order to force the app/phone to stay awake while attempting a reconnect.public BleNodeConfig()
BleNodeConfig
with all default options set. See each member of this class
for what the default options are set to. Consider using newNulled()
also.public BleNodeConfig(org.json.JSONObject jo)
BleNodeConfig
with all default options set. Then, any configuration options
specified in the given JSONObject will be applied over the defaults. See writeJSON()
regarding the creation of the JSONObjectpublic void nullOut()
Nullable
options in BleNodeConfig
, BleDeviceConfig
, BleManagerConfig
to null
so for example it's easier to cherry-pick just a few options to override from BleManagerConfig
when using BleDevice.setConfig(BleDeviceConfig)
.
BleManagerConfig
like BleManagerConfig.stopScanOnPause
.public static BleNodeConfig newNulled()
BleNodeConfig
, which is useful
when using BleServer.setConfig(BleNodeConfig)
to only override a few options
from BleManagerConfig
passed to BleManager.get(Context, BleManagerConfig)
or BleManager.setConfig(BleManagerConfig)
.public static double getTimeout(TaskTimeoutRequestFilter.TaskTimeoutRequestEvent event)
public BleNodeConfig clone()
clone
in class java.lang.Object
public org.json.JSONObject writeJSON()
public void readJSON(org.json.JSONObject jo)