MinewToolsKit Documentation

This set of SDK only supports Bluetooth smart lock devices produced by Minew. The SDK can help developers handle all the work between the mobile phone and the smart lock, including: scanning the Bluetooth smart lock, broadcasting data, unlocking, reading device information, firmware upgrades, etc.

preliminary work

Overall framework: ScanLockManager is a device management class, which is always a singleton when the APP is running. LockModule is a device instance class. This kit will generate an instance for each device, which will be used after scanning and connection. It contains device broadcast data, which will be updated as the device continuously broadcasts.

ScanLockManager:Device management, you can scan the surrounding smart lock devices and stop Bluetooth scanning.

LockModule:The device instance obtained during scanning corresponds to the Bluetooth smart lock device and will be used after scanning and connecting

Import to project

  1. Development environment

    The SDK supports Android 5.0 at a minimum, and the corresponding API Level is 21. Set minSdkVersion to 21or above in module's build.gradle

  2. android {
    
        defaultConfig {
            applicationId "com.xxx.xxx"
            minSdkVersion 21
        }
    }
    
    1
    2
    3
    4
    5
    6
    7
  3. Add MinewWristbandKit.jar to the libs folder of the module, and add the following statement in build.gradle of the module (add dependencies directly):

    implementation files('libs/MinewToolsKit.jar')
    implementation 'org.lucee:bcprov-jdk15on:1.52.0'
    
    1
    2

    Or right click on the jar file and select Add as Library to add to the current module

  4. The following permissions are required in AndroidManifest.xml. If targetSdkVersion is greater than 23, you need to do Permission Management to obtain permissions

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    
    1
    2
    3
    4

Usage

Start scan

For Android 6.0 and above, BLE scanning is only possible after applying for positioning permission, and the positioning switch must be turned on!

MinewLockCenterManager mLockCenterManager = MinewLockCenterManager.getInstance(context);
mLockCenterManager.getScanLockManager().startScan(new OnScanLockResultListener(){
    @Override
    public void onScanLockResult(List<LockModule> scanLockList) {
		//scan result
    }
});

1
2
3
4
5
6
7
8

The sdk does not process the Bluetooth scan duration, but the scan is a power-consuming operation. Generally, the scan can be stopped in 90 seconds. If you still need to continue the scan, you can provide refresh and other operations to continue the scan.

Take out the data

During scanning, the broadcast data obtained by the SDK is stored in the broadcast frame, and the scanned device mac address is placed in LockModule.getMacAddress() in List, which is required for a series of operations on the device. Frame information is also stored in LockModuleLockModule .getMinewFrame(FrameType type),

There are currently these frames:FrameType.DEVICE_INFO_FRAME;HISTORY_ERROR_INFO_FRAME,暂时未用到

Operate the smart lock device

At present, the operations of smart locks mainly include: unlocking, reading device information, and firmware upgrades. Each operation is to connect the smart lock first, and then send the corresponding instructions to the smart lock to perform the corresponding steps. After each operation is completed, it will be automatically disconnected. Open the smart lock connection, no need to disconnect the device

MinewLockCenterManager mCenterManager = MinewLockCenterManager.getInstance(context);
//Before operating the smart lock, call the method, initialize the number of operations //and start the 10-second timeout timer
mCenterManager.getConnLockManager().initOperaState();
/*
* Status callback during connection
*
* @param context 
* @param LockModule: Device to connect
* @param OperationType: Operation type
* unlock OperationType.OPERA_OPEN_LOCK;
* Read device information: OperationType.OPERA_READ_DEVICE;
* There are two steps to firmware upgrade: OperationType.OPERA_OTA1,                    	OperationType.OPERA_OT2,
* connect()Method used OPERA_OTA1
* @param OnConnStateListener: Operation interface return status
*/
 mCenterManager.getConnLockManager().connect(context, LockModule,OperationType,
                                             new OnConnStateListener() {
    @Override
    public void onOperaLockState(String macAddress, ConnectionState connectionState,
                                 ConnectionState operaState,
                                 boolean operaResult, String result) {
        
    }                                                                           
                                             });
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

固件升级;

/**
 * Firmware upgrade
 *
 * @param macAddress:  Device mac
 * @param data: Upgrade package data byte[] data
 * @param  OperationType.OPERA_OTA2  
 * @param listener   Listener
 */
manager.firmwareUpgrade(macAddress, data, OperationType.OPERA_OTA2, new OnFirmwareUpgradeListener
                        new OnFirmwareUpgradeListener() {
      
   /**
     * Start firmware upgrade
     */
   @Override
   public void startUpgrade() {
   
   }
    
    /**
     * Upgrade package data writing progress
     */
    @Override
    public void updateProgress(int progress) {

    }

    /**
     * update successed
     */
    @Override
    public void upgradeSuccess() {

    }
    
    /**
     * upgrade unsuccessful
     */
    @Override
    public void upgradeFailed() {

 }
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

API summary

Before connecting

  1. startScan(): Start scanning. Every time you start a scan, all results of the previous scan will be cleared

  2. stopScan():Stop scanning

  3. connect(Context context, LockModule lockModule,OperationType operationType, OnConnStateListener listener ): Operate the smart lock

  4. disConnect(String macAddress): Disconnect

  5. initOperaState(): Initialization before operation

Schedule

nothing

Update history

2020/10/15

  1. Create SDK instructions;
Last Updated:: 1/19/2021, 3:19:00 PM