public class IBeaconConnection extends java.lang.Object implements RemoteDeviceConnection<IBeaconDevice>
Modifier and Type | Class and Description |
---|---|
static interface |
IBeaconConnection.ConnectionListener |
static class |
IBeaconConnection.State
State enum describes all possible state that BeaconConnection may be in.
|
static interface |
IBeaconConnection.WriteBatchListener<T>
WriteBatchListener provides callback methods notifying about writing parameters batch to Beacon device.
|
static interface |
IBeaconConnection.WriteListener
WriteListener provides callbacks indicating whether Beacon characteristics manipulation
ended successfully or failed.
|
Modifier and Type | Field and Description |
---|---|
static int |
ERROR_AUTHENTICATION
Error code informing that unexpected error has occured while attempting
beacon authentication.
|
static int |
ERROR_BATCH_WRITE_INTERVAL
Error code informing that Batch write operation failed during Interval write.
|
static int |
ERROR_BATCH_WRITE_MAJOR
Error code informing that Batch write operation failed during Major write.
|
static int |
ERROR_BATCH_WRITE_MINOR
Error code informing that Batch write operation failed during Minor write.
|
static int |
ERROR_BATCH_WRITE_PROXIMITY_UUID
Error code informing that Batch write operation failed during Proximity UUID write.
|
static int |
ERROR_BATCH_WRITE_TX_POWER
Error code informing that Batch write operation failed during Transmission Power write.
|
static int |
ERROR_OVERWRITE_REQUEST
Error code informing that error has occured during characteristic
overwrite process.
|
static int |
ERROR_SERVICES_DISCOVERY
Error code informing that Beacon services discovery has failed.
|
static int |
FAILURE_UNKNOWN_BEACON
Failure code informing that BLE device was not recognised as kontakt.io
Beacon.
|
static int |
FAILURE_WRONG_PASSWORD
Failure code informing that beacon was not authenticated because of
wrong password.
|
Constructor and Description |
---|
IBeaconConnection(android.content.Context context,
IBeaconDevice beaconDevice,
IBeaconConnection.ConnectionListener connectionListener) |
Modifier and Type | Method and Description |
---|---|
void |
acceptProfile(Profile profile,
IBeaconConnection.WriteBatchListener<Profile> writeBatchListener)
Accepts predefined profile (
Profile ) and changes parameters for Beacon. |
void |
applyConfig(Config config,
IBeaconConnection.WriteBatchListener<Config> writeBatchListener)
Applies pending configuration (
Config ) for Beacon. |
void |
close()
Closes connection to the device.
|
boolean |
connect()
sends connection request to the device.
|
void |
enableDfuMode(java.lang.String masterPassword,
IBeaconConnection.WriteListener writeListener)
Enables dfu mode.
|
void |
enableNonConnectableMode(java.lang.String masterPassword,
IBeaconConnection.WriteListener writeListener)
Changes Beacon mode to non-connectable.
|
IBeaconDevice |
getDevice()
Gets remote device that the connection is established with.
|
boolean |
isAuthenticated()
Provides information whether the remote device has been authenticated.
|
boolean |
isConnected()
Provides information whether connection is established to the device.
|
void |
overwriteAdvertisingInterval(long millis,
IBeaconConnection.WriteListener writeListener)
Changes Beacon advertising interval.
|
void |
overwriteMajor(int value,
IBeaconConnection.WriteListener writeListener)
Changes Beacon major value.
|
void |
overwriteMinor(int value,
IBeaconConnection.WriteListener writeListener)
Writes minor value.
|
void |
overwriteModelName(java.lang.String newModelName,
IBeaconConnection.WriteListener writeListener)
Changes Beacon model name.
|
void |
overwritePassword(java.lang.String newPassword,
IBeaconConnection.WriteListener writeListener)
Changes beacon password.
|
void |
overwritePowerLevel(int powerLevel,
IBeaconConnection.WriteListener writeListener)
Changes Beacon power level.
|
void |
overwriteProximity(java.util.UUID proximity,
IBeaconConnection.WriteListener writeListener)
Changes Beacon Proximity UUID value.
|
void |
resetDevice(IBeaconConnection.WriteListener writeListener)
Resets device so that connection is established once again.
|
void |
restoreDefaultSettings(java.lang.String masterPassword,
IBeaconConnection.WriteListener writeListener)
Restores default Beacon settings.
|
public static final int ERROR_SERVICES_DISCOVERY
public static final int ERROR_OVERWRITE_REQUEST
public static final int ERROR_AUTHENTICATION
public static final int FAILURE_UNKNOWN_BEACON
public static final int FAILURE_WRONG_PASSWORD
public static final int ERROR_BATCH_WRITE_PROXIMITY_UUID
public static final int ERROR_BATCH_WRITE_TX_POWER
public static final int ERROR_BATCH_WRITE_MAJOR
public static final int ERROR_BATCH_WRITE_MINOR
public static final int ERROR_BATCH_WRITE_INTERVAL
public IBeaconConnection(android.content.Context context, IBeaconDevice beaconDevice, IBeaconConnection.ConnectionListener connectionListener)
public IBeaconDevice getDevice()
RemoteDeviceConnection
getDevice
in interface RemoteDeviceConnection<IBeaconDevice>
public boolean connect()
RemoteDeviceConnection
connect
in interface RemoteDeviceConnection<IBeaconDevice>
public boolean isConnected()
RemoteDeviceConnection
isConnected
in interface RemoteDeviceConnection<IBeaconDevice>
public boolean isAuthenticated()
RemoteDeviceConnection
isAuthenticated
in interface RemoteDeviceConnection<IBeaconDevice>
public void close()
RemoteDeviceConnection
close
in interface RemoteDeviceConnection<IBeaconDevice>
public void applyConfig(Config config, IBeaconConnection.WriteBatchListener<Config> writeBatchListener)
Config
) for Beacon.
* It is possible to encounter problems during batch (the Config in this case)
write operation which result in launching error handle callback method.
Once the write batch operation failes, the Write Batch Processor
will attempt performing rollback write batch operation aiming at
restoring original Beacon configuration.
The rollback operation however may not succeed as well leaving Beacon device
changed partially.
Therefore it is strongly advisable to write batches in relatively close distance
to Beacon device. Thus, the risk of leaving Beacon in unspecified state may
be avoided.
The method is synchronized.config
- the configwriteBatchListener
- the write batch listenerpublic void acceptProfile(Profile profile, IBeaconConnection.WriteBatchListener<Profile> writeBatchListener)
Profile
) and changes parameters for Beacon.
It is possible to encounter problems during batch (the Profile in this case) write operation which result
in launching error handle callback method. Once the write batch operation failes,
the Write Batch Processor will attempt performing rollback write batch
operation aiming at restoring original Beacon configuration.
The rollback operation however may not succeed as well leaving Beacon device
changed partially.
Therefore it is strongly advisable to write batches in relatively close distance
to Beacon device. Thus, the risk of leaving Beacon in unspecified state may
be avoided.
The method is synchronized.profile
- the profilewriteBatchListener
- the write batch listenerpublic void overwriteMinor(int value, IBeaconConnection.WriteListener writeListener)
value
- the valuewriteListener
- the write listenerpublic void enableNonConnectableMode(java.lang.String masterPassword, IBeaconConnection.WriteListener writeListener)
DeviceCredentials
)
The method is synchronized.masterPassword
- the beacon master passwordwriteListener
- the write listenerpublic void overwriteMajor(int value, IBeaconConnection.WriteListener writeListener)
value
- new valuewriteListener
- the write listenerpublic void overwriteProximity(java.util.UUID proximity, IBeaconConnection.WriteListener writeListener)
proximity
- the proximity UUIDwriteListener
- the write listenerpublic void overwritePassword(java.lang.String newPassword, IBeaconConnection.WriteListener writeListener)
newPassword
- the new passwordwriteListener
- the write listenerpublic void overwriteModelName(java.lang.String newModelName, IBeaconConnection.WriteListener writeListener)
newModelName
- the new model namewriteListener
- the write listenerpublic void overwriteAdvertisingInterval(long millis, IBeaconConnection.WriteListener writeListener)
millis
- the interval milliswriteListener
- the write listenerpublic void overwritePowerLevel(int powerLevel, IBeaconConnection.WriteListener writeListener)
powerLevel
- the power levelwriteListener
- the write listenerpublic void resetDevice(IBeaconConnection.WriteListener writeListener)
writeListener
- the write listenerpublic void enableDfuMode(java.lang.String masterPassword, IBeaconConnection.WriteListener writeListener)
masterPassword
- the master passwordwriteListener
- the write listenerpublic void restoreDefaultSettings(java.lang.String masterPassword, IBeaconConnection.WriteListener writeListener)
masterPassword
- the master passwordwriteListener
- the write listener