Turning Phone On and Off - Windows Mobile Development and Hacking General

Hey,
I have seen several posts on this topic but i didnt not find what I was looking for. I created a simple Dialog in eVC++3.0 and would like to programatically turn phone (radio) on/off so not to drain the battery.
I have come accross several methods. The method I am using now:
BOOL CTest9Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
.
.
.
.
lineOpen( HLINEAPP hLineApp,
DWORD dwDeviceID,
LPHLINE lphLine,
DWORD dwAPIVersion,
DWORD dwExtVersion,
DWORD dwCallbackInstance,
DWORD dwPrivileges,
DWORD dwMediaModes,
LPLINECALLPARAMS const lpCallParams );
lineNegotiateExtVersion(
HLINEAPP hLineApp,
DWORD dwDeviceID,
DWORD dwAPIVersion,
DWORD dwExtLowVersion,
DWORD dwExtHighVersion,
LPDWORD lpdwExtVersion );
//Turns radio on
lineSetEquipmentState(hLine, LINEEQUIPSTATE_FULL);
}
Is that the best method??

You can also do this using key events but Im having troulbe finding the correct keys. I been tryin to contact the OEM (Siemens) but calling them is fruitless.

Hello could it be possible you send me your simple applicaiton which turns on/off the phone ? I try but it didn't work ...

Related

RIL - Telepfone

Hi,
here my second problem :?
Has someone of you an idea how to Answer a call automaticly? I tried RIL_Answer and it seams to work, but i can't talk because the speaker and micro seems to be off.
Also I tried to dial with RIL_Dial - but there seems nothing to go on.
Greetings from hanovre again and
many many thanks for every idea
Andreas )
PS: Is there somewhere a RIL-Command to send AT-Commands directly (in text, not in HEX)?
PS: Is there somewhere a RIL-Command to send AT-Commands directly (in text, not in HEX)?
Click to expand...
Click to collapse
unfortunately there is not.
auto-answer
to make auto answer of phone call, just simulate the hardware key is pressed. not too hard to write in mVC+.
the question is: what next?
auto-answer works fine when you can switch to the speakerphone mode automatically right after the software did pick-up the call
I cannot do that, I tried in several ways but it is not working.
I cannot simulate "longer-press" of hardware buttons as you know you can turn on/off the speakerphone mode
Hi.
I'm also trying to use RIL_Dial. The way I'm running this function is:
RIL_Dial (g_hRil, (CHAR*)_T("696761699"), RIL_CALLTYPE_VOICE, RIL_DIALOPT_NONE)
My XDA seems to accept and try to establish the call since it opens the phone interface (without displaying the passed number). But then I get this answer back from the phone: UNKNOWN APPLICATION
Anyone knows how I can establish a call with this function?
Thanks,
Erik.
@ballrock2:
To answer a call using RIL_Answer do this:
- Call RIL_Answer
- Sleep(100)
- Send a VK_F4 down
- Sleep(100)
- Send a VK_F4 Up
You can then talk.
Quan
does not works
you dream,
keybd_event(VK_F4, MapVirtualKey(VK_F4, 0), 0, 0);
return one shot of button down emulation
no matter how long you are awaiting for the next
keybd_event(VK_F4, MapVirtualKey(VK_F4, 0), KEYEVENTF_KEYUP | KEYEVENTF_SILENT, 0);
so, in this way we cannot emulate tap-and-hold of the green phone button to turn on the speakerphone mode
can you explain or just post how you managed to initialize RIL ?? i dont seem to figure it out !!
thanks.
nutitija
Use Search
In Last Time
/*
callback for result of async functions
*/
void CALLBACK ril_result_callback(DWORD dwCode, HRESULT hrCmdID, const void* lpData, DWORD cbData, DWORD dwParam)
{
....
}
/*
callback for phony notifications (like incoming call)
*/
void CALLBACK ril_notify_callback(DWORD dwCode, const void* lpData, DWORD cbData, DWORD dwParam)
{
...
}
...
HRIL ril = NULL;
......
/*
1 - for RIL1: device
RIL1: device for COM2: device
*/
if (RIL_Initialize(1, ril_result_callback, ril_notify_callback, RIL_NCLASS_CALLCTRL | RIL_NCLASS_NETWORK | RIL_NCLASS_SUPSERVICE | RIL_NCLASS_RADIOSTATE, 0, &ril) < 0)
return;
.....
ok i kinda got the whole idea of it now, this is my implementation to try to initialize RIL however i get the following error :
error C2660: 'RIL_Initialize' : function does not take 6 parameters
Anybody can help me here ? i'm guessing maybe gotta do something with the RIL header file or lib or exp ?
************************************************
// Global Variables
HRESULT result;
DWORD dwNotificationClasses = 0xFF0000;
DWORD g_dwParam = 0x55AA55AA;
HRIL g_hRil = NULL;
// RL initilize
void CTerminalDlg::RIL_Initialize()
{
result = RIL_Initialize(1, ril_result_callback, ril_notify_callback, dwNotificationClasses, g_dwParam, &g_hRil);
}
************************************************
// Global Variables
HRESULT result;
DWORD dwNotificationClasses = 0xFF0000;
DWORD g_dwParam = 0x55AA55AA;
HRIL g_hRil = NULL;
// RL initilize
void CTerminalDlg::RIL_Initialize()
{
result = ::RIL_Initialize(1, ril_result_callback, ril_notify_callback, dwNotificationClasses, g_dwParam, &g_hRil);
}
learn C++

Turn ON/OFF BT/Widcomm on BA with eVc

Does anyone know how to turn on and off the Widcomm bluetooth on a Blue Angel from within C/eVc? :?:
tia
The only official way to turn off the radio is to destroy the last of the BT objects using the stack (the stack is object orientated, creating an object turns it on, destroying the lst object turns it off, this assumes you have the widcomm SDK). The problem is that the BT app that runs in the system tray (and shows you that bluetooth icon in the bottom left) owns a stack object that you cant properly destroy, hence you can't turn the radio off.
hrm...
If the tray app wasn't running, theres a function in the wbtapiCE.dll called UnloadStack ([email protected]@@[email protected]@[email protected]) which should force the stack to unload and probably turn off the radio.
So we might be able to turn it OFF this way. And how do we turn in ON again ;-)
Theres a corrasponding LoadStack ([email protected]@@[email protected]@[email protected]) which would do the job.
Each of these accept two parameters, the first appears to be a pointer to a class, the second a numeric value.
For the class pointer, it appears that you can define an 8 byte array and call the constructor ( [email protected]@[email protected] ) on it, remember to call the destructor ( [email protected]@[email protected] ) when your done. The hex value appears to be 0x123456 for LoadStack and 0x654321 for UnloadStack.
I really don't know how successfull you would be starting the stack yourself, spinning up the BT tray app, then killing it and shutting down the stack, you may find you have to replace all the functionality of the tray app yourself.
Complicated stuff. I might be easier off doing FindWindow on the BtApp and find the ON and OFF buttons and programatically press them.
Hello All.
I call wbtapiCE.dll functions for on/off BT on dell axim x30.
I use, two dll metods
[email protected]@@[email protected]@[email protected] == public: enum WBtRc __cdecl CWBtAPI::UnloadStack(unsigned int)
and
>> [email protected]@@[email protected]@[email protected] == public: enum WBtRc __cdecl CWBtAPI::LoadStack(unsigned int)
But no positive effect.
Anybody know what i doing wrong?
Sample code below:
{
CString szDllPath = _T("wbtapiCE.dll");
HMODULE hMod = LoadLibrary(szDllPath);
if(hMod==NULL)
{
AfxMessageBox(_T("LoadLibrary Failed !!!"));
}
//__cdecl CWBtAPI::CWBtAPI(void)
typedef void (CWBtAPI::*PFNCreateCWBt)();
typedef void (CWBtAPI::*PFNDestructorOfCWBt)();
typedef int (CWBtAPI::*PFNLoadCWBt)(unsigned int);
typedef int (CWBtAPI::*PFNUnLoadCWBt)(unsigned int);
//>> >> [email protected]@@[email protected]@[email protected] == public: enum WBtRc __cdecl CWBtAPI::UnloadStack(unsigned int)
CWBtAPI* a1 = (CWBtAPI*)_alloca(sizeof(CWBtAPI));
PFNCreateCWBt pfnCreateWBt = force_cast<PFNCreateCWBt>(GetProcAddress(hMod, TEXT("[email protected]@[email protected]")));
(a1->*pfnCreateWBt)();
//////////////////////////////////////////////////////////////////////////
PFNUnLoadCWBt pfnUnLoadA = force_cast<PFNUnLoadCWBt>(GetProcAddress(hMod, TEXT("[email protected]@@[email protected]@[email protected]")));
AfxMessageBox(_T("Started pfnUnLoadA"));
int result = (a1->*pfnUnLoadA)( 0x654321);
CString err = _T("Done pfnUnLoadA");
AfxMessageBox(err );
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
PFNLoadCWBt pfnLoadA = force_cast<PFNLoadCWBt>(GetProcAddress(hMod, TEXT("[email protected]@@[email protected]@[email protected]")));
AfxMessageBox(_T("Started pfnLoadA"));
result = (a1->*pfnLoadA)(0x123456);
AfxMessageBox(_T("Done pfnLoadA"));
//////////////////////////////////////////////////////////////////////////
PFNDestructorOfCWBt pfnDestA = force_cast<PFNDestructorOfCWBt>(GetProcAddress(hMod, TEXT("[email protected]@[email protected]")));
(a1->*pfnDestA)();
/*************************************************************************/
FreeLibrary(hMod);
}
could some kind soul maybe write a script to do someth like that...
I make it BT on/off
Jn dell axim X30 exist btpwr.dll.
This dll export some interesting methods.
1 0 0000128C PowerDeInit
2 1 00001284 PowerInit
3 2 00001258 PowerOff
4 3 0000121C PowerOn
I call this methods directly from dll, and i turn on turn off bt !!
Sample code below:
void DoTrayOn()
{
CString szDllPath = _T("btpwr.dll");
HMODULE hMod = LoadLibrary(szDllPath);
if(hMod==NULL)
{
AfxMessageBox(_T("LoadLibrary Failed !!!"));
}
typedef int (*BTPowerOn)();
BTPowerOn bton = (BTPowerOn) GetProcAddress(hMod, TEXT("PowerOn"));
if (NULL != bton)
{
// AfxMessageBox(_T("Start DoTrayOn"));
(bton) ();
}else
{
// AfxMessageBox(_T("Error NULL DoTrayOn pointer"));
}
FreeLibrary(hMod);
}
void DoTrayOff()
{
CString szDllPath = _T("btpwr.dll");
HMODULE hMod = LoadLibrary(szDllPath);
if(hMod==NULL)
{
AfxMessageBox(_T("LoadLibrary Failed !!!"));
}
typedef int (*BTPowerOff)();
BTPowerOff bton = (BTPowerOff) GetProcAddress(hMod, TEXT("PowerOff"));
if (NULL != bton)
{
// AfxMessageBox(_T("Start DoTrayOn"));
(bton) ();
}else
{
// AfxMessageBox(_T("Error NULL DoTrayOn pointer"));
}
FreeLibrary(hMod);
}
Bluetooth turn on/turn off
Hello
Have you a solution for turn on and turn off bluetooth by code?
I have a widcomm stack and I use c# .net
i'm searching for a solution for my Touch Pro 2 with Widcomm BT Stack.
i can turn on BT by creating an object of CBtIf, but can't turn of BT by deleting the object.
someone has an idea?
regards
IceFire

need some coding help...if possible?!

hi all !
I have a little problem..first i am not a very good coder..and second I have a feature that i would like to solve...
from a winmob 5.0 smartphone or pocketpc I would like to set a couple of registry settings.
But I cant figure out how to do it...
What I need is to set a device name in a spcific place in the registry...from the device itself,some kind of gui..the guipart and the rest of the app I have but its the regentry thing that I cant figure out...
first I thought that I could take an xml file and run it frm the program but then I thougnt about a little and what I need is a regentry instead...
I am running the latest .net visual studio 2005
anyone have any tips for me??
Writing to the registry is not that hard, it is done like this in C
HKEY hKey;
DWORD RegKeyDisp, RegKeyType, RegKeySize, dwTemp;
USHORT RegRead;
//Create the registry Key if it don't exist
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
TEXT("Software\\Sample\\Test1\\Test2"),
0, NULL, 0,0, NULL, &hKey, &RegKeyDisp) == ERROR_SUCCESS)
{
RegCloseKey(hKey);
}
//Read (Query) the value from the registry
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
TEXT("Software\\Sample\\Test1\\Settings"),
0, NULL, 0,0, NULL, &hKey, &RegKeyDisp) == ERROR_SUCCESS)
{
//Get the Value in 'Read This Key'
RegKeyType = REG_DWORD;
RegKeySize = sizeof(DWORD);
RegQueryValueEx(hKey, TEXT("Read This Key"), NULL, &RegKeyType,
(PBYTE)&RegRead, &RegKeySize);
RegCloseKey(hKey);
}
//Write a value to the registry
dwTemp = 42; //Value to be stored in the registry
RegKeyType = REG_DWORD;
RegKeySize = sizeof(DWORD);
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
TEXT("Software\\Sample\\Test1\\Test2"),
0, NULL, 0,0, NULL, &hKey, &RegKeyDisp) == ERROR_SUCCESS)
{
RegSetValueEx(hKey, TEXT("WriteKey"),
0, RegKeyType,
(PBYTE)&dwTemp,
RegKeySize);
RegCloseKey(hKey);
}
This has all been cut and chopped out of a working program I have written - I can not guarantee I have made a mistake in choping out irrelevent information - but I hope it makes sense.
If you are not writing in C then I am sure you could declare them or wrap them up with P/Invoke.
nice !
thx alot for a very fast answer!
I will give it a go as soon I get home!!
ok that looked ok...but it turned out that I need to put something in the registry via XML afterall...
is there a way todo that??
take a value(in this case a userid/password) and put it in cm_vpnentries ??
Reading the sdk it want to do it through rapi or cpf file only...

Programmatically cycle sound icon (sound/vibrate/mute)

When you click on the sound icon, you get the two sliders and three radio buttons. Anyone know how to set those radio buttons through code (C++) so it gets reflected in the icon display (and actually changes the "profile")?. I'd like to change to vibrate/mute/sound at different times using something like alarmToday to run a small app.
Thanks,
sbl
I wrote a profiles app in .net and C++ here are some code snippets;
You can change the registry values for the volumes (I cant remember which as I wrote it a long time ago), then you need to call the following to have the values applied.
// ProfilesHelper.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "ProfilesHelper.h"
#include <windows.h>
#include <Soundfile.h>
void WINEXPORT SetSoundMode(int mode)
{
// Initialize an empty SNDFILEINFO structure
SNDFILEINFO sndfile = {0};
if (mode == 0)
sndfile.sstType = SND_SOUNDTYPE_ON;
if (mode == 1)
sndfile.sstType = SND_SOUNDTYPE_VIBRATE;
if (mode == 2)
sndfile.sstType = SND_SOUNDTYPE_NONE;
SndSetSound(SND_EVENT_ALL, &sndfile, false);
void AudioUpdateFromRegistry();
}
void WINEXPORT SetSystemVolume(long volume)
{
waveOutSetVolume(NULL, volume);
void AudioUpdateFromRegistry();
}
Hi,
I have a similar need of programatically cycling the sound icon to MUTE VIBRATE and normal volume icon. I can do it successfully on Windows Mobile 5.0. I created a sample application with Visual Studio 2005 for WM 5.0 and I am able to set the icons as i want. But when i tried it for PPC2003 I was not able to compile that. Missing SoudFile.h. Can any one help me to find out how to do the same thing on PPC2003 specifically i-mate devices like PDA2 and PDA2K.
Thanks
With Regards,
Bhagat Nirav K.
i know its a 2 ur old post..but i need help also now
how can i mute sounds using C# in .net 2.0 for WM6
Just forget about this header file...
Operate on HKCU\ControlPanel\Notifications\ShellOverrides\Mode value. It can have 3 states: 0 == normal, 1 == vibrate and 2 == silent. That's all
Probably you need to call AudioUpdateFromRegistry function from coredll.dll.
Or... another method
look at HKCU\ControlPanel\Sounds\RingTone0:Sound, it takes 3 different values:
*none*
*vibrate*
your ringtone name, taken from SavedSound value in the same key.
Hi,
Firstly I know this post is way old, but I thought of responding to it since I was stuck on this topic for a couple of days and couldnt find a way to resolve it.
Also others having this problem will also be redirected here through various search results as I was. So to aid them
1. Meddling with the registry to change the sound profiles didnt work for me. I tried Changing the Mode inHKCU\ControlPanel\Notifications\ShellOverrides\Mode but that didnt work on my phone.
2. What I currently have working is the following code - C# with Pinvoke
public enum SND_SOUNDTYPE
{
On,
File,
Vibrate,
None
}
private enum SND_EVENT
{
All,
RingLine1,
RingLine2,
KnownCallerLine1,
RoamingLine1,
RingVoip
}
[StructLayout(LayoutKind.Sequential)]
private struct SNDFILEINFO
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szPathName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szDisplayName;
public SND_SOUNDTYPE sstType;
}
[DllImport("coredll.dll")]
public static extern void AudioUpdateFromRegistry ();
[DllImport("aygshell.dll", SetLastError = true)]
private static extern uint SndSetSound(SND_EVENT seSoundEvent, ref SNDFILEINFO pSoundFileInfo, bool fSuppressUI);
static void SetProfileNormal()
{
SNDFILEINFO soundFileInfo = new SNDFILEINFO();
soundFileInfo.sstType = SND_SOUNDTYPE.On;
uint num = SndSetSound(SND_EVENT.All, ref soundFileInfo, true);
AudioUpdateFromRegistry();
}
static void SetProfileVibrate()
{
SNDFILEINFO soundFileInfo = new SNDFILEINFO();
soundFileInfo.sstType = SND_SOUNDTYPE.Vibrate;
uint num = SndSetSound(SND_EVENT.All, ref soundFileInfo, true);
AudioUpdateFromRegistry();
}
static void SetProfileMuted()
{
SNDFILEINFO soundFileInfo = new SNDFILEINFO();
soundFileInfo.sstType = SND_SOUNDTYPE.None;
uint num = SndSetSound(SND_EVENT.All, ref soundFileInfo, true);
AudioUpdateFromRegistry();
}
Hope this helps

many RIL_NOTIFY_DISCONNECT signal received for one call made

Hi,
I was trying to get the notification signals for a voice call on windows mobile 5.0 smartphone so as to calculate the total call duration here is sample
// Initialize RIL library....
if (HdlRil == 0)
RIL_Initialize (1, ResultCallback, NotifyCallback, RIL_NCLASS_CALLCTRL, 0, &HdlRil);
void NotifyCallback(DWORD dwCode, HRESULT hrCmdID, const void *lpData, DWORD cbData, DWORD dwParam)
{
switch(dwCode)
{
case RIL_NOTIFY_CONNECT:
{ //debug(call connected);
dwOldTime = GetTickCount();
} break;
case RIL_NOTIFY_CONNECT: {
dwcalltime = GetTickCount()-dwOldTime;
//debug(call disconnected);}
}
Problem is when a call is made and cut after say 10 sec i get call connected debug message once thats correct but i get three or four call disconnected messages can u help me why i get those extra disconnected signals when a single disconnected signal was expected...
void ResultCallback (DWORD dwCode, HRESULT hrCmdID, const void *lpData, DWORD cbData, DWORD dwParam)
{
}
Thanks n Regards
Henry.

Categories

Resources