IMLLockScannerDelegate
# IMLLockScannerDelegate.java
### The SDK’s LockScanner requires an object that implements the MLLockScannerDelegate interface. The lock scanner calls the methods of its delegate during the lifecycle of a Master Lock Bluetooth device’s connection to the phone.
To set the delegate, call setLockScannerDelegate on the MLBluetoothSDK’s singleton instance:
MLBluetoothSDK.getInstance().setLockScannerDelegate(IMLLockScannerDelegate myDelegate)
Setting this delegate starts an Android Service and internally prepares a Bluetooth LE Scanner. When the Scanner is ready, the SDK calls the bluetoothReady() method, at which point you can call MLBluetoothSDK.getInstance().startScanning() to begin scanning for Master Lock bluetooth products.
package com.masterlock.mlbluetoothsdk.Interfaces;
import com.masterlock.mlbluetoothsdk.MLProduct;
public interface IMLLockScannerDelegate {
/**
* This method is called when the Bluetooth Adapter is ready to use
*/
void bluetoothReady();
/**
* This method is called when the Bluetooth Adapter is changed to a disabled state
*/
void bluetoothDown();
/**
* Tells the delegate that a Master Lock Bluetooth device was discovered.
* @param deviceId The unique identifier associated with a Master Lock product.
*/
void didDiscoverDevice(String deviceId);
/**
* Asks the delegate if the device should be connected to.
* @param deviceId The unique identifier associated with a Master Lock product.
* @param rssi The signal strength of the broadcasting device.
* @return true if you want to connect to the device
*/
boolean shouldConnect(String deviceId, int rssi);
/**
* Asks the delegate for an MLProduct whose device identifier matches the one provided.
* Note you should assign a MLProductDelegate to the MLProduct you return here.
* @param deviceId The unique identifier associated with a Master Lock product.
* @return the MLProduct you intend to interact with
*/
@Nullable
MLProduct productForDevice(String deviceId);
/**
* Indicates the current bluetooth operation failed with the indicated disconnect code
* @param deviceId the device ID that the failure occurred on
* @param disconnectCode the disconnect code the bluetooth radio received
*/
void bluetoothFailedWithDisconnectCode(String deviceId, int disconnectCode);
/**
* Indicates that the bluetooth scanner received an error when attempting to scan
* @param errorCode the int corresponding with error constants defined in android.bluetooth.le.ScanCallback;
* value of -1 indicates that the Bluetooth Adapter is unavailable
*
*/
void onScanFailed(int errorCode);
}