• Quick Start
  • Booting
  • Platform
  • Portals
  • References
    • API Reference TOI3
    • IIP Reference
  • Resources
ARRIS Enterprises, Inc. Confidential Information

ToiStorageService

Class Summary

Extends:
  • ToiEventTarget

The ToiStorageService interface provides access to all connected storage devices.

Service:

This is a service and can be accessed through toi.storageService
  • Methods
  • Members
  • Types
  • Events
  • Constants

Method Summary

getDevices ( )  → Array.<ToiStorageService.ToiDeviceInfo>

Returns the currently connected storage devices.

prepareDvrStorage ( callbacks , deviceId )  → operation

Prepare a device for DVR/timeshift usage. This may include partitioning, formatting and enabling the device for DVR/timeshift. The device will enter ToiStorageService.DEVICE_STATE_BUSY, then it goes through ToiStorageService.DEVICE_STATE_CONNECTING to its final state, which will be notified by ToiStorageDeviceStateChangedEvent.

If the operation has successfully completed, the device will be in state ToiStorageService.DEVICE_STATE_DVR_STORAGE.

If the operation fails, the reason will be indicated in the operation's error code.

prepareForRemoval ( callbacks , deviceId )  → operation

Release a device to prepare for physical removal. The device will enter ToiStorageService.DEVICE_STATE_BUSY firstly. If the operation has successfully completed, the device will be in ToiStorageService.DEVICE_STATE_SAFE_TO_REMOVE and safe to be removed.

reconnect ( callbacks , deviceId )  → operation

Reconnect the device which is ready to remove.

If the operation has successfully completed, the device will be in one of the states ToiStorageService.DEVICE_STATE_DVR_STORAGE, ToiStorageService.DEVICE_STATE_CONTENT_STORAGE, and ToiStorageService.DEVICE_STATE_UNUSABLE.

The final state will be indicated by ToiStorageDeviceStateChangedEvent.

repair ( callbacks , deviceId )  → operation

Attempt repair of the given storage device. The device will enter ToiStorageService.DEVICE_STATE_BUSY, then it goes through ToiStorageService.DEVICE_STATE_CONNECTING to its final state, which will be notified by ToiStorageDeviceStateChangedEvent.

If the operation has successfully completed, the device will be in state ToiStorageService.DEVICE_STATE_DVR_STORAGE or ToiStorageService.DEVICE_STATE_CONTENT_STORAGE.

If the operation fails, the reason will be indicated in the operation's error code.

Inherited Methods

addEventListener ( type , listener )

This method registers an event listener for a specific event. Multiple listeners can be added for the same event. Events are broadcast to all registered listeners.

removeEventListener ( type , listener )

This method removes an event listener for a specific event.

Type Definitions

ToiDeviceId (Type: string)

Type for the unique storage device identifier.

ToiDeviceState (Type: enum)

This represents the different kinds of states a storage device can be in.

  • DEVICE_STATE_BUSY
  • DEVICE_STATE_CONNECTING
  • DEVICE_STATE_CONTENT_STORAGE
  • DEVICE_STATE_DVR_STORAGE
  • DEVICE_STATE_SAFE_TO_REMOVE
  • DEVICE_STATE_UNUSABLE
ToiFileSystemStatus (Type: enum)

This represents the different kinds of file system status a storage device can have.

  • FILE_SYSTEM_STATUS_ERRORS_CORRECTED
  • FILE_SYSTEM_STATUS_ERRORS_LEFT_UNCORRECTED
  • FILE_SYSTEM_STATUS_MAJOR_FAILURE
  • FILE_SYSTEM_STATUS_OK
ToiHealth (Type: enum)

Indicates the health of a storage device.

  • HEALTH_DETECT_FAILURE
  • HEALTH_DEVICE_FAILURE
  • HEALTH_IO_ERROR
  • HEALTH_OK

Events

  • ON_DEVICE_ADDED
  • ON_DEVICE_FULL
  • ON_DEVICE_REMOVED
  • ON_DEVICE_STATE_CHANGED
  • ON_DEVICE_TEMPERATURE_REACHED

Constants

  • OP_ERROR_FILE_SYSTEM_CHECK_FAILURE
  • OP_ERROR_MOUNT_FAILURE
  • OP_ERROR_PARTITION_FAILURE
  • OP_ERROR_UNMOUNT_FAILURE
  • REASON_DEVICE_INIT
  • REASON_ERROR_FILE_SYSTEM_NOT_SUPPORTTED
  • REASON_ERROR_IO_FAILURE
  • REASON_ERROR_OTHER
  • REASON_STANDARD_REQUEST

Methods

addEventListener ( type , listener )

This method registers an event listener for a specific event. Multiple listeners can be added for the same event. Events are broadcast to all registered listeners.

Inherited From:

  • ToiEventTarget#addEventListener

Parameters:

Name Type Description
type number

The event type of the event to subscribe to.

listener ToiEventListener

The JavaScript function that will receive events.

Throws:

ToiInvalidArgumentException Raised if the event type is not supported by this object or if the listener is not a valid JavaScript function. This exception is also raised if the application calls addEventListener with the same combination of type and listener twice.

getDevices ( )  → Array.<ToiStorageService.ToiDeviceInfo>

Returns the currently connected storage devices.

Returns:

The connected storage devices.

Type: Array.<ToiStorageService.ToiDeviceInfo>
prepareDvrStorage ( callbacks , deviceId )  → operation

Prepare a device for DVR/timeshift usage. This may include partitioning, formatting and enabling the device for DVR/timeshift. The device will enter ToiStorageService.DEVICE_STATE_BUSY, then it goes through ToiStorageService.DEVICE_STATE_CONNECTING to its final state, which will be notified by ToiStorageDeviceStateChangedEvent.

If the operation has successfully completed, the device will be in state ToiStorageService.DEVICE_STATE_DVR_STORAGE.

If the operation fails, the reason will be indicated in the operation's error code.

Note:

Be very careful to use this method because it will wipe any existing data.

Parameters:

Name Type Description
callbacks AsyncCallback

Object with callback functions for the asynchronous operation. No result is produced by this method, so callbacks.onResult() will not be invoked.

deviceId ToiStorageService.ToiDeviceId

The identifier for the device to be prepared.

Throws:

ToiInvalidArgumentException

Raised if the operation identifier is invalid. Raised if the device identifier is invalid.

ToiOperationNotSupportedException

Raised if the operation is not supported on this device due to hardware limitations.

ToiInvalidPreconditionException

Raised if the device is not in ToiStorageService.DEVICE_STATE_DVR_STORAGE, ToiStorageService.DEVICE_STATE_CONTENT_STORAGE, or ToiStorageService.DEVICE_STATE_UNUSABLE.

Returns:

operation The asynchronous operation created by the function.

Type: ToiAsynchronousOperation
prepareForRemoval ( callbacks , deviceId )  → operation

Release a device to prepare for physical removal. The device will enter ToiStorageService.DEVICE_STATE_BUSY firstly. If the operation has successfully completed, the device will be in ToiStorageService.DEVICE_STATE_SAFE_TO_REMOVE and safe to be removed.

See also:

  • ToiStorageService#reconnect

Parameters:

Name Type Description
callbacks AsyncCallback

Object with callback functions for the asynchronous operation. No result is produced by this method, so callbacks.onResult() will not be invoked.

deviceId ToiStorageService.ToiDeviceId

The identifier for the device prepared for removal.

Throws:

ToiInvalidArgumentException

Raised if the operation identifier is invalid. Raised if the device identifier is invalid.

ToiInvalidPreconditionException

Raised if the device is in ToiStorageService.DEVICE_STATE_BUSY or ToiStorageService.DEVICE_STATE_SAFE_TO_REMOVE.

Returns:

operation The asynchronous operation created by the function.

Type: ToiAsynchronousOperation
reconnect ( callbacks , deviceId )  → operation

Reconnect the device which is ready to remove.

If the operation has successfully completed, the device will be in one of the states ToiStorageService.DEVICE_STATE_DVR_STORAGE, ToiStorageService.DEVICE_STATE_CONTENT_STORAGE, and ToiStorageService.DEVICE_STATE_UNUSABLE.

The final state will be indicated by ToiStorageDeviceStateChangedEvent.

Parameters:

Name Type Description
callbacks AsyncCallback

Object with callback functions for the asynchronous operation. No result is produced by this method, so callbacks.onResult() will not be invoked.

deviceId ToiStorageService.ToiDeviceId

The identifier for the device prepared for removal.

Throws:

ToiInvalidArgumentException

Raised if the operation identifier is invalid. Raised if the device identifier is invalid.

ToiInvalidPreconditionException

Raised if the device is not in ToiStorageService.DEVICE_STATE_SAFE_TO_REMOVE.

Returns:

operation The asynchronous operation created by the function.

Type: ToiAsynchronousOperation
removeEventListener ( type , listener )

This method removes an event listener for a specific event.

Inherited From:

  • ToiEventTarget#removeEventListener

Parameters:

Name Type Description
type number

The event type of the event to remove the listener from.

listener ToiEventListener

The JavaScript function that was previously added as an event listener.

Throws:

ToiInvalidArgumentException Raised if the event type is not supported by this object or if the listener is not a valid JavaScript function. This exception is also raised if the listener has not previously been added.

repair ( callbacks , deviceId )  → operation

Attempt repair of the given storage device. The device will enter ToiStorageService.DEVICE_STATE_BUSY, then it goes through ToiStorageService.DEVICE_STATE_CONNECTING to its final state, which will be notified by ToiStorageDeviceStateChangedEvent.

If the operation has successfully completed, the device will be in state ToiStorageService.DEVICE_STATE_DVR_STORAGE or ToiStorageService.DEVICE_STATE_CONTENT_STORAGE.

If the operation fails, the reason will be indicated in the operation's error code.

Parameters:

Name Type Description
callbacks AsyncCallback

Object with callback functions for the asynchronous operation. No result is produced by this method, so callbacks.onResult() will not be invoked.

deviceId ToiStorageService.ToiDeviceId

The identifier for the device to be repaired.

Throws:

ToiInvalidArgumentException

Raised if the operation identifier is invalid. Raised if the device identifier is invalid.

ToiInvalidPreconditionException

Raised if the device is not in ToiStorageService.DEVICE_STATE_DVR_STORAGE, or ToiStorageService.DEVICE_STATE_UNUSABLE.

Returns:

operation The asynchronous operation created by the function.

Type: ToiAsynchronousOperation

Members

ON_DEVICE_ADDED (Type: ToiStorageDeviceAddedEvent) (value = 2608) (static, constant)

This is an Event identifier for ToiStorageDeviceAddedEvent.

This notification is sent when a storage device has been added to the system.

This constant can also be accessed from toi.consts.ToiStorageService.ON_DEVICE_ADDED.
ON_DEVICE_FULL (Type: ToiStorageDeviceFullEvent) (value = 2611) (static, constant)

This is an Event identifier for ToiStorageDeviceFullEvent.

This notification is sent when an HDD runs out of free storage space. The callback will occur periodically as long as the HDD is full and operations such as DVR recordings will not be possible until the requested number of bytes are freed. When this has been resolved, the callback will occur a final time with spaceRequired set to 0 to indicate that enough free space is now available.

This constant can also be accessed from toi.consts.ToiStorageService.ON_DEVICE_FULL.
ON_DEVICE_REMOVED (Type: ToiStorageDeviceRemovedEvent) (value = 2609) (static, constant)

This is an Event identifier for ToiStorageDeviceRemovedEvent.

This notification is sent when a storage device has been physically removed from the system. The device will no longer be available in the list of connected storage devices by ToiStorageService#getDevices.

There is no specific state to represent a device that has been removed from the system, so the state in the provided device information will be the state the device had when the actual removal occurred.

This constant can also be accessed from toi.consts.ToiStorageService.ON_DEVICE_REMOVED.
ON_DEVICE_STATE_CHANGED (Type: ToiStorageDeviceStateChangedEvent) (value = 2610) (static, constant)

This is an Event identifier for ToiStorageDeviceStateChangedEvent.

This notification is sent when a storage device has changed state. The reason can be mapped to the defined reason constants.

This constant can also be accessed from toi.consts.ToiStorageService.ON_DEVICE_STATE_CHANGED.
ON_DEVICE_TEMPERATURE_REACHED (Type: ToiStorageDeviceTemperatureReachedEvent) (value = 2612) (static, constant)

This is an Event identifier for ToiStorageDeviceTemperatureReachedEvent.

This notification is sent when some predefined HDD temperature threshold has been reached.

This constant can also be accessed from toi.consts.ToiStorageService.ON_DEVICE_TEMPERATURE_REACHED.
DEVICE_STATE_BUSY (Type: ToiStorageService.ToiDeviceState) (value = 4) (static, constant)

A maintenance operation is ongoing (formatting, repair etc).

This constant can also be accessed from toi.consts.ToiStorageService.DEVICE_STATE_BUSY.
DEVICE_STATE_CONNECTING (Type: ToiStorageService.ToiDeviceState) (value = 0) (static, constant)

The device is in the process of being connected. This is an interim state. Once connected/requested, device will try to mount and finally enter any of ToiStorageService.DEVICE_STATE_DVR_STORAGE, ToiStorageService.DEVICE_STATE_CONTENT_STORAGE, and ToiStorageService.DEVICE_STATE_UNUSABLE, or unmount to ToiStorageService.DEVICE_STATE_SAFE_TO_REMOVE.

This constant can also be accessed from toi.consts.ToiStorageService.DEVICE_STATE_CONNECTING.
DEVICE_STATE_CONTENT_STORAGE (Type: ToiStorageService.ToiDeviceState) (value = 2) (static, constant)

The device has been connected as a generic content storage in the system.

This constant can also be accessed from toi.consts.ToiStorageService.DEVICE_STATE_CONTENT_STORAGE.
DEVICE_STATE_DVR_STORAGE (Type: ToiStorageService.ToiDeviceState) (value = 1) (static, constant)

The device has been connected as a DVR storage in the system.

This constant can also be accessed from toi.consts.ToiStorageService.DEVICE_STATE_DVR_STORAGE.
DEVICE_STATE_SAFE_TO_REMOVE (Type: ToiStorageService.ToiDeviceState) (value = 5) (static, constant)

The system has released all dependencies to the storage device and will gracefully handle a physical removal of the device.

This constant can also be accessed from toi.consts.ToiStorageService.DEVICE_STATE_SAFE_TO_REMOVE.
DEVICE_STATE_UNUSABLE (Type: ToiStorageService.ToiDeviceState) (value = 3) (static, constant)

The storage device has not been recognized or fulfilled the criteria to be connected as a storage for recordings or other content, possibly due to errors, access failures or unsupported file system. Until application has taken further actions it is not usable from a platform perspective.

This constant can also be accessed from toi.consts.ToiStorageService.DEVICE_STATE_UNUSABLE.
FILE_SYSTEM_STATUS_ERRORS_CORRECTED (Type: ToiStorageService.ToiFileSystemStatus) (value = 1) (static, constant)

The file system had errors but they have been corrected.

This constant can also be accessed from toi.consts.ToiStorageService.FILE_SYSTEM_STATUS_ERRORS_CORRECTED.
FILE_SYSTEM_STATUS_ERRORS_LEFT_UNCORRECTED (Type: ToiStorageService.ToiFileSystemStatus) (value = 2) (static, constant)

The file system had errors that could not be corrected. A reformat is required to get the file system working.

This constant can also be accessed from toi.consts.ToiStorageService.FILE_SYSTEM_STATUS_ERRORS_LEFT_UNCORRECTED.
FILE_SYSTEM_STATUS_MAJOR_FAILURE (Type: ToiStorageService.ToiFileSystemStatus) (value = 3) (static, constant)

The file system is completely broken or not supported.

This constant can also be accessed from toi.consts.ToiStorageService.FILE_SYSTEM_STATUS_MAJOR_FAILURE.
FILE_SYSTEM_STATUS_OK (Type: ToiStorageService.ToiFileSystemStatus) (value = 0) (static, constant)

No errors discovered on the file system.

This constant can also be accessed from toi.consts.ToiStorageService.FILE_SYSTEM_STATUS_OK.
HEALTH_DETECT_FAILURE (Type: ToiStorageService.ToiHealth) (value = 1) (static, constant)

The device was expected to be found but could not be detected.

This constant can also be accessed from toi.consts.ToiStorageService.HEALTH_DETECT_FAILURE.
HEALTH_DEVICE_FAILURE (Type: ToiStorageService.ToiHealth) (value = 2) (static, constant)

The device reported S.M.A.R.T errors or other fatal failures.

This constant can also be accessed from toi.consts.ToiStorageService.HEALTH_DEVICE_FAILURE.
HEALTH_IO_ERROR (Type: ToiStorageService.ToiHealth) (value = 3) (static, constant)

The device reported ATA errors or other low-level I/O communication errors.

This constant can also be accessed from toi.consts.ToiStorageService.HEALTH_IO_ERROR.
HEALTH_OK (Type: ToiStorageService.ToiHealth) (value = 0) (static, constant)

The device reported no problems.

This constant can also be accessed from toi.consts.ToiStorageService.HEALTH_OK.
OP_ERROR_FILE_SYSTEM_CHECK_FAILURE (Type: ToiOperationManager.ToiOperationError) (value = -6) (static, constant)

Operation failure due to file system check related errors.

This constant can also be accessed from toi.consts.ToiStorageService.OP_ERROR_FILE_SYSTEM_CHECK_FAILURE.
OP_ERROR_MOUNT_FAILURE (Type: ToiOperationManager.ToiOperationError) (value = -3) (static, constant)

Operation failure due to mount related errors.

This constant can also be accessed from toi.consts.ToiStorageService.OP_ERROR_MOUNT_FAILURE.
OP_ERROR_PARTITION_FAILURE (Type: ToiOperationManager.ToiOperationError) (value = -5) (static, constant)

Operation failure due to partition management related errors.

This constant can also be accessed from toi.consts.ToiStorageService.OP_ERROR_PARTITION_FAILURE.
OP_ERROR_UNMOUNT_FAILURE (Type: ToiOperationManager.ToiOperationError) (value = -4) (static, constant)

Operation failure due to unmount related errors.

This constant can also be accessed from toi.consts.ToiStorageService.OP_ERROR_UNMOUNT_FAILURE.
REASON_DEVICE_INIT (Type: string) (value = 'DeviceInit') (static, constant)

State change due to connecting the device.

This constant can also be accessed from toi.consts.ToiStorageService.REASON_DEVICE_INIT.
REASON_ERROR_FILE_SYSTEM_NOT_SUPPORTTED (Type: string) (value = 'ErrorFileSystemNotSupported') (static, constant)

Failure due to unsupported file system.

This constant can also be accessed from toi.consts.ToiStorageService.REASON_ERROR_FILE_SYSTEM_NOT_SUPPORTTED.
REASON_ERROR_IO_FAILURE (Type: string) (value = 'ErrorIoFailure') (static, constant)

Failure due to low level IO errors.

This constant can also be accessed from toi.consts.ToiStorageService.REASON_ERROR_IO_FAILURE.
REASON_ERROR_OTHER (Type: string) (value = 'ErrorOther') (static, constant)

Failure due to other reasons.

This constant can also be accessed from toi.consts.ToiStorageService.REASON_ERROR_OTHER.
REASON_STANDARD_REQUEST (Type: string) (value = 'StandardRequest') (static, constant)

State change due to requested by application.

This constant can also be accessed from toi.consts.ToiStorageService.REASON_STANDARD_REQUEST.
ToiDeviceInfo (Type: struct) (static)

Information about the storage device itself.

Struct fields

Name Description
capacity

Total disk space on storage device.

Type: number
health
[optional]

Indicates the health of the storage device.

Type: ToiStorageService.ToiHealth
id

A unique identfier of the storage device. The identifier value is a hash created based on static information from the storage device to ensure it is reasonably unique and persistent between reboots if no major change to the device has been made.

Type: ToiStorageService.ToiDeviceId
isApproved

True if this device is supported by Arris.

Type: boolean
model

Persistent device model.

Type: string
serialNumber

Persistent storage identification.

Type: string
state

The current device state.

Type: ToiStorageService.ToiDeviceState
status
[optional]

Detailed storage information for a device when it has reached ToiStorageService.DEVICE_STATE_DVR_STORAGE.

Type: ToiStorageService.ToiStorageStatus
temperature
[optional]

Current storage temperature. It will only be set if S.M.A.R.T support is available.

Type: number

ToiStorageStatus (Type: struct) (static)

Information about the storage status.

Struct fields

Name Description
fileSystemStatus

Partition file system check result from last connection.

Type: ToiStorageService.ToiFileSystemStatus
freeCapacity

This is the amount of space currently available.

Type: number
isWritable

Set to true if file system is mounted as read/write.

Type: boolean

Events

ON_DEVICE_ADDED ( )

This is an Event identifier for ToiStorageDeviceAddedEvent.

Value: 2608

ON_DEVICE_FULL ( )

This is an Event identifier for ToiStorageDeviceFullEvent.

Value: 2611

ON_DEVICE_REMOVED ( )

This is an Event identifier for ToiStorageDeviceRemovedEvent.

Value: 2609

ON_DEVICE_STATE_CHANGED ( )

This is an Event identifier for ToiStorageDeviceStateChangedEvent.

Value: 2610

ON_DEVICE_TEMPERATURE_REACHED ( )

This is an Event identifier for ToiStorageDeviceTemperatureReachedEvent.

Value: 2612

5.1.1.p8

Copyright (c) 2018 ARRIS Enterprises, LLC. All Rights Reserved. ARRIS Enterprises, LLC. Confidential Information.