Stopping USB services

This document tells you how to stop USB services by using the USB Manager library.

Purpose

USB services are be stopped by a function call to the USB Manager. There are two methods for stopping USB services:

  • The intelligent method, which only executes if USB services are currently in the started state (in other words it does not execute if USB services are already in process of stopping, or indeed of starting). This is Symbian's recommended method.

  • The forced method, which executes even if USB services are in process either of starting or stopping; it is not recommended.

We recommend you always use the "intelligent" method.

Intended Audience

This document is for Symbian licensees who are implementing USB services, including host and On-The-Go (OTG) services, on a Symbian device.

Required Background

For details of, and links to, the USB and On-The-Go (OTG) specifications on the USB Implementers Forum website, see USB Manager library.

Setup and Configuration Requirements

The setup and configuration requirements for stopping USB services are no different from those for starting USB services (see Starting USB services). Note that you must not close a session to USB Manager before stopping USB services.

Using USB Manager to stop USB services

Basic Procedure

The high-level steps involved stopping USB services are shown here:

  1. Establish whether the conditions are appropriate for stopping USB services

  2. Stop USB services.

  3. Close the USB Manager session.

Stopping USB services

The conditions for stopping USB services

On a Symbian platform phone that is only capable of performing as a USB peripheral, if your USB-aware application (in other words, your application that watches for cable-insertions and removals) detects that the phone's device state is EUsbDeviceStateUndefined (see Monitoring the phone's status as a USB peripheral device), then it is time to stop USB services and close the session to USB Manager.

If the Symbian platform phone supports USB host/OTG services, then on:

Stopping USB services

When it is time to stop USB services because any of the above conditions are true, you need to call either RUsb::TryStop() (recommended) or RUsb::Stop() to de-activate and unload USB services.

Note: For OTG phones, when the Symbian platform phone is an A-device, you must always drop VBus (by using the RUsb::BusDrop() function) before stopping USB services (see Dropping VBus).

You can perform either an "intelligent" stop (recommended) or a "forced" stop of USB services:

  • Intelligent stop: RUsb::TryStop() stops USB services. (This is Symbian's recommended method.) This function only has an effect if USB services are currently in the started state.

    usb.BusDrop();        //Drop VBus
    usb.TryStop(status);  //Stop USB services (if they are running)
    usb.Close();          //Close the USB Manager session

    The RUsb::TryStop() function can only be called asynchronously.

  • Forced stop: RUsb::Stop() stops USB services. (This is not Symbian's recommended method.) This function executes even if USB services are already in the process of stopping or if USB services are currently starting up.

    usb.BusDrop();       //Drop VBus
    usb.Stop(status);    //Stop USB services (execute even if USB services are in process of starting or stopping)
    usb.Close();         //Close the USB Manager session

    The RUsb::Stop() function can be called synchronously or asynchronously.

Closing the USB Manager session

After you have stopped USB services you must close the session to USB Manager:

usb.Close();