[WM6] get GSM neighbor cells info - Windows Mobile Software Development

Hello experts,
I always wonder if there's any way that we can get the informations (id, phone signal strength, bcch ...) from all the surround cells in Windows mobile 6 (with C#/C++ on my HTC touch HD). With RIL, we can only extract the info of current cell, but not the neighbors.
I'm inspired by this thread which was created in the forum by binary64:
forum.xda-developers.com/showthread.php?t=610759
However without the code i still haven't figured how did he extract the values of the 6 towers...
Base on the research i've done, it seems impossible to get the real neighbors cell ID, however i'm really interested in the phone signal strength, bcch... that are possible to get. (as fieldtest.exe or what binary64 demonstrated)
Any idea would be precious to me, thank you very much

I think that the memory/registry approche seems to be the only solution
Does anyone know which part of the memory/registry in HTC contains the GSM informations ?

up thread
Sorry to spam, i just want to up my thread because i really want to have some answer

Progress
With RIL DevSpecific i've get to extract the values of Fieldtest, however i don't know the necessary parameters to get the source that fieldtest take as result.
Precisely, if i run fieldtest once, and use the devSpecific, i'll get the last result of fieldtest and always the same. If i run fieldtest again then use DevSpecific i'll get a new result (always latest result from Fieldtest).
Does anyone know where to find a document related to devSpecific ?
Thank you very much.

Well you could execute "fieldtest.exe" in the /windows/ folder; it's like the old Nokia's "Netmonitor" wich was for "engineering purposes"

MuratNL said:
Well you could execute "fieldtest.exe" in the /windows/ folder; it's like the old Nokia's "Netmonitor" wich was for "engineering purposes"
Click to expand...
Click to collapse
Thank you, my fieldtest.exe was always running ok, but in fact i'm trying to disassembly it with C++/C#. Do you (or anyone) know any source that we can buy the documents related to this subject ?

No, I'm sorry but i'm not a good coder so i have to dissapoint you...
Maybe someone here at XDA-DEV can help you?

AT Command
Does anyone know a specific AT Command that can be used to extract the network info ?
Thanks

A spam question : Is there any condition for a member to get the answers of the experts ? i don't think that no one has an idea ...

Hi Vietsuper,
This seems to be a more up to date thread, so I post this here as well.
I'm working on a HTC HD2, and I am trying to get pretty much the same info. neighbour BCCH carriers and their received signal strengths. Indeed, not only RIL does not offer info on the neighbour cells, but I keep getting ZEROs in all fields returned by RIL except the cellID, MCC, MNC and LAC.
I see that you found a way with RIL_DevSpecific. If you give me advice, directions or code pieces, I'd be interested to try it on my HD2.
Thanks

hi pc18,
Actually RIL_devSpecific allows you to extract the info of neighbor cells (ARFCN + RSSI) as the program fieldtest. However it just works along with fieldtest, without fieldtest you always get the same value not up to date. I think in fieldtest they add some more parameters that allow to refresh.
You can find some reference in the thread of binary64 of which the link i posted above.
( forum.xda-developers.com/showthread.php?t=610759 )
I'm searching for the document more specific about RIL_devSpecific, however i couldn't find. If you find it somewhere, i'll be very grateful if you can share.
Thanks.

vietsuper said:
hi pc18,
Actually RIL_devSpecific allows you to extract the info of neighbor cells (ARFCN + RSSI) as the program fieldtest. However it just works along with fieldtest, without fieldtest you always get the same value not up to date. I think in fieldtest they add some more parameters that allow to refresh.
You can find some reference in the thread of binary64 of which the link i posted above.
( forum.xda-developers.com/showthread.php?t=610759 )
I'm searching for the document more specific about RIL_devSpecific, however i couldn't find. If you find it somewhere, i'll be very grateful if you can share.
Thanks.
Click to expand...
Click to collapse
Hi vietsuper,
I've looked into the thread and got inspired by it. I think it is interesting. I also think it is very interesting that one can only get carrier information (attachment base and neighbours) via FieldTest. Unfortunately, using the code that I will paste below, I could only get a return value of -2147467263 which as far as I could see means E_NOTIMPL. Now, I could be wrong when building up the params to pass to RIL_DevSpecific(). Here it is:
Code:
hRes = RIL_Initialize(1, new RILRESULTCALLBACK(rilResultCallback), null, 0, 0, out hRil);
byte[] dev_command_buffer = new byte[] {84, 0, 0, 0, 0, 0, 0, 0, 0x9c, 0x9b};
int size = Marshal.SizeOf(dev_command_buffer[0]) * dev_command_buffer.Length;
IntPtr buffer_pointer = Marshal.AllocHGlobal(size);
try
{
Marshal.Copy(dev_command_buffer, 0, buffer_pointer, dev_command_buffer.Length);
hRes = RIL_DevSpecific(hRil, buffer_pointer, 10);
}
Where do you think is the problem?
Thanks

pc18 said:
Hi vietsuper,
I've looked into the thread and got inspired by it. I think it is interesting. I also think it is very interesting that one can only get carrier information (attachment base and neighbours) via FieldTest. Unfortunately, using the code that I will paste below, I could only get a return value of -2147467263 which as far as I could see means E_NOTIMPL. Now, I could be wrong when building up the params to pass to RIL_DevSpecific(). Here it is:
Code:
hRes = RIL_Initialize(1, new RILRESULTCALLBACK(rilResultCallback), null, 0, 0, out hRil);
byte[] dev_command_buffer = new byte[] {84, 0, 0, 0, 0, 0, 0, 0, 0x9c, 0x9b};
int size = Marshal.SizeOf(dev_command_buffer[0]) * dev_command_buffer.Length;
IntPtr buffer_pointer = Marshal.AllocHGlobal(size);
try
{
Marshal.Copy(dev_command_buffer, 0, buffer_pointer, dev_command_buffer.Length);
hRes = RIL_DevSpecific(hRil, buffer_pointer, 10);
}
Where do you think is the problem?
Thanks
Click to expand...
Click to collapse
I remember u said u use HTC HD2, so i think the RIL standard functions are implemented, so if u have imported the functions i should work.
I once did in C# and the code just simple as below and it worked well:
Code:
[DllImport("ril.dll")]
private static extern IntPtr RIL_Initialize(...
[DllImport("ril.dll")]
private static extern IntPtr RIL_DevSpecific(IntPtr hRil, byte[] lpbParams, uint dwSize);
//in my function
byte[] param = new byte[] { 0x84, 0, 0, 0, 0, 0, 0, 0, 0x9C, 0x9B };
hRes = RIL_DevSpecific(hRil, param, 10);
you even just need {0x84,0,0,0} for the same result, because commandId=0x84 is enough.
If u still get E_NOTIMPL may be u need to create/copy ur own ril.dll somewhere, but i think it's unlikely because i think HTC HD (my phone) and HTC HD2 have the similar implementation for RIL.

Memory dump
I'm desperate to find the info directly in the memory. There's something a little bit interesting that i found out.
There's a sequence of responses to AT Command writing in ASCII:
@HTCCSQ:3
@HTCCSQ:4
@HTCCSQ:2
+CREG: 1,"000C","9F60" (here we has current LAC + Cell ID)
+CREG: 1,"000C","9BC7" (another LAC + Cell ID, i think it's the previous one)
+COPS: 0,2,"20820",3 (inside the "" are MCC MNC)
@HTCCSQ:3 .... (there's plenty of @HTCCSQ: coming next )
Look like some kind of log of the querries of RIL driver to the modem (i'm not sure), just sure that it wasn't my programs who send the command.
may be we can get to the other network info too. Any ideas ?
Thanks.

Thanks vietsuper for your help. I finally arrived at some result. Indeed, a hexdump of the data that's being received from ril_devspecific gives the last information that's displayed by fieldtest. With fieldtest running in the backgound one can get fresh information (ie with a new request every, say, 2 secs).
I see two problems at the moment:
1) does anyone know at this point how to turn the memory zone pointed to by the IntPtr into a struct? or will i have to parse the hexdump for the neighbour cell information (BCCH number and received signal strength)?
2) fieldtest will only return neighbour information when the telephone displays Edge available (GSM menu item); whenever the phone displays the 3G status icon, neighbor cell information is no longer available (ie NCell1 0 -99dbm); does anyone have any idea?

pc18 said:
Thanks vietsuper for your help. I finally arrived at some result. Indeed, a hexdump of the data that's being received from ril_devspecific gives the last information that's displayed by fieldtest. With fieldtest running in the backgound one can get fresh information (ie with a new request every, say, 2 secs).
I see two problems at the moment:
1) does anyone know at this point how to turn the memory zone pointed to by the IntPtr into a struct? or will i have to parse the hexdump for the neighbour cell information (BCCH number and received signal strength)?
2) fieldtest will only return neighbour information when the telephone displays Edge available (GSM menu item); whenever the phone displays the 3G status icon, neighbor cell information is no longer available (ie NCell1 0 -99dbm); does anyone have any idea?
Click to expand...
Click to collapse
1> In C#, you can use Marshal.PtrToStructure to copy the IntPtr to a structure/class u created. To dump memory you Marshal.Copy to a byte array and BitConverter.toString(array). I think if you want to read the full neighbor cell info, as what i wrote above you must do research in some memory zones or make a direct stream connection to the gsm modem and querry with AT Command.
2> Fieldtest can show different kind of info depending on the option you choose in the "group" menu. The neighbor cell info are only available for gsm option, so if your phone has the 3G status, means that it connect to a 3G tower, the gsm info in Fieldtest is no longer available, you must choose other options for 3G.
If you have any progress in any way that i mentioned (AT Command / Memory dump), please share to me too, thanks.

vietsuper said:
1> In C#, you can use Marshal.PtrToStructure to copy the IntPtr to a structure/class u created. To dump memory you Marshal.Copy to a byte array and BitConverter.toString(array). I think if you want to read the full neighbor cell info, as what i wrote above you must do research in some memory zones or make a direct stream connection to the gsm modem and querry with AT Command.
2> Fieldtest can show different kind of info depending on the option you choose in the "group" menu. The neighbor cell info are only available for gsm option, so if your phone has the 3G status, means that it connect to a 3G tower, the gsm info in Fieldtest is no longer available, you must choose other options for 3G.
If you have any progress in any way that i mentioned (AT Command / Memory dump), please share to me too, thanks.
Click to expand...
Click to collapse
Thanks. This is valuable info. I am looking into the directions you pointed out to.

Memory dump
I've found something else by dumping the memory, this time it isn't some AT Command log but a fixed structure :
00 00 ... 00 [4 bytes LAC][4 bytes Cell ID][3 chars MCC][2 chars MNC] 01(unknown byte) 00 ... 00 00
I think there'll be other memory blocs that contain neighbor cell info, however i haven't found.
Hope someone can share ...

Fieldtest rssi
Does any one know why the RSSI shown in Fieldtest have a distance of 15-20 dB compare to the value of GetSignalQuality ?
In my opinion:
- GetSignalQuality shows the initial signal strength captured by the phone (Rx), because the value is calculated from the response AT+CSQ of the Radio modem.
- In Fieldtest / RIL_DevSpecific we have a weaker strength (-10 -20 db), may be it counts some other loss factors of device.
Any ideas ?
Thanks

Help using RIL_DevSpecific
Hi, guys would you share code to get that information. I work for a telecommunication company and I am also working on my MS degree project related to cellular networks. I will use the information to compare with cell database I have access to.
Thanks

Related

make call

i want to make a call from my application, please help
PS: i am using .net cf
thanx
Use "phoneMakeCall "function
Find "phoneMakeCall" function infomation in MSDN library.
I was unable to find that function in the MSDN library. I found more, but they were .NET functions.
I am interested in the same functionality as the tel: protocol. Does anyone know what the parameter is that I can send to cprog.exe so it knows what number I want to dial (if it's possible). And if there is a way to make the phone automatically dial that number would be great.
The tel: protocol is really kind of weak for applications outside of IE. Having to launch a blank window is a horrible user experience.
Thanks in advance,
-- Mike
Hi there
Try this link:
http://smartdevices.microsoftdev.com/Learn/Articles/622.aspx
Discribed is a away to use the TAPI through p/Invoke.
It was a bit of hard work, but after only 1/2 a Day i made my first phonecall to a telephonenumber, stored in my App's database.
Generally i found out, that http://smartdevices.microsoftdev.com is a good starting point for searching information (and of course this forum ;-))
Hi
Thx for the link, It helped me a lot. I didn't get the VB.NET part of the sample code (Downloaded) to work when I was calling a phone number. It seems that the phone is not converted correctly. The SMS part of the VB sample works ok although.
The CS sample work OK, I could make a phone call in minuts, using the sample code.
So if I can't find the reason for the error in the VB sample, I must stick to the CS code.
Klaus E. Frederiksen, Denmark
PhoneMakeCall
This function dials the specified phone number.
LONG PhoneMakeCall(
PHONEMAKECALLINFO *ppmci);
Parameters
ppmci
Pointer to the PHONEMAKECALLINFO structure that contains the information related to the call to be placed.
Return Values
Value Description
Non-zero The function was not successful.
Zero The function was successful.
Remarks
This function must be called in order to initiate a phone call.
Guest said:
I was unable to find that function in the MSDN library. I found more, but they were .NET functions.
I am interested in the same functionality as the tel: protocol. Does anyone know what the parameter is that I can send to cprog.exe so it knows what number I want to dial (if it's possible). And if there is a way to make the phone automatically dial that number would be great.
The tel: protocol is really kind of weak for applications outside of IE. Having to launch a blank window is a horrible user experience.
Thanks in advance,
-- Mike
Click to expand...
Click to collapse
Details for .Net developers:
The PhoneMakeCall function is not the tricky part of this.
For .net newcomers it's P/Invoke that makes this a little more difficult,
than just using a dll.
1. You have to create a Class (for Example: Phone) that hold the functionality. Because we are using P/Invoke, don't forget using System.Runtime.InteropServices!
2. In your new created Phone Class declare 2 statics, that help us with the option of Prompting before making a call, one of them will fill the dwFlags part of our Infostructure:
private static long PMCF_DEFAULT = 0x00000001;
private static long PMCF_PROMPTBEFORECALLING = 0x00000002;
3. Now to define the allready by yrj mentioned PhoneMakeCallInfo structure. it should look like this:
private struct PhoneMakeCallInfo
{
public IntPtr cbSize;//size of struct
public IntPtr dwFlags;//prompt or not
public IntPtr pszDestAddress;//pointer to CharArray with
//Phone number
public IntPtr pszAppName;//nothing
public IntPtr pszCalledParty;//nothing
public IntPtr pszComment;//nothing
}
4. The import of the Phone.dll function should be no problem:
[DllImport("phone.dll")]
private static extern IntPtr PhoneMakeCall(ref PhoneMakeCallInfo ppmci);
5. Now you have to create a fucntion that instantiates a PhoneMakeCall infoStructure and call the newly Invoked PhoneMakeCall-function.
Now, have fun!

Help me understand C++ code with notifications (beers offered)

Hi,
I need to use the C++ version of this. The code should gather information and show this in a notification.
The notification works but I want to receive the choice the user made in the html form.
I know I need to use the hwsink, a message map, and some events but cannot find info (book, example, etc.) how.
Could some one finish this code so I can test what has been chosen. If NOT, please give me an C++ example from which I can learn/copy. I have been searching on google for days now
Thx, for your help
BTW:
I started with this http://www.krvarma.com/?p=146 downloaded code but was a bit to complicated. In it is all I need but i would like it to be in 1 cpp file.
I'm offering 2 beers if you have the solution
Code:
#include "stdafx.h"
#include <stdlib.h>
#include "resource.h"
// {4E8A9888-D15C-4395-9C9A-B4B572F20081}
static const GUID NOTIFICATION_GUID =
{ 0x4e8a9888, 0xd15c, 0x4395, { 0x9c, 0x9a, 0xb4, 0xb5, 0x72, 0xf2, 0x0, 0x81 } };
int _tmain(int argc, _TCHAR* argv[])
{
SHNOTIFICATIONDATA stcNtData = {0};
stcNtData.cbStruct = sizeof(stcNtData);
stcNtData.dwID = 1;
stcNtData.npPriority = SHNP_INFORM;
stcNtData.csDuration = 15;
// stcNtData.hicon = LoadIcon((HINSTANCE)GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON2));
stcNtData.clsid = NOTIFICATION_GUID;
//What todo here... stcNtData.hwndSink = hWnd;
stcNtData.grfFlags = SHNF_SILENT | SHNF_TITLETIME | SHNF_CRITICAL | SHNF_FORCEMESSAGE;
stcNtData.pszTitle = L"ReRemind";
//stcNtData.pszHTML = TEXT("<html><body>This is a sample application to show the SHNotificationAdd API")
// TEXT("<p><b>This line should be bold</b>.<br><i>This one should be italics.</i><br>")
// TEXT("This is a line with a <a href='cmd:10000'>link</a></p>")
// TEXT("<p>This is a line with <input type='button' name='cmd:10001' value='Click'></p><br><br><br><br>");
stcNtData.pszHTML = TEXT("<form method='get' action='TestBubble://Test'>")
TEXT("<table width=100% cellspacing=0 cellpadding=0>")
TEXT("<tr><td colspan=2>")
TEXT("<b>Choose a fruit:</b><p>")
TEXT("<input type='radio' value='0' id='Apples' checked name='Fruit'><label for='Apples'>Apples</label><br>")
TEXT("<input type='radio' value='1' id='Oranges' name='Fruit'><label for='Oranges'>Oranges</label></p></td><td>")
TEXT("<input type='submit' value='Submit' name='Submit'>")
TEXT("</td></tr><tr><td width=42>")
TEXT("<a href='cmd:12288'>Settings</a></td></tr></table></form><br><br><br><br>");
SHNotificationAdd(&stcNtData);
Sleep(15000);
SHNotificationRemove(&NOTIFICATION_GUID, 1);
return 0;
}
I'm offering beers now. No need to finish it, just give me some hints
Hi,
as I understand your article (http://www.krvarma.com/?p=146)
you need to create window, then assign it's HWND
to SHNOTIFICATIONDATA member HWND hwndSink;
then "The system will send WM_COMMAND with wParam set to 1000 to the hwndSink window." so - you need to handle WM_COMMAND in your window and check wParam - if it is equal to your parameter, then this message means "system sends you user choice from your html".
serfer222 said:
Hi,
as I understand your article (http://www.krvarma.com/?p=146)
you need to create window, then assign it's HWND
to SHNOTIFICATIONDATA member HWND hwndSink;
then "The system will send WM_COMMAND with wParam set to 1000 to the hwndSink window." so - you need to handle WM_COMMAND in your window and check wParam - if it is equal to your parameter, then this message means "system sends you user choice from your html".
Click to expand...
Click to collapse
Exactly as i understand it.
So I tried copying code from that article into my code but got stuck with really not understandable compiler errors. I think I need to find a good book explaining this message map.
The first thing I do not understand is that I only want to show the notification bubble (is working). If I create a windows handle (how?) will this overwrite the current screen (this is something I do not want).
window can be invisible.
I'm Win32 programmer, and I don't know exactly about WinCE.
If you are using VisualC++, I think you should use MFC, it's very easy to create window and then create message handler for this window.
search google for some
"WinCE c++ tutorial" and you will find how to create window and setup message loop. (add "Hello world" phrase to your search - this is usually used as very first example)
for example: http://www.codeproject.com/KB/mobile/ltwtdlg.aspx
serfer222 said:
window can be invisible.
I'm Win32 programmer, and I don't know exactly about WinCE.
If you are using VisualC++, I think you should use MFC, it's very easy to create window and then create message handler for this window.
search google for some
"WinCE c++ tutorial" and you will find how to create window and setup message loop. (add "Hello world" phrase to your search - this is usually used as very first example)
for example: http://www.codeproject.com/KB/mobile/ltwtdlg.aspx
Click to expand...
Click to collapse
Can you switch between MFC, ATL, etc. ? I know they are some kind of libraries but thought "don't look at it, there too much to learn/understand anyway ".
I've search but somehow you think there is the solution and then you learn the hard way, it's very old code. Will search further offcourse and I am reading a chapter on classes and if I can find; messages.
it's already very easy to handle messages without any MFC overload. Just check the uMsg parameter in your DefWindowProc. If you create a new Win32 project in Visual C++ wizard then you see what it's looking like. This is mandatory knowledge. Usually first thing you learn after Hello World. If you didn't know about message processing in Windows/Wince then it's the same like sitting in a car and don't know how to turn the keys.
Do you know how to open dsm file in textbox???
RAMMANN said:
it's already very easy to handle messages without any MFC overload. Just check the uMsg parameter in your DefWindowProc. If you create a new Win32 project in Visual C++ wizard then you see what it's looking like. This is mandatory knowledge. Usually first thing you learn after Hello World. If you didn't know about message processing in Windows/Wince then it's the same like sitting in a car and don't know how to turn the keys.
Click to expand...
Click to collapse
Thats how I feel exactly. It's strange. I read quickly thru 3 books about C++ and no mention of these messages. C#/Basic are easier to understand because of all the examples.
Found these:
- http://www.youtube.com/watch?v=kWVGqV2Yklw
- http://www.youtube.com/watch?v=cbe6yxBHEiU
The video does explain that the linked example doesn't look so different. What a lot of source code Ms creates for you..
If created a WIN32 smart device project and DefWindowsProc is only called when to pass the message to other programs. I need the windows handle for the notification and NOT display the window.
But again it's a bit to much for me at this moment. I haven't got a solution yet..Could somebody help me with not displaying this window. I would still like to use the windows handle to make sure I get the callbakcs to the WM_COMMAND.
Yes - I think you only need at end of WinMain before SHNotificationRemove
to add:
Code:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hacc, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Then a new function:
Code:
/* Redefine generic HANDLE_WM_ACTIVATE macro for Pocket PC */
#undef HANDLE_WM_ACTIVATE
#define HANDLE_WM_ACTIVATE(hwnd,wParam,lParam,fn) \
(SHHandleWMActivate((hwnd), (wParam), (lParam), &g_sai, 0), /*return*/ 0L)
/* Redefine generic HANDLE_WM_SETTINGCHANGE macro for Pocket PC */
#undef HANDLE_WM_SETTINGCHANGE
#define HANDLE_WM_SETTINGCHANGE(hwnd,wParam,lParam,fn) \
(SHHandleWMSettingChange((hwnd), (wParam), (lParam), &g_sai), /*return*/ 0L)
static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
HANDLE_MSG(hwnd, WM_CREATE, Main_OnCreate);
HANDLE_MSG(hwnd, WM_ACTIVATE, /* SHHandleWMActivate()*/ 0);
HANDLE_MSG(hwnd, WM_SETTINGCHANGE, /* SHHandleWMSettingChange() */ 0);
HANDLE_MSG(hwnd, WM_PAINT, Main_OnPaint);
HANDLE_MSG(hwnd, WM_COMMAND, Main_OnCommand);
HANDLE_MSG(hwnd, WM_DESTROY, Main_OnDestroy);
[B]// Remark: Here you can add more messages - also for what user has chosen.[/B]
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}
and then the message handlers like this:
Code:
static BOOL Main_OnCreate(HWND hwnd, CREATESTRUCT *pcs)
{
SHMENUBARINFO mbi;
memset(&mbi, 0, sizeof(mbi));
mbi.cbSize = sizeof(mbi);
mbi.hwndParent = hwnd;
mbi.nToolBarId = IDR_MNU_MAIN;
mbi.hInstRes = g_hInstance;
if (!SHCreateMenuBar(&mbi)) /* create the menu bar */
return FALSE;
g_hwndMB = mbi.hwndMB;
return TRUE;
}
But your Compiler should already make such a project by default and you can simple add the code fom _tmain to WinMain, which you've posted above.
Greetz
Micha
Thank you, yesterday I debugged and and debugged trying to understand how this works but the debugger doesn't stop always in all source code.
If f.i. you click on the screen I expected this to be an event, but the debugger didn't stop at all. Is there a command to always stop when a line of code is processed? Now it only stops when I have set a break point. I want to see every line processed...
I will try to implement your suggestions. For a newby it still looks difficult I hope someday I will look back to this and say "wow, that was so easy".
ajhvdb said:
Thank you, yesterday I debugged and and debugged trying to understand how this works but the debugger doesn't stop always in all source code.
If f.i. you click on the screen I expected this to be an event, but the debugger didn't stop at all. Is there a command to always stop when a line of code is processed? Now it only stops when I have set a break point. I want to see every line processed...
I will try to implement your suggestions. For a newby it still looks difficult I hope someday I will look back to this and say "wow, that was so easy".
Click to expand...
Click to collapse
Well, actually that's the reason why breakpoints exist. To stop the debugger and allow you look at the running code..... or what else did you think??
RAMMANN said:
Well, actually that's the reason why breakpoints exist. To stop the debugger and allow you look at the running code..... or what else did you think??
Click to expand...
Click to collapse
I want to say "stop and show at the current code line".
For example you start your program, goto the appropiate window, type in some data and NOW before you click on SAVE. You say to your debugger "catch this/coming event".
Debugger would stop if you'd handle this event and set break point to 1st command of this function.
then yo can go step by step through each line of code.
and hey: it's not soo easy,which I posted.But your Compiler (vs2008 or PellesC or whatever) would make this automatically for you and you only have to copy your part of code into WinMain of this automatic processed code.
The "Managers" then can help you also to add eventhandlers automatically.
you only have to set Breakpoints to the automatic processed Event-Handle-Function - them you can see,if this event is triggered like you want it.
You only think from the wrong direction
Ok, I learned a lot.
(The VS2008 debugger has bugs. If I set a breakpoint on line 100, and start debug, line 109 has the breakpoint. It looks like only the original code can be debugged)
I did start a new project and used the tips from above. I can catch a click on a link ahref field in the notification bubble.
I have disabled the screen so only the bubble is shown
Now I need to catch the menu button and more important the data in the html form (input type radio) in the notification bubble. For this I need to convert the param to a structure...!
I also need to extend the "while getmessage" loop with a timer. If 15 seconds have passed, I need to step out of the loop and quit automatically.
A lot of searching again.
BTW.
Thx all for helping me. Not really one tip did it, you all guided me a bit. If you think your tip helped me a lot then send me a PM with your paypal code. You can also send me your address/or your businessaddress. I will send you a small present/surprise related to my country (Holland).
in Germany we have a good cheese, too and the sense of a community like this great one,is for helping each other-especially beneath developers.
And it's always a question of finding out,how to manage something new
All the best for your further development.
Micha
Attached is the code of my subproject. I will update it if those last points are done. Hope it helps others.
If someone has a link or example code for those points. (or improvements of my code) please let me know.

Send SMS Text Message

Hi Everyone,
I'm making a WinMo app that will help all those affected by Alzheimer's Disease, as well as its related illnesses. More information is at
JamesGeddes.com/TrackNan
It sends an SMS text to 1 or more mobile numbers when the patient goes outside of the GPS boundary, the only trouble is I can't work out how to get it to send SMS Text messages!
Any help would be fantastic as it will help this most worthy cause - I'll even come and buy you a drink if I can!
Thanks everyone!
James
Hey,
Is this program going to be run on Windows Mobile based phones / PPC or on a Personal Computer?
If it is on a phone, your choices are:
Using .NET CF:
Obtain GPS data (if a class is provided, i am not sure) and based on that data create an OutlookSession and Send a SMS with Microsoft.WindowsMobile.PocketOutlook
P\Invoke a C++ Method (http://msdn.microsoft.com/en-us/library/aa920513.aspx)
Using C++:
Use the methods i just mentioned before, except in a true C++ environment.
Otherwise, I have developed an application called CMail which will send SMS for you when it is run (Check my Signature for some of my projects) All you would need is a way to gather the GPS Data.
If it is on a PC:
I would reccomend looking up pre-set servers that send out SMS and make an app to link to those (just google and you will find ) ...
or you can send 'Email SMS' to phones.... IE: my number is 111-222-3333 and i use Tmobile...so you would email it to [email protected] (or .net? I cant remember)... THe list of these emails IS online
I hope this helps! (I think you are making a program for a great cause!)
Good Luck!
Hi,
I'll be running it on my HTC HD2, so on a Windows Mobile Phone. I'm working in C# and Microsoft have been unusually kind and given GPS code away with the WinMo6 SKD, so thats all good, however I just can't work out how to send a text!
Thanks!
James
It is really easy actually!
Just add a reference to your project for Microsoft.WindowsMobile.PocketOutlook. Then use the following:
Code:
SmsMessage x = new SmsMessage(RECIPIENT NUMBER, BODY);
x.send();
And that should do it!!
Hope this helps
I've use the following code
Code:
private void btn_send_Click(object sender, EventArgs e)
{
SmsMessage x = new SmsMessage(tb_Number, tb_Message);
x.send();
}[code]
However it returns
"The type or namespace name 'SmsMessage' could not be found (are you missing a using directive or an assembly reference?)"
What's going wrong?
OK, I got that working, I just forgot to put this at the top!
Code:
using Microsoft.WindowsMobile.PocketOutlook;
How do you send to multiple numbers though? I've asked the user to give me 3 mobile numbers in coma separated format, does that help?
well you can do a foreach loop
...
SO the user gives you 3 numbers :
123-456-7890
098-765-4321
132-465-7980
Store those to a String[]
Code:
string[] numbs = {1234567890, 09876543210, 1324657980};
foreach (string numb in numbs)
{
SmsMessage x = new SmsMessage(numb, BODY);
x.send();
}
That should do it. I had a few issues when i tried this with my program that i am upgrading ... It may give u a ArgumentException Invalid Address, but it still sends the SMS. To get rid of this just do the following:
Code:
string[] numbs = {1234567890, 09876543210, 1324657980};
try
{
foreach (string numb in numbs)
{
SmsMessage x = new SmsMessage(numb, BODY);
x.send();
}
}
catch {}
I found that sending an SMS took a little while - not too long, maybe about a second or something; but if you're sending to lots of people, the application may stop for a while.
I thought it would be better to use the "for each" idea Cyclonezephyrxz7 mentioned, and put it in a separate thread. I had alsorts of fun with it, but I found the answer.
I wrote something about it here:
http://forum.xda-developers.com/showthread.php?t=630537
I can post the code if you like (I've not got it here), but I wrote it in VB - it should be an easy port.
What this does is to allow your app to continue, while in the background the SMSs get sent - then the code raises an event when done.
Let me know, ok?
Paul.

Truetype fonts in evC++

Hi gents.
I want to ask you,how can I use external font loaded from ttf file in my app,developed under Embedded Visual C++?
I need to easily change color and size of the font and using the DrawText() function make an output into current DC.
Can someone make an example for me please?
Thank you.
Here's the bare bones of it ,you'll have to flesh it out to suit. It might not be perfect but it works.
Global Variable
Code:
HFONT g_hfont;
Forward declaration of EnumFontProc()
Code:
int CALLBACK EnumFontsProc(LOGFONT *lplf, TEXTMETRIC *lptm, DWORD dwType, LPARAM lpData);
In WM_PAINT print it out. I'll use Wingdings. The name in the EnumFonts must match the actual name of the font as declared in the TTF file.
Code:
case WM_PAINT:
RECT rt;
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rt);
EnumFonts(hdc,TEXT("Wingdings"),(FONTENUMPROC) EnumFontsProc,NULL);
SelectObject(hdc,g_hfont);
DrawText(hdc,TEXT("12345"),5, &rt, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
DeleteObject(g_hfont);
EndPaint(hWnd, &ps);
break;
In EnumFontsProc set the font to the first font given. Returning 0, ends the enumeration, non zero, give me the next.
To change the size do it here by changing lplf->lfHeight and lplf->lfWidth
Code:
int CALLBACK EnumFontsProc(LOGFONT *lplf, TEXTMETRIC *lptm, DWORD dwType, LPARAM lpData)
{
g_hfont = CreateFontIndirect(lplf);
return 0;
}
To load and release your font add the code below to the message handling sections.
Code:
WM_CREATE:
AddFontResource(TEXT("\\Storage Card\\myfont.TTF"));
WM_DESTROY:
RemoveFontResource(TEXT("\\Storage Card\\myfont.TTF"));
Here's the proof it works, (with Wingdings anyway!)
Thanks man,I will try it ASAP.
Well,is it possible to read the ttf file directly from exe resource also?
I am still learning C++,so some things are a bit unclear for me. Can you please post this source?
This stuff is explained fully at:
http://msdn.microsoft.com/en-us/library/aa911455.aspx
I've just taken a few shortcuts with it.
The zip file contains the main .cpp file of the above project. It does not include the AddFontResource or RemoveFontResource statements.
Create a shell WinMo application and replace the main program .cpp file with it.
AddFontResource can only accept the path to a True Type font TTF file as an argument.
The thing you have got to get your head around are CALLBACK routines, they are used during most enumeration routines, and are widely used in Win32 for all sorts of things. A Win32 app's WndProc it itself a callback routine. In the case of EnumFonts, you pass the address of the callback routine to the enumerating function, which will call your function once for every instance it finds that matches your request. You terminate the sequence by returning 0 or it will carry on until there are no instances left. You have to decide what to do with the results. In my case I take the first Wingding font I'm offered, then quit.
Be aware that there is little, or no error handling in this code. I cobbled it together pretty quickly to prove the point.
I remember reading somewhere that if you drop the .TTF file in the Windows directory, and do a soft reset, then Windows will pick it up as a resident font, so the AddFontResource and RemoveFontResource functions are not required. EnumFonts() should know about it, and present it accordingly.
Well,thank you very much for that,but can you please provide me full project source,including all the files? With working project,I can better understand the font loading principle.
Unfortunately,I am too busy nowadays to discover something,that I don't understand well,so every time save is a big plus for me. Thank you very much again.
Attached,
But, it is a VS 2008 Smart Device project. EVC won't read it.
You will have to create a shell hello world project in EVC and copy the modified code in the panels above from TestFont.CPP.
Hello.
Actually i've got it working,but I still cannot discover,how to resize the font.
Where should I exactly put the lfWidth and lfHeight?
I am now a bit confused of that.
This is my code:
Functions and declarations of HFONT,CALLBACK,WM_CREATE,WM_DESTROY are present as you described.
void ShowNumber(HDC hdc, int Value,int xrect,int yrect,int wrect,int hrect,HBITMAP source)
{
EnumFonts(hdc,TEXT("Sam's Town"),(FONTENUMPROC) EnumFontsProc,NULL);
SelectObject(hdc,g_hfont);
TCHAR szText[MAX_LOADSTRING];
int width,height;
rtText.right=wrect;rtText.bottom=hrect;width=wrect-xrect;height=hrect-yrect;
TransparentImage(hdc,xrect,yrect,width,height,source,xrect,yrect,width,height,RGB(255,0,255));
SetBkMode(hdc,TRANSPARENT);
if(Value<10) wsprintf (szText, TEXT ("0%d"),Value);else wsprintf (szText, TEXT ("%d"),Value);
rtText.left=xrect ;rtText.top=yrect ;SetTextColor(hdc,RGB(0,0,0)); DrawText(hdc,szText,2,&rtText,DT_SINGLELINE | DT_LEFT | DT_TOP);
DeleteObject(g_hfont);
}
int CALLBACK EnumFontsProc(LOGFONT *lplf, TEXTMETRIC *lptm, DWORD dwType, LPARAM lpData)
{
g_hfont = CreateFontIndirect(lplf);
return 0;
}
Click to expand...
Click to collapse
This doesn't work:
lplf.lfWidth=0;
g_hfont = CreateFontIndirect(lplf);
Click to expand...
Click to collapse
Actually I want to put one more parameter into ShowNumber() function,which will tell the function the size of the font.
You are nearly there...........
The code to set the font size will have to go in here.......
Code:
int CALLBACK EnumFontsProc(LOGFONT *lplf, TEXTMETRIC *lptm, DWORD dwType, LPARAM lpData)
{
lplf->lfHeight=14;
lplf->lfWidth=8;
g_hfont = CreateFontIndirect(lplf);
return 0;
}
Or whatever your values are, I just picked 8 and 14 as examples. If these values are passed as variables to another function above, store them as global variables, and use them here.
As lplf is passed to this function as a pointer to a LOGFONT structure, you have to use the -> operator to access its members. lplf.lfHeight won't work as you mentioned, that is for predeclared or static structures.
These values have to be changed here in the EnumFontsProc() routine before the font is created, as we are passing that pointer to create the font.
Good Luck!!
P.S. While we are here, let's tidy it up a bit.
Replace:
Code:
if(Value<10) wsprintf(szText,TEXT ("0%d"),Value);else wsprintf (szText,TEXT("%d"),Value);
with
Code:
wsprintf(szText, TEXT ("02%d"),Value);
A very big thanks for that.
I am still beginner in C++,so something can look very comic for others.
My beloved programming language is Pascal.
I really didn't think,that -> is an operator,I've just mentioned,you wrote it as something else(something like "to")
You are more than welcome.
Some features in C/C++ are not immediately obvious, but the real battle is fighting your way through the Win32 programming model, trying to get it to do what you want. Sometimes the simplest of things become maddeningly complicated, but the effort to do it properly is usually worth the effort.
Glad you got it working, best wishes, stephj.
Hello a bit later.
First of all,thank your for your explanation and now I am using this method successfuly.
I want to ask you now,if there is a way to get fixed pitch of the font,that is truetype. With standart font I can achieve with this...
lf.lfPitchAndFamily = (tm.tmPitchAndFamily & 0xf0) | TMPF_FIXED_PITCH;
I am using font,that displays numbers in "digital" mode(7-segment display) and I get the number "1" very narrow in comparison with others(actually it is narrow on any kind display,but is displayed on right segments,so "01" has adequate spacing on hard display). Now I get "0l_" instead of "0_l",that's not preferable.
Thanks in advance for reactions.
I don't think there the above method will work as each character has it own width associated with it.
A simpler approach, a bit of a pain, but which should work, is to draw/print the numeric value out one character at a time using DrawText(). Set a RECT structure up to hold the coordinates of the top left and bottom right of the area for each character.
Setting uFormat to DT_RIGHT will force the character to right align in the RECT area, so the '1' should appear correctly. Move the left and right values along a fixed amount for each character. A bit of trial and error will be involved first until you get the values just right.
Good luck, stephj.

CheckBox state presrving/restoring

Hi there,
Does anyone out there how to preserve/restore the transient state of a CheckBox and/or Radio button?
So far, I'm using the following code, working for textbox
Code:
Public Sub PreserveState_TextBox(ByVal TB As TextBox)
Dim buffer As String = String.Empty
If True = PhoneApplicationService.Current.State.ContainsKey(TB.Name) Then
buffer = TryCast(PhoneApplicationService.Current.State(TB.Name), String)
If Not String.IsNullOrEmpty(buffer) Then
TB.Text = buffer
End If
End If
End Sub
Public Sub RestoreState_TextBox(ByVal TB As TextBox)
If True = PhoneApplicationService.Current.State.ContainsKey(TB.Name) Then
PhoneApplicationService.Current.State.Remove(TB.Name)
End If
PhoneApplicationService.Current.State.Add(TB.Name, TB.Text)
End Sub
it possible to modify the above code to work for Checkbox and/or Radiobutton?
If not, any ideas?
So far, I've been trying the sample "Tombstoning" sample code from Microsoft without any luck...
Thanks in advance!
Hi,
I'm not a VB developer, but storing the state of a checkbox is not much different from storing any other primitive type. What you could do is have a bool variable "isCbChecked" and store that bool state in your PhoneApplicationService.State.
Code:
PhoneApplicationService.Current.State.Add("isCbChecked", myCheckbox.IsChecked)
Then, when you're restoring your app, simply do
Code:
myCheckbox.IsChecked = (bool)PhoneApplicationService.Current.State.ContainsKey("isCbChecked");
keyboardP said:
Hi,
I'm not a VB developer, but storing the state of a checkbox is not much different from storing any other primitive type. What you could do is have a bool variable "isCbChecked" and store that bool state in your PhoneApplicationService.State.
Code:
PhoneApplicationService.Current.State.Add("isCbChecked", myCheckbox.IsChecked)
Then, when you're restoring your app, simply do
Code:
myCheckbox.IsChecked = (bool)PhoneApplicationService.Current.State.ContainsKey("isCbChecked");
Click to expand...
Click to collapse
Thanks a lot for your fast reply.
Can I ask for additional help on how to make your statements into generic procedures, at least to take them to something similar to what I posted?
Don't care if it's in C#
Thanks in advance!
GFR_2009 said:
Thanks a lot for your fast reply.
Can I ask for additional help on how to make your statements into generic procedures, at least to take them to something similar to what I posted?
Don't care if it's in C#
Thanks in advance!
Click to expand...
Click to collapse
Off the top of my head, something like this should work (C# code).
Code:
public static T RestoreState<T>(string key)
{
if (PhoneApplicationService.Current.State.ContainsKey(key))
{
return (T)PhoneApplicationService.Current.State[key];
}
return null;
}
'T' is the type that will be used. In C# 'T' is a special character denoting the generic type, not something I just used
So in the code above, the return type is 'T' and when using RestoreState, it will be 'RestoreState<Textbox>("TB.Name");'. The value of 'TB.Name' will be searched within the dictionary and, if it's found, it will cast that object as 'T' (Textbox) and return it, otherwise it will return null.
Hi,
So far, I did the following and while no error is raised, nothing happens...
Code:
Public Function Backup(ByVal token As String, ByVal value As Object) As Boolean
If Nothing Is value Then
Return False
End If
Dim store = PhoneApplicationService.Current.State
If store.ContainsKey(token) Then
store(token) = value
Else
store.Add(token, value)
End If
Return True
End Function
Public Function Restore(Of T)(ByVal token As String) As T
Dim store = PhoneApplicationService.Current.State
If Not store.ContainsKey(token) Then
Return Nothing
End If
Return CType(store(token), T)
End Function
I call them as follows
Code:
Backup(Me.CheckBox_1.Name, Me.CheckBox_1)
Restore(Of CheckBox)(Me.CheckBox_1.Name)
Don't where is the error, maybe you could take a look and help me out.
Any help is much appreciated!
Where are you calling the Backup and Restore functions? Since your doing page specific things, you could do it in the OnNavigatedFrom and OnNavigatedTo methods, respectively.
keyboardP said:
Where are you calling the Backup and Restore functions? Since your doing page specific things, you could do it in the OnNavigatedFrom and OnNavigatedTo methods, respectively.
Click to expand...
Click to collapse
Hi,
I'm calling them in the OnNavigatedTo and OnNavigatedFrom methods, as you pointed out
Unfortunately, nothing happens at all!
Thanks!
Hi,
As far as I can tell, there's nothing wrong with your saving/loading code. When you call
"Restore(Of CheckBox)(Me.CheckBox_1.Name)", is that returning a bool? You need to assign that bool to the checkbox:
Code:
myCheckbox.IsChecked = Restore(Of CheckBox)(Me.CheckBox_1.Name);
Also, all variables are reset when the page loads, so make sure you have set "myCheckbox.IsChecked" anywhere else on the page that could be called when the page loads.
Please, check the converted code of the above functions, to C#
Code:
public bool Backup(string token, object value)
{
if (null == value)
{
return false;
}
var store = PhoneApplicationService.Current.State;
if (store.ContainsKey(token))
{
store(token) = value;
}
else
{
store.Add(token, value);
}
return true;
}
public T Restore<T>(string token)
{
var store = PhoneApplicationService.Current.State;
if (! (store.ContainsKey(token)))
{
return default(T);
}
return (T)(store(token));
}
Do you think they are OK?
How should I call them ?
Clearly, the restore does not returns a boolean...
Honestly, I'm lost now!
Hope this helps to find the culprit.
It seems okay to me. You'll have to do some debugging. Set a breakpoint inside the Backup and Restore methods. Step through each line and make sure it's going to the line you expect it to and that the value being set is the correct one.
I haven't seen the tombstoning sample from MSDN, but can you get that to work? If so, is the generic method causing the problem? Or can you not get it to work at all?
Hi,
Sorry for the delay in getting back, but I was trying different codes and at least I found the cause.
Code:
Me.NavigationService.Navigate(New Uri("/PivotPage1.xaml?Name=" & "John", UriKind.Relative))
[B]Me.NavigationService.GoBack[/B]()
Me.NavigationService.Navigate(New Uri("/PivotPage1.xaml", UriKind.Relative))
Everything works fine, and the Checkbox state is saved/restored (in the Pivot Page) if I GO BACK using the GoBack hardware button or Me.NavigationService.GoBack
But, the state's dictionary entry is lost or ignored if I go back with the Navigate service (lines 1 and 3)...
Problem is that I need to get back with the query string...
The query string contains a value taken in the SelectedItem event of PAGE2's ListBox, and automatically once retrieved must go back.
I didn't know until know, that NavigationService.Navigate creates a new page instance or something like that in the backstack...
Any sugestions are welcomed!
Hi,
There are various methods you can use depending on the app's architecture. For example, you could have a 'shared' class that contains a shared field that holds the SelectedItem value. When the user selects the item, set the shared field's value and then when you go back, you can get the value from the shared field.
keyboardP said:
Hi,
There are various methods you can use depending on the app's architecture. For example, you could have a 'shared' class that contains a shared field that holds the SelectedItem value. When the user selects the item, set the shared field's value and then when you go back, you can get the value from the shared field.
Click to expand...
Click to collapse
So, no other way to cope with the navigation service?
It's a strange behaviour for sure...
Will try your ideas.
Thanks a lot for your reply!
GFR_2009 said:
So, no other way to cope with the navigation service?
It's a strange behaviour for sure...
Will try your ideas.
Thanks a lot for your reply!
Click to expand...
Click to collapse
There are other ways. For example, instead of using the PhoneApplicationService to store the tombstoning information, you could put it in a querystring for page 2. Then, in page 2, you could add the information from the previous page to a querystring AND the information of the selected item to the querystring. Navigate to page 1, with the querystring that contains information on what was there before and what the user selected. Tombstoning is there for when the user presses the hardware search button, home button, a phone call arrives etc.. It's not there for the navigation of the app. That's where querystrings, shared variables, binary serialization etc... come into play.
The concept of the navigation service is similar to a website. For example, when you submit something and then go back, it might still be there in the page state. However, if you submit something and then reload the previous page by typing it in the address bar, it becomes a completely new page as no state is stored.
keyboardP said:
There are other ways. For example, instead of using the PhoneApplicationService to store the tombstoning information, you could put it in a querystring for page 2. Then, in page 2, you could add the information from the previous page to a querystring AND the information of the selected item to the querystring. Navigate to page 1, with the querystring that contains information on what was there before and what the user selected. Tombstoning is there for when the user presses the hardware search button, home button, a phone call arrives etc.. It's not there for the navigation of the app. That's where querystrings, shared variables, binary serialization etc... come into play.
The concept of the navigation service is similar to a website. For example, when you submit something and then go back, it might still be there in the page state. However, if you submit something and then reload the previous page by typing it in the address bar, it becomes a completely new page as no state is stored.
Click to expand...
Click to collapse
Hi,
Will try your suggested approach, and thanks a lot for the last explanation on how the darn thing works.
Thanks again!
GFR_2009 said:
Hi,
Will try your suggested approach, and thanks a lot for the last explanation on how the darn thing works.
Thanks again!
Click to expand...
Click to collapse
You're welcome . It's one of those things that take a bit of time to understand, but starts to make sense. You might be interested in a free WP7 development ebook by Charles Petzold.
keyboardP said:
You're welcome . It's one of those things that take a bit of time to understand, but starts to make sense. You might be interested in a free WP7 development ebook by Charles Petzold.
Click to expand...
Click to collapse
I already have the book, but will need a deeper reading
So far, I've been testing your idea of using global classes and works ok.
Thanks a lot for being so cooperative, it's much appreciated!
GFR_2009 said:
I already have the book, but will need a deeper reading
So far, I've been testing your idea of using global classes and works ok.
Thanks a lot for being so cooperative, it's much appreciated!
Click to expand...
Click to collapse
No worries! If programming was super easy everyone would be doing it
keyboardP said:
No worries! If programming was super easy everyone would be doing it
Click to expand...
Click to collapse
Never said better!

Categories

Resources