KAccessoryModeChanged API
Article Metadata
Code Example
Article
Purpose
The services offered by DOS(Domestic OS) server can be accessed through DOS Client API. The services offered by DOS Client API are – Registering for listening and receiving DOS events, accessory related services, bluetooth audio related services etc.
Use cases
1. We can get notification when an accessory like wired headset, Bluetooth headset is connected or disconnected. We can listen to accessory mode change events using CDosEventListenerBase.
2. We can also listen to wired headset button events with CDosEventListenerBase
Example code
Header
#include <dossvrservices.h>// To access dos servicesLink against
LIBRARY dsclient.lib1. Derive from CDosEventListenerBase.
2. Connect to dos server session
RDosServer session;
session.Connect();
Usecase1: Get notification when an accessory is connected or disconnected
3. Start listening to accessory mode changed events.
StartListeningL(KAccessoryModeChanged,sizeof(TDosAccessoryMode),EOnlyLast);
4. Callback function AccessoryModeChangedL will be called whenever it detects an accessory.
void CDosServExampleAppUi::AccessoryModeChangedL(TDosAccessoryMode aAccessoryState)
{
switch(aAccessoryState)
{
case EDosAccNotConnected:
{
CEikonEnv::InfoWinL(_L("Accessory not connected"),_L(""));
break;
}
case EDosAccUnsupportedConnected:
{
CEikonEnv::InfoWinL(_L("Unsupported accessory"),_L(""));
break;
}
case EDosAccModeHeadset:
{
CEikonEnv::InfoWinL(_L("Wired Headset detected"),_L(""));
break;
}
};
}
Usecase2 :To listen to wired headset button events
3. Start listening to wired headset button change events
StartListeningL(KHeadsetButtonChanged,sizeof(EPSButtonState),EOnlyLast);
4. Callback function HeadsetButtonChangedL will be called whenever there is headset buttonpress.
void CDosServExampleAppUi::HeadsetButtonChangedL(EPSButtonState aState)
{
switch(aState)
{
case EPSButtonUp:
{
CEikonEnv::InfoWinL(_L("Button up event"),_L(""));
break;
}
case EPSButtonDown:
{
CEikonEnv::InfoWinL(_L("Button down event"),_L(""));
break;
}
case EPSButtonDownLongPress:
{
CEikonEnv::InfoWinL(_L("Long press "),_L(""));
break;
}
};
}


30 Sep
2009
DOS(DOmestic Server) Client API are useful to access service offered by DOS server. This article demonstrates the use of DOS Client API to get notification when an accessory mode changed(for example accessory is connected or disconnected ), with code example which helps to understand how this API can be used. Note that this API, DOS Client API, is not part of the public SDK. So you have to download it from SDK API Plug-in before using it. Furthermore, the author added a working demo project, which can be used for more detailed study of new opportunities for various kinds of experiments.
Q: What capabilities are needed for the application? Is it possible to make this work with selfsigned apps?