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:

  • device (required): The device object on which the operation has to be performed.
  • 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(
  device = device,
  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(
  device = device,
  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:

  • device (required): The device object on which the operation has to be performed.
InstaVision.deviceServices.stopPTZ(
  device = device,
  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:

  • device (required): The device object on which the operation has to be performed.
InstaVision.deviceServices.resetPTZ(
  device = device,
  onSuccess = {
    // The PTZ was reset successfully
  },
  onError = { error ->
    // The error object contains the error code and message
  },
)

Validate the SIM ID of a 4G device

To validate the sim number of a 4g device, The following method can be used:

  • spaceId (required): The space ID of the device.
  • request (required): The request object containing the sim number to validate.
InstaVision.deviceServices.validateSimId(
  spaceId = "spaceId",
  request = ValidateSimId(simNumber = "simNumber"),
  onSuccess = {
    // The sim id was validated successfully
  },
  onError = { error ->
    // The error object contains the error code and message
  },
)

Initiate a video call with a device

To initiate a video call with a device, The following method can be used:

  • device (required): The device object on which the operation has to be performed.
  • request (required): The request object containing the start time of the video call.
val request = InitiateVideoCallRequest(startTime = System.currentTimeMillis())
InstaVision.deviceServices.initiateVideoCall(
  device = device,
  request = request,
  onSuccess = { eventId ->
    // The id of the video call event
  },
  onError = { error ->
    // The error object contains the error code and message
  },
)

Update the status of a video call

To update the status of an ongoing video call, The following method can be used:

  • device (required): The device object on which the operation has to be performed.
  • eventId (required): The id of the video call event.
  • request (required): The request object containing the new status of the video call.
val request = UpdateVideoCallStatusRequest(status = "ended")
InstaVision.deviceServices.updateVideoCallStatus(
  device = device,
  eventId = "eventId",
  request = request,
  onSuccess = {
    // The video call status was updated successfully
  },
  onError = { error ->
    // The error object contains the error code and message
  },
)

This site uses Just the Docs, a documentation theme for Jekyll.