public class KontaktDeviceConnection extends java.lang.Object implements IKontaktDeviceConnection
| Modifier and Type | Class and Description |
|---|---|
static class |
KontaktDeviceConnection.State
State enum describes all possible state that BeaconConnection may be in.
|
IKontaktDeviceConnection.ConnectionListener| 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_INSTANCE_ID
Error code informing that Batch write operation failed during InstanceId write
|
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_NAME
Error code informing that Batch write operation failed during Name write
|
static int |
ERROR_BATCH_WRITE_NAMESPACE
Error code informing that Batch write operation failed during Namespace write
|
static int |
ERROR_BATCH_WRITE_PASSWORD
Error code informing that Batch write failed during Password write
|
static int |
ERROR_BATCH_WRITE_PROFILE
Error code informing that Batch write operation failed during Profile 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_BATCH_WRITE_URL
Error code informing that Batch write operation failed during Url 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.
|
| Modifier | Constructor and Description |
|---|---|
|
KontaktDeviceConnection(android.content.Context context,
RemoteBluetoothDevice bluetoothDevice,
IKontaktDeviceConnection.ConnectionListener connectionListener) |
protected |
KontaktDeviceConnection(android.content.Context context,
RemoteBluetoothDevice bluetoothDevice,
IKontaktDeviceConnection.ConnectionListener connectionListener,
KontaktDeviceServiceStore serviceStore) |
| Modifier and Type | Method and Description |
|---|---|
void |
acceptProfile(Preset profile,
WriteBatchListener<Preset> writeBatchListener)
Accepts predefined profile (
Preset) and changes parameters for Beacon. |
void |
applyConfig(Config config,
WriteBatchListener<Config> writeBatchListener)
Applies pending configuration (
Config) for Device. |
void |
applySecureConfig(java.lang.String secureConfig,
WriteListener writeListener)
Method for writing secure config.
|
void |
close()
Closes Beacon connection releases provided resources.
|
boolean |
connect()
Initializes connection to device provided in the KontaktDeviceConnection constructor.
|
boolean |
connect(RemoteBluetoothDevice device)
Initializes connection to given device.
|
void |
enableDfuMode(java.lang.String masterPassword,
WriteListener writeListener)
Enables dfu mode.
|
void |
enableNonConnectableMode(java.lang.String masterPassword,
WriteListener writeListener)
Changes Device mode to non-connectable.
|
void |
executeSecureCommand(java.lang.String secureCommand,
WriteListener writeListener) |
RemoteBluetoothDevice |
getDevice()
Gets beacon that the connection is established with.
|
static int |
getGattError(int errorCode)
Method for getting gatt error status code from received errorCode
throws IllegalAccessException if errorCode is not gatt error code |
boolean |
isAuthenticated()
Returns true if Beacon was successfully authenticated.
|
boolean |
isClosed() |
boolean |
isConnected()
Returns true if Connection with Beacon is established.
|
static boolean |
isGattError(int errorCode)
Metohd for checking is error code indicating GATT error
|
protected void |
overwrite(android.bluetooth.BluetoothGattCharacteristic characteristic,
byte[] newValue,
WriteListener listener) |
void |
overwriteAdvertisingInterval(long millis,
WriteListener writeListener)
Changes Beacon advertising interval.
|
void |
overwriteInstanceId(java.lang.String instanceId,
WriteListener writeListener)
Overwrite instance id.
|
void |
overwriteMajor(int value,
WriteListener writeListener)
Changes Beacon major value.
|
void |
overwriteMinor(int value,
WriteListener writeListener)
Writes minor value.
|
void |
overwriteModelName(java.lang.String newModelName,
WriteListener writeListener)
Changes Beacon model name.
|
void |
overwriteNamespaceId(java.lang.String namespaceId,
WriteListener writeListener)
Overwrites namespace id.
|
void |
overwritePassword(java.lang.String newPassword,
WriteListener writeListener)
Changes beacon password.
|
void |
overwritePowerLevel(int powerLevel,
WriteListener writeListener)
Changes Beacon power level.
|
void |
overwriteProximityUUID(java.util.UUID proximity,
WriteListener writeListener)
Changes Beacon Proximity UUID value.
|
protected void |
overwriteSecure(android.bluetooth.BluetoothGattCharacteristic characteristic,
byte[] newValue,
WriteListener listener,
boolean readResponse) |
void |
overwriteUrl(java.lang.String newUrl,
WriteListener writeListener)
Overwrites url.
|
void |
resetDevice(WriteListener writeListener)
Resets device so that connection is established once again.
|
void |
restoreDefaultSettings(java.lang.String masterPassword,
WriteListener writeListener)
Restores default Beacon settings.
|
void |
switchToDeviceProfile(DeviceProfile deviceProfile,
WriteListener writeListener)
Switch to device profile.
|
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 static final int ERROR_BATCH_WRITE_PROFILE
public static final int ERROR_BATCH_WRITE_NAMESPACE
public static final int ERROR_BATCH_WRITE_INSTANCE_ID
public static final int ERROR_BATCH_WRITE_URL
public static final int ERROR_BATCH_WRITE_NAME
public static final int ERROR_BATCH_WRITE_PASSWORD
public KontaktDeviceConnection(android.content.Context context,
RemoteBluetoothDevice bluetoothDevice,
IKontaktDeviceConnection.ConnectionListener connectionListener)
protected KontaktDeviceConnection(android.content.Context context,
RemoteBluetoothDevice bluetoothDevice,
IKontaktDeviceConnection.ConnectionListener connectionListener,
KontaktDeviceServiceStore serviceStore)
public static boolean isGattError(int errorCode)
errorCode - received from IKontaktDeviceConnection.ConnectionListener.onErrorOccured(int)public static int getGattError(int errorCode)
IllegalAccessException if errorCode is not gatt error codeerrorCode - error codepublic RemoteBluetoothDevice getDevice()
getDevice in interface IKontaktDeviceConnectionpublic boolean connect()
connect in interface IKontaktDeviceConnectionpublic boolean connect(RemoteBluetoothDevice device)
connect in interface IKontaktDeviceConnectiondevice - device to connect to.public boolean isConnected()
isConnected in interface IKontaktDeviceConnectionpublic boolean isAuthenticated()
isAuthenticated in interface IKontaktDeviceConnectionpublic void close()
close in interface IKontaktDeviceConnectionpublic boolean isClosed()
isClosed in interface IKontaktDeviceConnectionpublic void applyConfig(Config config, WriteBatchListener<Config> writeBatchListener)
Config) for Device.
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higherapplyConfig in interface IKontaktDeviceConnectionconfig - the configwriteBatchListener - the write batch listenerpublic void acceptProfile(Preset profile, WriteBatchListener<Preset> writeBatchListener)
Preset) and changes parameters for Beacon.
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higheracceptProfile in interface IKontaktDeviceConnectionprofile - the profilewriteBatchListener - the write batch listenerpublic void overwriteMinor(int value,
WriteListener writeListener)
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higheroverwriteMinor in interface IKontaktDeviceConnectionvalue - the valuewriteListener - the write listenerpublic void enableNonConnectableMode(java.lang.String masterPassword,
WriteListener writeListener)
Credentials)
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higherenableNonConnectableMode in interface IKontaktDeviceConnectionmasterPassword - the beacon master passwordwriteListener - the write listenerpublic void overwriteMajor(int value,
WriteListener writeListener)
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higheroverwriteMajor in interface IKontaktDeviceConnectionvalue - new valuewriteListener - the write listenerpublic void overwriteProximityUUID(java.util.UUID proximity,
WriteListener writeListener)
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higheroverwriteProximityUUID in interface IKontaktDeviceConnectionproximity - the proximity UUIDwriteListener - the write listenerpublic void overwritePassword(java.lang.String newPassword,
WriteListener writeListener)
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higheroverwritePassword in interface IKontaktDeviceConnectionnewPassword - the new passwordwriteListener - the write listenerpublic void overwriteModelName(java.lang.String newModelName,
WriteListener writeListener)
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higheroverwriteModelName in interface IKontaktDeviceConnectionnewModelName - the new model namewriteListener - the write listenerpublic void overwriteAdvertisingInterval(long millis,
WriteListener writeListener)
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higheroverwriteAdvertisingInterval in interface IKontaktDeviceConnectionmillis - the interval milliswriteListener - the write listenerpublic void overwritePowerLevel(int powerLevel,
WriteListener writeListener)
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higheroverwritePowerLevel in interface IKontaktDeviceConnectionpowerLevel - the power levelwriteListener - the write listenerpublic void switchToDeviceProfile(DeviceProfile deviceProfile, WriteListener writeListener)
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higherswitchToDeviceProfile in interface IKontaktDeviceConnectiondeviceProfile - the device profilewriteListener - the write listenerpublic void resetDevice(WriteListener writeListener)
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higherresetDevice in interface IKontaktDeviceConnectionwriteListener - the write listenerpublic void enableDfuMode(java.lang.String masterPassword,
WriteListener writeListener)
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higherenableDfuMode in interface IKontaktDeviceConnectionmasterPassword - the master passwordwriteListener - the write listenerpublic void overwriteUrl(java.lang.String newUrl,
WriteListener writeListener)
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higheroverwriteUrl in interface IKontaktDeviceConnectionnewUrl - the new urlwriteListener - the write listenerpublic void overwriteNamespaceId(java.lang.String namespaceId,
WriteListener writeListener)
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higheroverwriteNamespaceId in interface IKontaktDeviceConnectionnamespaceId - the namespace idwriteListener - the write listenerpublic void overwriteInstanceId(java.lang.String instanceId,
WriteListener writeListener)
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higheroverwriteInstanceId in interface IKontaktDeviceConnectioninstanceId - the instance idwriteListener - the write listenerpublic void restoreDefaultSettings(java.lang.String masterPassword,
WriteListener writeListener)
IllegalOperationException if provided RemoteBluetoothDevice is in version 4.0 or
higherrestoreDefaultSettings in interface IKontaktDeviceConnectionmasterPassword - the master passwordwriteListener - the write listenerpublic void applySecureConfig(java.lang.String secureConfig,
WriteListener writeListener)
IllegalOperationException if provided device is below 4.0 firmware version
*applySecureConfig in interface IKontaktDeviceConnectionpublic void executeSecureCommand(java.lang.String secureCommand,
WriteListener writeListener)
executeSecureCommand in interface IKontaktDeviceConnectionprotected void overwrite(android.bluetooth.BluetoothGattCharacteristic characteristic,
byte[] newValue,
WriteListener listener)
protected void overwriteSecure(android.bluetooth.BluetoothGattCharacteristic characteristic,
byte[] newValue,
WriteListener listener,
boolean readResponse)