This document tells you how to stop USB services by using the USB Manager library.
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.
Basic Procedure
The high-level steps involved stopping USB services are shown here:
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:
an A-device, the time to stop USB services is after you have dropped VBus (see Dropping VBus). Your USB control application needs to drop VBus after the bus connection has remained idle for a certain period of time (see Monitoring whether the phone's bus connection is idle or busy).
a B-device, the time to stop USB services is when you detect that VBus is down (see Monitoring whether VBus is powered).
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();