OWLIFT Library for Android: UsbOwliftHost Class Reference
OWLIFT Library for Android  1.8.0.0
Top Page
List of all members | Classes | Public Member Functions | Static Public Member Functions
UsbOwliftHost Class Reference

Classes

interface  Callback
 

Public Member Functions

void onCreate ()
 
void onDestroy ()
 
UsbOwliftDev.Collection getDevs ()
 
void close ()
 
UsbOwliftDev openDev (ContextWrapper contextWrapper, long timeoutMSecWaitUntilDeviceFound, Callback cb) throws OwliftException
 

Static Public Member Functions

static UsbOwliftHost getUsbHost (Context c) throws OwliftException
 

Detailed Description

A class for USB Host.

      To access USB device, please follow the criteria below.<br>


  1. Gets UsbOwliftHost by getUsbHost().

  2. Calls openDev().

  3. Returns target UsbOwliftDev by calling selectDev() in UsbOwliftHost.Callback.

  4. Gets target UsbOwliftFunc from UsbOwliftDev that got by openDev(). UsbOwliftFunc is a parent class of UvcOwliftFunc. Uses UsbOwliftDev.getFuncs() to get USB function.

  5. Communicates with USB Device by operating UsbOwliftFunc that casted to UvcOwliftFunc. For examples, start video streaming by UvcOwliftFunc.startStream().

  6. Calls close() before exit from application.


    [Restrictions]
    • Could not stop streaming once start streaming on USB device, except closing all devices by calling close().
    • Must re-do all criteria from getUsbHost() to restart streaming.
    • Reconnects USB device and reset USB device permission if call close(). It will take more than several seconds to finish close() processing.

Member Function Documentation

◆ close()

void close ( )

Discards this object.

◆ getDevs()

UsbOwliftDev.Collection getDevs ( )

Returns connecting device list on UsbHost.

Returns
connecting device list.

◆ getUsbHost()

static UsbOwliftHost getUsbHost ( Context  c) throws OwliftException
static

Returns UsbOwliftHost object.

Parameters
cContext object. Passes Activity in nominal case.
Returns
UsbOwliftHost object.
Exceptions
OwliftException

◆ onCreate()

void onCreate ( )

Must call this method in Activity.onCreate().

This method is doing mandatory processing for UsbHost terminal.

◆ onDestroy()

void onDestroy ( )

Must call this method in Activity.onDestroy().

This method is doing mandatory processing for UsbHost terminal.
This method fully release native resource. So, process is halting in some terminal. Don't call this method if you would not like to halt the process.

◆ openDev()

UsbOwliftDev openDev ( ContextWrapper  contextWrapper,
long  timeoutMSecWaitUntilDeviceFound,
Callback  cb 
) throws OwliftException

Opens USB device.

Display permission dialog if no permission for USB device.

Parameters
contextWrapper
ContextWrapper to register BroadcastReceiver. passes Activity usually. This uses to display dialog for USB permission.
timeoutMSecWaitUntilDeviceFoundwaiting time for device detection in milliseconds.
cbCallback.
Returns
UsbDev if success to open UsbDev that returned from callback. if failed to open, exception will occur(not return NULL).
Exceptions
OwliftExceptionUsbOwliftExceptionCode.NO_DEVICE_FOUND : no device found.
UsbOwliftExceptionCode.NO_DEVICE_SELECTED : cb.selectDev() in callback returns NULL.
UsbOwliftExceptionCode.FAILED_OPEN_DEVICE : failed to open device due to lack of permission.