# MinewSensorKit Instruction document
This SDK only supports the Bluetooth sensor devices from Minew. The SDK helps developers to handle everything between the phone and the sensor, including: scanning the device, broadcasting data, connecting to the device, writing data to the device, receiving data from the device, etc.
# Preliminary work
Overall framework:PT100SensorBleManager
is the device management class, which is always a single instance when the app is running. PT100SensorEntity
is the device instance class, this suite generates an instance for each device, which is used after scanning and connecting, and contains device broadcast data inside, which will be updated during scanning as the device keeps broadcasting.
PT100SensorBleManager
:Device management class that scans the surrounding pt100 devices and can connect them, verify them, etc.;
PT100SensorEntity
:Example of an pt100 sensor device acquired during scanning, inherited fromBaseBleDeviceEntity
;
# Import to project
Development Environment
The minimum sdk support is Android 5.0, corresponding to API Level 21. set
minSdkVersion
to 21 or above inbuild.gradle
of the module.android { defaultConfig { applicationId "com.xxx.xxx" minSdkVersion 21 } }
1
2
3
4
5
6
7Add jar to the module's libs folder and add the following statement to the
build.gradle
of themodule
(add the dependency directly)implementation files('libs/base_ble_library.jar') implementation files('libs/minew_pt100.jar') api 'org.lucee:bcprov-jdk15on:1.52.0'
1
2
3Or right-click the jar file and select
Add as Library
to add it to the current module.Add the configuration to the.so library file in the App directory build.gradle
android { defaultConfig { ndk { abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64' } } sourceSets { main { jniLibs.srcDirs = ['libs'] } } }
1
2
3
4
5
6
7
8
9
10
11
12
13
14The following permissions are required in
AndroidManifest.xml
, and iftargetSdkVersion
is greater than 23, you need to do permission management to get the permissions.<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" tools:node="replace" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" tools:node="replace" /> <uses-permission android:name="android.permission.BLUETOOTH_SCAN" /> <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" /> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> <uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/> <uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/> <uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/> <uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED"/> <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" /> <!-- Required to maintain app compatibility. --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Use
The sdk is divided into three phases: scanning, connecting, and reading and writing.
# Scanning section
# Start scannin
For Android 6.0 and above systems, when performing BLE scanning, you need to apply for Bluetooth permission and turn on the positioning switch before proceeding.
To enable Bluetooth scanning, you need to turn on Bluetooth first. If you scan without turning on Bluetooth, the APP will crash. You can use BLETool.checkBluetooth(this) to determine whether Bluetooth is turned on. If it is not turned on, you can turn on Bluetooth first.
val mBleManager = PT100SensorBleManager.getInstance()
when (BLETool.checkBluetooth(this@Mst01Pt100ScanDevicesListActivity)) {
BluetoothState.BLE_NOT_SUPPORT -> {
Toast.makeText(this@Mst01Pt100ScanDevicesListActivity, "Not Support BLE", Toast.LENGTH_SHORT).show()
}
BluetoothState.BLUETOOTH_OFF -> {
val enableIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
launcherActivityResultForBle.launch(enableIntent)
}
BluetoothState.BLUETOOTH_ON -> {
manager.startScan(ModuleMst01Pt100Application.getApplication().mApplication, 5*60*1000,object : OnScanDevicesResultListener<PT100SensorEntity> {
override fun onScanResult(scanList: MutableList<PT100SensorEntity>?) {
}
override fun onStopScan(scanList: MutableList<PT100SensorEntity>?) {
}
})
}
else -> {
}
}
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
The SDK does not process the Bluetooth scanning duration internally, but scanning is a power-consuming operation. The SDK stops scanning after 5 minutes by default. If you still need to continue scanning, you can provide a timer or refresh operation to continue calling the scanning method to continue scanning the device.。
# Retrieve data
During the scan, the APP is able to get a part of the current data of the device through the sdk. The data of the device is obtained throughPT100SensorEntity
as shown below, which is stored in the broadcast frame object.
The sdk providesBaseBleDeviceEntity
as the base class ofPT100SensorEntity
to store the public data of the sensor device as shown in the following table.
Name | Type | Description |
---|---|---|
macAddress | String | device mac |
name | String | Device name |
rssi | int | Signal strength |
The BaseBleDeviceEntity
also keeps a Map, which is used internally to store the device broadcast data frames it acquires during a scan, and can be retrieved as follows
val module:PT100SensorEntity
val industrialHtFrame : IndustrialHtFrame? = module.getMinewFrame(FrameType.INDUSTRIAL_TEMPERATURE_HUMIDITY_TAG_STATUS_V2_FRAME)?.let {
it as IndustrialHtFrame
}
val deviceStaticInfoFrame : DeviceStaticInfoFrame? = module.getMinewFrame(FrameType.DEVICE_INFORMATION_FRAME)?.let {
it as DeviceStaticInfoFrame
}
if (deviceInforFrame != null) {
//Device mac address
String macAddress = deviceInforFrame.macAddress
//Percentage of power
val battery = deviceInforFrame.battery
//firmware version
val firmwareVersion = deviceInforFrame.firmwareVersion
}
if (industrialHtFrame != null) {
//Sensor temperature
val temperature = combinationFrame.temperature
val humidity = combinationFrame.humidity
//temp unit 1=°F 0=°C
val unit = combinationFrame.unit
//type 0:ht,1:temp
val temperature = combinationFrame.type
//screen status
val screenStatus = combinationFrame.screenStatus
//sensor status
val sensorStatus = combinationFrame.sensorStatus
//mark status
val markStatus = combinationFrame.markStatus
//Sensor name
val deviceName = combinationFrame.deviceName
}
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
There are 2 types of adv frames for Pt100 device
Device static information frame
DeviceStaticInfoFrame
Name Type Description frameVersion int device type firmwareVersion String Firmware Version batteryLevel int Battery Level Percentage macAddress String firmware mac peripheralSupportInfo PeripheralSupportInfo Description of peripheral support
Industrial Ht Frame
IndustrialHtFrame
Name Type Description frameVersion int device type tempHumiVersion int pt100 HT version type int Sensor type:0= ht,1= temp unit int temp unit: 1=°F 0=°C temperature float temperature humidity float humidity deviceName String Device name markStatus int mark status:1=marked,0=normal screenStatus int screen status: 1= exception,0=normal sensorStatus int sensor status: 1=exception,0=normal
# Connections
It is usually necessary to stop scanning before connecting. sdk provides methods to connect and disconnect.。
val manager = PT100SensorBleManager.getInstance()
//stop scanning
manager.stopScan(context)
//Setting the device secret key
val key="minewtech1234567"
manager.setSecretKey(key)
//Connection, module for the device to be connected
val module:PT100SensorEntity
manager.connect(context,module)
//Disconnect. macAddress is the device mac
manager.disConnect(macAddress)
2
3
4
5
6
7
8
9
10
11
12
Note: Before connecting the device, please confirm whether the device is scanned, if no device broadcast is scanned and the connection method is called, the connection will fail.
After calling connect()
, there will be a status listener in sdk for the connection process.
val manager = PT100SensorBleManager.getInstance()
manager.setOnConnStateListener { macAddress, bleConnectionState ->
when (it) {
BleConnectionState.Connecting -> {
//This state will be called back after calling connect()
Log.d("connectionListener", "Connecting")
}
BleConnectionState.Connected -> {
//The initial connection was successful, as a transition phase, but not really successful at this point.
Log.d("connectionListener", "Connected")
}
BleConnectionState.AuthenticateSuccess ->{
//Key verification successful.
Log.d("connectionListener", "AuthenticateSuccess")
}
BleConnectionState.AuthenticateFail ->{
//Key verification failed.
Log.d("connectionListener", "AuthenticateFail")
}
BleConnectionState.ConnectComplete -> {
//Connection is complete, the device is now ready for read and write operations.
Log.d("connectionListener", "ConnectComplete")
}
BleConnectionState.Disconnect -> {
//Connection failure or device disconnection will be called back, active disconnection will not call back the .
Log.d("connectionListener", "Disconnect")
}
else -> {}
}
}
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
During the connection process, sdk will return multiple connection states to the app, which the app needs to handle properly.
- BleConnectionState.Connecting,BleConnectionState.Connected: Connecting the device in, do not do time-consuming operations in this state, because at this time in the connected device discovery service, and send authentication data, etc.
- BleConnectionState.ConnectComplete: The sensor device is successfully connected at this point, and can perform read and write operations, such as configuring advparameters, sensor configuration, reading historical data, etc.
- BleConnectionState.AuthenticateFail:The secret key is verified during the authentication process. If the entered secret key is incorrect, this state will be called back and the device will actively disconnect.
- BleConnectionState.AuthenticateSuccess:The secret key is verified during the authentication process. If the entered secret key is correct, this status will be called back.
- BleConnectionState.Disconnect: The callback will be made if the connection fails or the device is disconnected.
# Reading and writing
The read and write APIs are as follows.:
/**
*Set device key
* @param macAddress device mac
* @param secretKey secret key key
* @param listener
*/
public void setDeviceSecretKey(String macAddress, String secretKey, OnModifyConfigurationListener listener);
/**
* Query device version information
* @param macAddress device mac
* @param listener listener
*/
public void queryDeviceFirmwareInfo(String macAddress, OnQueryResultListener<FirmwareVersionModel> listener);
/**
* Read historical data
*
* @param macAddress device mac
* @param startTime starting timestamp unit: seconds
* @param endTime end timestamp unit: seconds,Cannot be greater than systemTime
* @param systemTime real-time timestamp unit: seconds
* @param listener listener
*/
public void queryHistoryData(String macAddress,long startTime,long endTime,long systemTime, OnQueryResultListener<HistoryHtData> listener);
/**
* Query adv frame broadcast parameters
* @param macAddress device mac
* @param slot Query the broadcast channel value, default value 0.slot = 0 DeviceStaticInfoFrame 、slot = 1
* IndustrialHtFrame
* @param listener listener
*/
public void queryAdvParametersConfiguration(String macAddress,int slot, OnQueryResultListener<AdvParametersConfiguration> listener);
/**
* Set broadcast frame broadcast parameters
*
* @param macAddress device mac
* @param frameType FrameType enumeration gets getFrameTypeVersion()
* @param slotNumber sets the channel value corresponding to the broadcast,
* @param advertisingInterval broadcast interval in milliseconds, the broadcast interval is adjustable from 1s to 60s, and * the scale is 1s;
* @param txPower -40 -20 -16 -12 -8 -4 0 4dBm
* @param listener listener
*/
void setAdvParametersConfiguration(@NonNull String macAddress, @NonNull String frameType, int slotNumber, int advertisingInterval, int isAlwaysAdv, int txPower, @Nullable String advertisingName, OnModifyConfigurationListener listener);
/**
* set Temp unit
*
* @param macAddress device mac
* @param unit 1 = °F ,0=°C
* @param listener listener
*/
void setTemperatureUnit(@NonNull String macAddress, int unit, OnModifyConfigurationListener listener);
/**
* read Temp unit
*
* @param macAddress device mac
* @param listener listener
*/
void queryTemperatureUnit(@NonNull String macAddress, OnQueryResultListener<Integer> listener);
/**
* Set temperature and humidity sensor configuration
*
* @param macAddress device mac
* @param htSettingData Ht Sensor Params list,size = two .
* @param samplingInterval , unit: seconds
* @param delayRecordInterval ,unit: seconds
* @param listener listener
*/
public void setHTSensorConfiguration(String macAddress, List<HTSensorThresholdConfig> htSettingData, int samplingInterval,int delayRecordInterval,OnModifyConfigurationListener listener);
/**
* Query temperature and humidity sensor configuration
*
* @param macAddress device mac
* @param listener listener
*/
public void queryHTSensorConfiguration(String macAddress, OnQueryResultListener<HtSensorConfiguration> listener);
/**
* Firmware upgrade
*
* @param macAddress device mac
* @param isLinkUpgrade true url upgrade, false firmware package upgrade. The default value is false, and the url upgrade * method is not supported.
* @param dfuTarget isLinkUpgrade =true, dfuTarget = 0
* @param upgradeData upgrade package data
* @param listener listener
*/
public void firmwareUpgrade(String macAddress,boolean isLinkUpgrade,int dfuTarget,byte[] upgradeData, OnFirmwareUpgradeListener listener);
/**
* Restore factory settings
*
* @param macAddress device mac
* @param listener listener
*/
public void reset(String macAddress, OnModifyConfigurationListener listener);
/**
* Shutdown
* @param macAddress device mac
* @param listener listener
*/
public void powerOff(String macAddress, OnModifyConfigurationListener listener);
/**
* Verify the OTA upgrade file
* @param zipFilePath ota file path
* @return true=upgrade file ,false= unusable
*/
boolean verifyOtaFile(@NonNull String zipFilePath);
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
Some methods are supplemented:
Set the device key. This method must be called before the connect() method.
val manager = PT100SensorBleManager.getInstance() val secretKey = "3141592653589793" manager.setSecretKey(mAddress,secretKey)
1
2
3
4Query device version information。
suspend fun queryFirmwareInfo(): FirmwareVersionModel? = withContext(Dispatchers.Default) { if (connectMacAddress == null) { return@withContext null } return@withContext suspendCancellableCoroutine<FirmwareVersionModel?> { continuation -> manager.queryDeviceFirmwareInfo(connectMacAddress!!) { isSuccessful, version -> continuation.resume( when (isSuccessful) { true -> version else -> null }, null ) } } }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17Query and configure sensor Temp Unit
//unit 1 = °F ,0=°C suspend fun queryTemperatureUnit(): Int = withContext(Dispatchers.Default) { if (connectMacAddress == null) { return@withContext 0 } return@withContext suspendCancellableCoroutine<Int> { continuation -> manager.queryTemperatureUnit(connectMacAddress!!) { _, unit -> continuation.resume(unit, null) } } } suspend fun setTemperatureUnit(tempUnit: Int): Boolean = withContext(Dispatchers.Default) { if (connectMacAddress == null) { return@withContext false } return@withContext suspendCancellableCoroutine<Boolean> { continuation -> manager.setTemperatureUnit(connectMacAddress!!, tempUnit) { result -> continuation.resume(result, null) } } }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23Query adv frame broadcast parameters and configure adv parameters.
//slot = 0 DeviceStaticInfoFrame 、slot = 1 IndustrialHtFrame suspend fun queryAdvertisingParametersConfiguration(slot: Int): AdvParametersConfig? = withContext(Dispatchers.Default) { if (connectMacAddress == null) { return@withContext null } return@withContext suspendCancellableCoroutine<AdvParametersConfig?> { continuation -> manager.queryAdvParametersConfiguration( connectMacAddress!!, slot ) { isSuccessful, configResult -> continuation.resume( when (isSuccessful) { true -> configResult else -> null }, null ) } } } suspend fun setAdvertisingParametersConfiguration(slot:Int,frameType: String,advertisingInterval:Int, txPower:Int,isAlwaysAdv:Int,advertisingName:String?): Boolean = withContext(Dispatchers.Default) { if (connectMacAddress == null) { return@withContext false } return@withContext suspendCancellableCoroutine<Boolean> { continuation -> manager.setAdvParametersConfiguration(connectMacAddress!!,frameType,slot,advertisingInterval,isAlwaysAdv,txPower,advertisingName) { isSuccess -> continuation.resume(isSuccess, null) } } }
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
36Query temperature historical data
suspend fun readHistoryData(startTime:Long,endTime:Long,systemTime:Long): HistoryHtData?= withContext(Dispatchers.Default) { if (connectMacAddress == null) { return@withContext null } return@withContext suspendCancellableCoroutine<HistoryHtData?> { continuation -> manager.queryHistoryData(connectMacAddress!!,startTime,endTime,systemTime) { result,historyData -> continuation.resume(historyData, null) } } } private fun selectHTHistoryData(){ val systemTime = System.currentTimeMillis() / 1000 // unit:seconds val startTime = (systemTime - 60 * 60 * 1000 * 24) / 1000 // unit:seconds val endTime = systemTime / 1000 // unit:seconds lifecycleScope.launch(Dispatchers.Main) { WaitDialog.show(R.string.common_loading) val result = mConnectViewModel.readHistoryData( startTime, endTime, systemTime) WaitDialog.dismiss() if (result != null && result.historyDataList.isNotEmpty()) { MessageDialog.show(getString(R.string.common_tips),"HT HistoryDataList = ${result.historyDataList.size}") } else { } } }
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
31Query sensor parameters and configure sensor parameters.
private fun queryHTSensorConfiguration() { lifecycleScope.launch(Dispatchers.Main) { WaitDialog.show(R.string.common_configing) val htSensorConfiguration = mConnectViewModel.queryHTSensorConfiguration() mHtSensorConfiguration = htSensorConfiguration WaitDialog.dismiss() val sb = StringBuilder() htSensorConfiguration?.let { //2 sets of temperature threshold data val htSettingData = it.htSettingData val temp1Status = it.htSettingData[0].lowTemperature != -32768f && it.htSettingData[0].highTemperature != -32768f val temp2Status = it.htSettingData[1].lowTemperature != -32768f && it.htSettingData[1].highTemperature != -32768f //// Temperature alarm 1 when (temp1Status) { true -> { val temperatureAlarmLow1 = when (settingTemperatureUnit) { 1 -> getF(it.htSettingData[0].lowTemperature) else -> it.htSettingData[0].lowTemperature } val temperatureAlarmHigh1 = when (settingTemperatureUnit) { 1 -> getF(it.htSettingData[0].highTemperature) else -> it.htSettingData[0].highTemperature } val temp1Group = when (settingTemperatureUnit) { 1 -> "${temperatureAlarmLow1}°F ~ ${temperatureAlarmHigh1}°F" else -> "${temperatureAlarmLow1}°C ~ ${temperatureAlarmHigh1}°C" } sb.append("temp1Group=${temp1Group},\n") } else -> { val temp1Group = "~~" sb.append("temp1Group=${temp1Group},\n") } } //// Temperature alarm 2 when (temp2Status) { true -> { val temperatureAlarmLow2 = when (settingTemperatureUnit) { 1 -> getF(it.htSettingData[1].lowTemperature) else -> it.htSettingData[1].lowTemperature } val temperatureAlarmHigh2 = when (settingTemperatureUnit) { 1 -> getF(it.htSettingData[1].highTemperature) else -> it.htSettingData[1].highTemperature } val temp2Group = when (settingTemperatureUnit) { 1 -> "${temperatureAlarmLow2}°F ~ ${temperatureAlarmHigh2}°F" else -> "${temperatureAlarmLow2}°C ~ ${temperatureAlarmHigh2}°C" } sb.append("temp2Group=${temp2Group},\n") } else -> { val temp2Group = "~~" sb.append("temp2Group=${temp2Group},\n") } } //sampling interval. Unit second val samplingInterval = it.samplingInterval //delay Record interval. Unit second val delayRecordTimeStamp = it.delay sb.append("samplingInterval=${samplingInterval},\n") sb.append("delayRecordTimeStamp=${delayRecordTimeStamp},\n") MessageDialog.show(getString(R.string.common_tips),"SensorConfiguration = ${sb.toString()}") } } } suspend fun queryHTSensorConfiguration(): HtSensorConfiguration? = withContext(Dispatchers.Default) { if (connectMacAddress == null) { return@withContext null } return@withContext suspendCancellableCoroutine<HtSensorConfiguration?> { continuation -> manager.queryHTSensorConfiguration(connectMacAddress!!) { isSuccessful, configResult -> continuation.resume( when (isSuccessful) { true -> configResult else -> null }, null ) } } } //Setting sensor parameters //2 groups of temperature threshold ranges [-200,200], in degrees Celsius. To convert the Fahrenheit range itself, call getF() private fun setHTSensorConfiguration(){ lifecycleScope.launch(Dispatchers.Main){ mHtSensorConfiguration?.let { WaitDialog.show(R.string.common_configing) val result = mConnectViewModel.setHTSensorConfiguration(it.htSettingData,it.samplingInterval,it.delay) WaitDialog.dismiss() ToastUtils.showShort(when(result){ true -> R.string.common_config_success else -> R.string.common_config_fail }) } } } private fun getF(t: Float): Float { return t * 1.8f + 32 }
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107Firmware upgrade.
private fun firmwareUpgrade( fileByte: ByteArray, dfuTarget: Int ) { mConnectViewModel.firmwareUpgrade(dfuTarget, fileByte, progressCallBack = { progress -> WaitDialog.show(getString(R.string.common_upgrading), (progress / 100f)) binding.progressBarSimpleCustom.progress = progress.toFloat() }, successCallBack = { WaitDialog.dismiss() ToastUtils.showShort(R.string.common_firmware_upgrade_successfully) finishPageForResult() }, failCallBack = { WaitDialog.dismiss() ToastUtils.showShort(R.string.common_firmware_upgrade_failure2) } ) } fun firmwareUpgrade( dfuTarget: Int, fileByte: ByteArray, progressCallBack:(progress:Int) -> Unit, successCallBack:() -> Unit, failCallBack:() -> Unit, ){ manager.firmwareUpgrade(connectMacAddress!!,false,dfuTarget,fileByte, object : OnFirmwareUpgradeListener { override fun updateProgress(progress: Int) { progressCallBack(progress) } override fun upgradeSuccess() { successCallBack() } override fun upgradeFailed() { failCallBack() } }) }
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
44
45
46Restore the factory settings.
suspend fun reset(): Boolean = withContext(Dispatchers.Default) { if (connectMacAddress == null) { return@withContext false } return@withContext suspendCancellableCoroutine<Boolean> { continuation -> manager.reset(connectMacAddress!!) { continuation.resume(it, null) } } }
1
2
3
4
5
6
7
8
9
10Shutdown.
suspend fun shutdown(): Boolean = withContext(Dispatchers.Default) { if (connectMacAddress == null) { return@withContext false } return@withContext suspendCancellableCoroutine<Boolean> { continuation -> manager.powerOff(connectMacAddress!!) { continuation.resume(it, null) } } }
1
2
3
4
5
6
7
8
9
10
# History
- **2024/10/12 edit;