Device Control and Operations
Pre-requisite: The user has to be signed in to perform the following operations.
Operate PTZ of the Device
To move the PTZ of the device, The following method can be used:
spaceId(required): The space ID of the device.deviceId(required): The device ID.request(required): The request object containing the PTZ movement information.
val request = MoveRequest(
pan = MoveValue.NONE.value, // The pan value of the PTZ movement
tilt = MoveValue.UP.value, // The tilt value of the PTZ movement
nonStop = false // If the PTZ movement should be non-stop and continue till the stopPTZ method is called
)
InstaVision.deviceServices.ptzMove(
spaceId = "spaceId",
deviceId = "deviceId",
request = request,
onSuccess = {
// The PTZ movement was successful
},
onError = { error ->
// The error object contains the error code and message
},
)
if you have a device that is cluster based you need to pass the multiplier or the steps along with the direction.
val isFlipped = cluster.value?.rotationAngle() != 0 // To check if the device is flipped
val panFactor =
if (isNonStop) cluster.value?.panStep() ?: 0 else cluster.value?.pan() ?: -100 //-100 is a default value
val tiltFactor =
if (isNonStop) cluster.value?.tiltStep() ?: 0 else cluster.value?.tilt() ?: -50 //-50 is a default value
var request = MoveRequest(
pan = panFactor * panValue,
tilt = tiltFactor * tiltValue
)
if (isFlipped) {
request = request.copy(
pan = request.pan,
tilt = -request.tilt
)
}
InstaVision.deviceServices.ptzMove(
spaceId = "spaceId",
deviceId = "deviceId",
request = request,
onSuccess = {
// The PTZ movement was successful
},
onError = { error ->
// The error object contains the error code and message
},
)
Stop PTZ Movement
To stop the PTZ movement of the device, The following method can be used:
spaceId(required): The space ID of the device.deviceId(required): The device ID.
InstaVision.deviceServices.stopPTZ(
spaceId = "spaceId",
deviceId = "deviceId",
onSuccess = {
// The PTZ movement was stopped successfully
},
onError = { error ->
// The error object contains the error code and message
},
)
Reset PTZ to default position
To reset the PTZ of the device, The following method can be used:
spaceId(required): The space ID of the device.deviceId(required): The device ID.
InstaVision.deviceServices.resetPTZ(
spaceId = "spaceId",
deviceId = "deviceId",
onSuccess = {
// The PTZ was reset successfully
},
onError = { error ->
// The error object contains the error code and message
},
)
Wake Up Device from sleep state
To wake up the device, The following method can be used:
spaceId(required): The space ID of the device.deviceId(required): The device ID.
InstaVision.deviceServices.wakeUpDevice(
spaceId = "spaceId",
deviceId = "deviceId",
onSuccess = {
// The device wake up command was sent
},
onError = { error ->
// The error object contains the error code and message
},
)
Check if the device is awake
To check if the device is awake, The following method can be used:
spaceId(required): The space ID of the device.deviceId(required): The device ID.
InstaVision.deviceServices.isDeviceAwake(
spaceId = "spaceId",
deviceId = "deviceId",
onSuccess = { isAwake ->
// The device is awake
},
onError = { error ->
// The error object contains the error code and message
},
)
Wake Up all the battery devices in the space
To wake up all the battery devices in the space, The following method can be used:
spaceId(required): The space ID of the device.
InstaVision.deviceServices.wakeUpBatteryDevices(
spaceId = "spaceId",
onSuccess = {
// The wake up command was sent to all the battery devices
},
onError = { error ->
// The error object contains the error code and message
},
)