Share via


Implementing Asynchronous Device Discovery (Windows Embedded CE 6.0)

1/6/2010

The OBEX protocol enables asynchronous device discovery.

To implement asynchronous device discovery

  1. Instantiate an IObex:IUnknown object.

  2. Instantiate and implement an IObexSink:IUnknown object.

  3. Provide a pointer to the IObexSink object to inform the IObex object, as follows:

    1. Query for the Windows Embedded CE IConnectionPointContainer interface.
    2. Call the IConnectionPointContainer::FindConnectionPoint method.
    3. Use the returned IConnection value to create the pointer.
  4. Use the IObex::StartDeviceEnum method to begin device enumeration. The IObexSink:IUnknown object receives a notification for each device arrival, departure, and update.

    When a remote device that supports OBEXenters the range of the local device, the IObexSink::Notify method is called. The method notifies the local device (local IObex:IUnknown object) of the arrival of the new device.

    The IObexSink::Notify method specifies one of the following values for the Event parameter.

    Value Description

    OE_DEVICE_ARRIVAL

    A new remote device has arrived within range of the local device.

    OE_DEVICE_DEPARTURE

    A previously listed remote device has left the range of the local device.

    The local device should release its pointer to the remote device and notify the user through the user interface that the remote device is no longer available.

    OE_DEVICE_UPDATE

    A remote device was initially located but did not provide complete information about itself.

  5. Do one of the following based on the value specified for the Event parameter:

    1. OE_DEVICE_ARRIVAL   Query for the remote device IPropertyBag to retrieve information about the device, such as the class ID of the transport and the name of the remote device. IPropertyBag is provided by the pUnk1 parameter for the IObexSink::Notify method.
      To bind the local device to the remote device, call the IObex::BindToDevice method and pass the property bag of the remote device to this method. IObex::BindToDevice returns a pointer, in the form of an IObexDevice:IUnknown interface, to the remote device. Call the IObexDevice::Connect method to connect to the remote device.
    2. OE_DEVICE_UPDATE   To retrieve information about the device, query for the remote device IPropertyBag.
  6. Call the IObex::StopDeviceEnum method to stop the device enumeration process at any point.

  7. Release the IObexSink::Notify object when the enumeration process is finished so that this object is unadvised to the IObex:IUnknown object.

See Also

Concepts

Discovering OBEX Devices

Other Resources

OBEX Application Development