I'm trying to activate the speakerphone on my HTC-derived (Qtek-8300) Smartphone 2003 with no success. So far, I've tried the following approaches.
TAPI:
After initializing TAPI and veryfing the device's capabilities I made the following call:
phoneSetHookSwitch(hPhone, PHONEHOOKSWITCHDEV_SPEAKER, PHONEHOOKSWITCHMODE_MICSPEAKER).
The call fails with PHONEERR_OPERATIONUNAVAIL despite the fact that the device should support this feature. In fact any phoneSetHookSwitch call fails regardless of the parameters supplied.
Synthesizeing key strokes
..by using keybd_event with both VK_F3 and VK_TSPEAKERPHONETOGGLE (VK_F16) although I read somewhere that HTC forgot to implement that key.
I thought I could open up the SIM-card and send AT-commands but I haven't been able to open a device that allows me to send AT commands directly to the phone. The driver, virser_atcmd.Dll, seems to be the correct one but failes when doing a CreateFile (Error 55).
The thing is that the phone's shell (or preinstalled phone app) is able to turn on the speakerphone (by pressing on hook key so apparently it Can be done.
I'm stuck on this one and I really hope you guys can help me out. Thanks.

Activating speakerphone on Windows Smartphone
BobbyVee
Then I just ran out of luck. I'm working with a Smartphone 2003 so it won't work. The key isn't even present in the registry.. and the IOCTLs for my specific device are not easy to come by. Aight, thank's for your help, I'm about to resign on this one although it's extremly annoying not to be able to fix this issue.
Andrei Gradinari
I tried changing the speaker value in registry on WM5 SP, but it did not work. speaker value is changing and even menu for Speaker on/off is also changing however, speaker is not tuning on or off.
Jean-Michel Bezeau
Im not 100% sure this will work, but I suspect the simpliest way to do this is to switch the profile. The speaker phone is just a profile [HKEY_CURRENT_USER\ControlPanel\Profiles]
struct __declspec(uuid("B7A5E609-3E46-442d-8D32-65926EDA6795")) ProfilesApp;
MIDL_INTERFACE("F13D0964-E2DA-4bba-BF1A-EED82BB948D3")
ITPCProfiles : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE SetActiveProfile(
LPCWSTR wszProfile,
HWND hwndOwner,
BOOL bHideOwnerBeforeSet) = 0;
};
ITPCProfiles* pProfiles = NULL;
HRESULT hr = CoCreateInstance(__uuidof(ProfilesApp), NULL, CLSCTX_INPROC_SERVER, __uuidof(ITPCProfiles), (LPVOID*)&pProfiles);
if(SUCCEEDED(hr) && pProfiles != NULL) {
// where ProfileName comes from the reg key
// HKEY_CURRENT_USER\ControlPanel\Profiles
hr = pProfiles->SetActiveProfile(ProfileName, NULL, FALSE);
pProfiles->Release();
pProfiles = NULL;
}
Ken Mcferren
Great idea!
Unfortunatelly that didn't work either. It really did change the profile to 'Speakerphone' but nothing else happened. I broadcasted a WM_WININICHANGE but still nothing. The thing is that the Speakerphone profile is present but can't be selected by the user. However, after the speakerphone is active (by pressent the hang up button) the check marker is present next to the Speakerphone item in the profiles menu.
Back to the lab...
Interesting piece of code by the way. I can't find any documentation about that interface!
Any other suggestions
Regards
/Pierre
Makemagic
How about trying a WM_SETTINGSCHANGE message after you set the profile
PostMessage( HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0 );
or how about trying the RIL interface.
// Selects the type of audio device currently in use (either. Handset, Headset, Speakerphone, or Carkit)
HRESULT RIL_SetAudioDevices(
HRIL hRil, // @parm handle to RIL instance returned by <f RIL_Initialize>
const RILAUDIODEVICEINFO* lpAudioDeviceInfo // @parm audio devices to set
);
zoki977
WM_SETTINGSCHANGE made no difference.
Moving on to RIL...
I successfully initialized the RIL and called RIL_SetAudioDevices:
RILAUDIODEVICEINFO audioDeviceInfo;
audioDeviceInfo.cbSize =
sizeof(RILAUDIODEVICEINFO);audioDeviceInfo.dwParams = RIL_PARAM_ADI_ALL;
audioDeviceInfo.dwRxDevice = RIL_AUDIO_SPEAKERPHONE;
audioDeviceInfo.dwTxDevice = RIL_AUDIO_SPEAKERPHONE;
hr = pRIL_SetAudioDevices(hRil, &audioDeviceInfo);
The callback reported success! But guess what, the speakerphone was not activated. I read a whitepaper from Intel that stated that a call to waveOutMessage should be carried out after RIL_SetAudioDevices. But since that function is vendor specific I have no idea on what to pass as parameters.
I also tried a different approach. RIL_GetSerialPortHandle returns a virtual serial port handle used for data communication according to the header file I snatched off the internet (Unfortunatelly I have no copy of platform builder). I tried WriteFile on the handle passing a basic AT command and the write succeeded. ReadFile returned EOF though.. So I guess that handle is to be used with DeviceIoControl only. So now I'm stuck again having no idea what control code to pass. Another potential useful function is RIL_DevSpecific but the same problem here. What to pass as parameters
So... I ask you again, any other suggestions Your suggestions are very appreciated!
jkristia
I have one last suggestion, assumming this is windows mobile 2005.
After you have set the profile to "Speakerphone", set the notification hardware key.
From the help file :-
In Windows Mobile Version 5.0, there are two ways to notify the Shell or a generic client of a device state change:
So try change the speaker to 1 in the reg key HKEY_LOCAL_MACHINE\System\State\Hardware, this should notify all interested apps that the profile has changed.