DeviceManager
class DeviceManager
Description: Device manager
class DeviceManager private constructor() : IDeviceManager, OnDeviceChangedListener,IProtoConnectListener {
companion object {
private const val CLASS_NAME = "[DeviceManager]"
private const val TAG = Constants.MSDK_PROTO_TAG
/**
* max retry connection count defined here
*/
private const val MAX_RETRY_COUNT = 3
/**
* device manager class
*/
private var deviceManager: IDeviceManager = DeviceManager()
/**
* disconnection interval
*/
var mDisconnectTimeInterval = 0L
/**
* Frequency binding completion time (unit: ms)
*/
var costTime = 0
/**
* init method for defined device manager class with context
* @param context context of activity
*/
fun init(context: Context) {
deviceManager.init(context)
}
/**
* getting current device manager class object
* @return device manager object
*/
fun getDeviceManager(): IDeviceManager {
return deviceManager
}
/**
* getting drone device data object class connected with Remote Controller
* @return getting first device connected from drones
*/
fun getFirstDroneDevice(): IAutelDroneDevice? {
return deviceManager.getFirstDroneDevice()
}
}
/**
* coroutine scope of main thread
*/
private val coroutineScope = CoroutineScope(Dispatchers.Main)
/**
* available drone listener list
*/
private var droneListenerList = mutableListOf<IAutelDroneListener>()
/**
* available drone list
*/
private var droneDeviceList = mutableListOf<IAutelDroneDevice>()
/**
* available remote controller list
*/
private var remoteDeviceList = mutableListOf<IAutelRemoteDevice>()
/**
* available remote upgrade device list
*/
private var remoteUpgradeDeviceList = mutableListOf<IBaseDevice>()
/**
* available drone upgrade device list
*/
private var droneUpgradeDeviceList = mutableListOf<IBaseDevice>()
/**
* available nest device list
*/
private var nestDeviceList = mutableListOf<IAutelNestDevice>()
/**
* defined switch mode devices list here
*/
private var switchModeDeviceList = mutableListOf<IBaseDevice>()
/**
* defines state of initiate or not
*/
private var isInit = false
private val RETRY_MAX_COUNTS = 10
/**
* The time the plane disconnected
*/
private var mDisconnectTime = 0L
/**
* The number of retries. Only when the system initialization data is successfully obtained, will the app be notified that it is connected.
*/
private var retryCount = MAX_RETRY_COUNT
/**
* context object
*/
private var mContext: Context? = null
}
method createRemoterDevice
private fun createRemoterDevice()
Description: Add remote device
Input parameters: None。
Output parameters: None。
Related parameters: None。
method listenMatchCostTime
private fun listenMatchCostTime()
Description: Monitor the completion time of linking, used in SkyLink test
Input parameters: None。
Output parameters: None。
Related parameters: None。
method startRemoteUploadAndTimeSync
private fun startRemoteUploadAndTimeSync()
Description: Enable remote control frequency reporting and remote control time synchronization
Input parameters: None。
Output parameters: None。
Related parameters: None。
method rcTimeSync
private fun rcTimeSync()
Description: RC and APP time synchronization
Input parameters: None。
Output parameters: None。
Related parameters: None。
method getTimeZoneOffset
private fun getTimeZoneOffset(): Int
Description: Get the offset hours of the current time zone relative to the zero time zone
Input parameters: None。
Output parameters: Convert offset value to hours
Related parameters: None。
method createDroneDevice
private fun createDroneDevice()
Description: Add aircraft equipment
Input parameters: None.
Output parameters: None.
Related parameters: None.
method removeDroneDevice
private fun removeDroneDevice(device: IAutelDroneDevice)
Description: Remove aircraft equipment
Input parameters: device: drone device object to be removed
Output parameters: None.
Related parameters: None.
method getInitData
private fun getInitData(device: IAutelDroneDevice, retryCount: Int = RETRY_MAX_COUNTS)
Description: Starts init data of drone device
Input parameters: Device drone object
Output parameters: None.
Related parameters: None.
method iniCameraInfo
private fun iniCameraInfo(device: IAutelDroneDevice, retryCount: Int = RETRY_MAX_COUNTS)
Description: Camera capability set initialization
Input parameters: device: connected aircraft information retryCount: the number of retries to obtain camera information
Output parameters: None.
Related parameters: None.
method test
fun test()
Description: Performance testing uses
Input parameters: None.
Output parameters: None.
Related parameters: None.
method getDroneDeviceInfo
private fun getDroneDeviceInfo(device: IAutelDroneDevice, retryCount: Int = RETRY_MAX_COUNTS) {
Description: Getting drone device all info
Input parameters: device: drone device object retryCount: retry counter
Output parameters: None.
Related parameters: None.
method getCameraAbilityVersion
private fun getCameraAbilityVersion(model: String, retryCount: Int = RETRY_MAX_COUNTS)
Description: Get the camera capability set version number
Input parameters: model: camera model
Output parameters: None.
method initLocalAssetGson
private fun initLocalAssetGson()
Description: Directly parse local Asset data
Input parameters: None.
Output parameters: None.
Related parameters: None.
method downloadCameraAbilityFile
private fun downloadCameraAbilityFile(
model: String,
version: String,
oldVersion: String?,
sourcePath: String,
retryCount: Int = RETRY_MAX_COUNTS
)
Description: Download capability set file
Input parameters: model: camera model version: capability set version number oldVersion: local version number sourcePath: download path sourcePath: path of json file
Output parameters: None.
Related parameters: None.
method parseAndInformApp
fun private fun parseAndInformApp(file: File, model: String, version: String)
Description: Parse the camera capability set file and notify the app
Input parameters: file: camera json file model: camera model version: capability set version number
Output parameters: None.
Related parameters: None.
method setTimeZone
private fun setTimeZone(device: IAutelDroneDevice, retryCount: Int = RETRY_MAX_COUNTS)
Description: Synchronize system time to flight controller
Input parameters: device: drone device object
Output parameters: None.
Related parameters: None.
method listenCameraStatusMsg
private fun listenCameraStatusMsg(aircraftDevice: IBaseDevice)
Description: Listen camera status of drone
Input parameters: aircraftDevice: drone device base object
Output parameters: None.
Related parameters: None.