Accessing GPS data on HTC device - Windows Mobile Development and Hacking General

Hi,
I'm developping a program that use the GPS of the Pocket PC. I first start development on a Mio A201 and I just had to open COM port to automatically receive NMEA trames.
I am now on HTC Diamond and my code does not work anymore... I still open the COM port but nothing comes and if I try to write something on port, I have instantly a timeout Exception evenif I set up WriteTimeout to udge number...
Anyone have already uses the GPS on HTC devices and can help me?
I'm using Framework.net and C# under VS2008. Thanks by advance.
PS: I'm using COM4 at 4800 bauds as Tomtom which works perfectly!

I'm developing a new program with HTC Diamond called "Where is...", and i look that if you open and close and re-open the port it dont work.
Open port after 1 second of start of program and maintain opened during the application work and read all data every 1 second or more or use the Event DataReceived.
Close port when FormClosing.
Bye

Thanks for reply, here is my code:
Code:
[...]
SerialPort spGps;
spGps = new SerialPort("COM4", 4800, Parity.None, 8, StopBits.One);
spGps.ReceivedBytesThreshold = 16;
SerialDataReceivedEventHandler handler;
handler = new SerialDataReceivedEventHandler(spGps_DataReceived);
spGps.DataReceived += handler;
spGps.Open();
[...]
And spGps_DataReceived function is never called with my HTC Diamond whereas it works with another Pocket PC with embedded GPS...
Any idea???
Thanks for the help

Up!
I've also tried to set RTS (Request To Send) and DTR (Data Terminal Ready) signals but with no results...
Damn GPS

Well I'm quite surprised: When I try to ReadLine() on the port, I receive a NMEA trame! I don't really understand the mecanism... Are the data buffered or generated on demand? Because in a case of buffered data, why my handle doesn't work, and how to know the 'date' of a trame... ?

Related

How to create a virtual Com port

Hello.
I am trying to develop an application that allows multiple applications to access GPS co-ordinates from TOMTOM. I have the tomtom control that allows other applications to get the gps location. I was hopnig to create virtual com ports on the PPC and send the gps location to the virtual com port.
Does anyone know how tyo create a virtual com port on the ppc using EVB, or does anyone have a control to create one that I could use.?
Hiya,
Although I don't know how to create what you asked, there is a product called GpsGate that already does what you've just said:
http://franson.com/gpsgate/index.asp?
You may find it easier/quicker to just purchase theirs than write your own (Pricing = USD $15 to $30 depending on version) but obviously that's your choice.
I use it to share my GPS between TomTom and WiFiFoFum and works perfectly!
Cool - I've just had a lok it looks fine, I'll try it out for a few days - Thanks

Using multiple GPS apps simultaneously - A small investigation

Searched all forums for ( GSP , Comports, Multple, split comport, duplex )
I have no troubles using any GPS app on my Universal (MDA Pro)
However, using...... GPS gate (buyware)
....or the free GPS splitter that comes with
Microsoft Virtual Earth Mobile (freeware, GPS icon suddenly appears under settings-connections after install of Microsoft Virtual Earth Mobile,
....or app found at http://www.gpsmeter.com/ (browse to portsplitter)
i am still unable to successfully run two GPS apps at the same time.
Don't get me wrong, I DO succeed in getting two GPS apps READ the data.
Both apps will show connection , for instance TomTom together with my own app PocketReperion, but tried with Visualgpsce http://www.visualgps.net/VisualGPSce/ and a lot of other apps too.
Symptoms : Even though successfull in setting up various comsplitters to send data to 1 virtual port, and have multiple GPS application accessing them, I am unable to get that situation stable.
So the concept on a lot if ISO layers has been proven, why the hell doesn't it work for longer that say a minute, 4 minutes, not at all, 10 seconds...
It seems that most comsplit apps are rather "reset" intensive (tested on clean device) and even when it does work for a while something will lockup and a reset is again necessary.
Does anybody use the blue GPS icon (free after install virtual earth mobile) to split ports and if so what is your setup ?
Does anybody use GPSGATE to split ports and if so what is your setup ?
Does anybody use the PortSplitter linked to above..to split ports and if so what is your setup ?
Please share your thought and expierences with me as I really really want to solve this issue. Be it for my "own" app, but also for all the other ones out there.
GPS port splitting multiple GPS apps on 1 receiver
Small BUMP : Doesn't anyone use portsplitting in whatever form, or am I really the UeBerGEEK here ?
It Works !!
IT WORKS !!!! BUT YOU HAVE TO CREATE TWO VIRTUAL PORTS - USE PORTSPLITTER !!!
All I had to do is download http://www.gpsmeter.com/ portsplitter as discussed in the other threads, HOWEVER......
Instead of what manuals seem to say, even from other softwarez like GPSGate, create TWO or more VIRTUAL ports in PORTSPLITTER!! Connect each GPS app to a DIFFERENT VIRTUAL PORT.
Also, when pairing and configuring your GPS, try taking a high Comport like 9. Go down one if no success.
Then when configuring PORTSPLITTER, don't be alarmed that your COMPORT isn't in the drop down list, MANUALLY enter "COMx" without the usual ":" where x stands for a number..the high real COM portnumber you configured when pairing/setting up.
You must use your keyboard or the stylus to manually enter the Comport if it is not in your dropdown list in PORTSPLITTER..
for speedreaders :
install PORTSPLITTER http://www.gpsmeter.com
use highest physical COMport available to pair your GPS
Define TWO virtual ports (instead of what seems to be written everywhere or am I really lame?)
Connect each Application to different virtual ports
My setup on a T-Mobile MDA Vario II (with Cingular ROM)
Physical Port 9
Virtual Ports in PORTSPLITTER 4,8
Hardware COMport in PORTSPLITTER (COM9 had to manually enter it, it was unavailable from drop down.... .... ...)
TomTom Navigator mapped to virtual COM8 (Didn't show up in TOMTOM until PORTSPLITTER running and connected to GPS.. ..)
Reperion *sweet favorite GPS app" mapped to Virtual COMPort 4 (Reperion eats all ports, no problems there....)
Please o please report...

Finding available ports in HTC P3600 / Trinity

Hi,
My first post here!
I use the following in VB.NET 2005 to obtain a list of available ports in my HTC P3600:
Code:
Dim s As String
For Each s In SerialPort.GetPortNames()
Console.WriteLine(" {0}", s)
Next s
When I run this piece of code, it only finds COM3. I have a ROM in my P3600 that has the GPS activated. GPS is available on COM9, but I don't see this port in the list of portnames. When I connect directly to COM9, I get GPS data, so I know it works.
Any idea why COM9 doesn't show up with the code above? Is this port maybe hidden for developers?
CD
Nobody able to help with this?

Toggle WiFi/BT/Phone using .NET code only!!!

Hi people,
A little something primary for .NET developers but native developers can benefit from this too.
Maybe you were working really hard to make google find you a .NET code to toggle radio devices. I know I did and i was unsuccessful.
Maybe you found some sites about ossvcs.dll and undocumented functions for controlling the Radio Devices. But you were just missing that last piece - .NET code that calls them without some intermediate c++ dll.
Your search is over because i give you my .NET CF code that you can use to toggle WiFi/Bluetooth/Phone by using PInvoke of undocumented functions in mentioned ossvcs.dll!
This is a general solution, so it should work on all devices (I tried it on old ipaq 1940, Qtek 8310 and HTC s730)!
DllImports :
[DllImport("ossvcs.dll", EntryPoint = "#276")]
internal static extern int GetWirelessDevices(ref IntPtr pDevices, int dwFlags);
[DllImport("ossvcs.dll", EntryPoint = "#280")]
internal static extern int FreeDevicesList(IntPtr pDevices);
[DllImport("ossvcs.dll", EntryPoint = "#273")]
internal static extern int ChangeRadioState(IntPtr pDevices, int dwState, SAVEACTION sa);
In the attachement you will find code for 3 projects :
- RadioManager (real code is here)
- RadioManagerTester (Forms application for testing)
- RadioMngrCnsl (Console application for users)
If you have any questions feel free to post them here.
If you want to show your support for my work and encourage me to continue posting code like this you can do that by donating through
Just send me a PM and i'll tell you my e-mail address.
Hi!
Thanks for sharing your code... I pitty you didn't do it a week ago , hehehe... I found a really close solution but I've tried your's as it seems better structured . Although the wifi doesn't work on my device for some reason (HTC Herald). By mixing your solution and mine it does work. Here you've the code:
Code:
[DllImport("coredll.dll", SetLastError = true)]
public static extern int DevicePowerNotify(string name, CEDEVICE_POWER_STATE state, int flags);
public void SwitchWifiState()
{
rdm = new RadioDeviceManager();
rdm.Dispose();
}
private void _WiffiToggle(String name)
{
CEDEVICE_POWER_STATE cps = Microsoft.WindowsMobile.Status.SystemState.WiFiStatePowerOn ? 4 : 0;
DevicePowerNotify(name, cps, 1);
}
In case you find some one with the same problem you can give this a try .
Thanks again for your share!!
Hmmm....i was using that solution with DevicePowerNotify but then i had a lot of problem with comm manager. If I turn on device with this i can't turn it off with comm manager. And if i turn it off i can't turn it on with comm manager (on Qtek 8310).
Anyway, does RefreshDevicesList iin RadioDeviceManager class returns RDD structure for your radio device? Can you toggle bluetooth or phone?
amaric said:
Hmmm....i was using that solution with DevicePowerNotify but then i had a lot of problem with comm manager. If I turn on device with this i can't turn it off with comm manager. And if i turn it off i can't turn it on with comm manager (on Qtek 8310).
Anyway, does RefreshDevicesList iin RadioDeviceManager class returns RDD structure for your radio device? Can you toggle bluetooth or phone?
Click to expand...
Click to collapse
On my devie there are no such problems... Strange....
Your code detects my wifi perfectly and toggles BT and Phone... It just doesn't work with Wifi... No error is thrown...
no devices found
hi,
i am quite new to .NET programming... i have been using c++ all this while.. I tried your code on my windows mobile 6.0 professional product.. but unfortunately i keep getting "Devices not found" message..
Is there any issue that i have not taken care of..
thank you very much for any help..
thanks for your code too....
regards,
Senthil.K
wifi
am devloping a WM 6 app in VB.net (2005)
ok i have the bluetooth bit sorted and working fine.
However I can't get the wifi bit working.
It appears not to be able to find the correct device to change the power on
I also can't open the example code as its in a different VS version.
Any ideas?
Thanks
Hello everyone,
sorry for not being so professional, but I figured out that manually changing the following registry keys it makes the job done even though the 'Comm Manager' doesn't realize the wifi has turned off.
Any recommendation not for doing so?
HKEY_LOCAL_MACHINE\System\State\Hardware\Wifi (5 disabled, 23 enabled)
HKEY_LOCAL_MACHINE\Software\Drivers\WLAN\WlanStatus (0 disabled, 1 enabled)
(using HTC Touch HD)
Have a nice day.
Hey amaric,
Thanks a lot for sharing.
It works flawlessly on my Touch Diamond.
I still can't toggle bluetooth with this

[UNDER DEVELOPMENT]Windows Mobile 6 Bluetooth and Wiimote

I am currently trying to develop some software that allows to use a wiimote or a ps3 controller (ex. for fpsece).
all in vb.net
I currently discovered that I am unable to connect. I have already found a similar project that stopped because of the same problem!
I have read that the problem is the missing HID/S2CAP support of 32feet.net
The other software uses BlueTools so there may be the same problem!.
Does anyone know something that allows me to connect to my wiimote?! Maybe some SDK with HID/S2CAP support?!
You own an HD2 and another WinMob device and want to help? Take a look here: http://forum.xda-developers.com/showpost.php?p=5553883&postcount=10
Sorry, i cant help you but i will love control a wii with my HD...
I am speaking of the other way round , but I could also try that ^^.
I am talking about to control your HD with a Wiimote
It would be easy, if there is any idea how succesfull connect to the wiimote
I have found something here: http://www.eggheadcafe.com/software/aspnet/31158420/big5bxf276hrqkrnsut.aspx
I will see if it helps
Mhh, to bad, I cannot find the source files I would need
They maybe in the "Windows CE 5 platform builder" But the Online Setup I was able to get doesn't work anymore
scilor said:
I am speaking of the other way round , but I could also try that ^^.
I am talking about to control your HD with a Wiimote
It would be easy, if there is any idea how succesfull connect to the wiimote
Click to expand...
Click to collapse
Control your Wii with HD... It would be a great app.. if you can write it...
Thanks my Friend.
I was looking at doing this at one point. The HD2 with its Widcomm bluetooth stack supports BT HID, and the later WM6.5.X builds have Bth_HID in the SYS.
Pairing doesn't get you very far though. I found some C++ code for using the Wiimotes, but I haven't transfered it yet.
@l3v5y Why you have always the same ideas I do
The Bluetooth Stack of the HD2 seems to be a little bit buggy:
If I try to use a Bluetooth chat, it just works from my HD2 to my Kaiser, not the other way round. It is as my HD2 blocks all incoming Bluetooth connections
Any idea?
please setup a team , winmo need you
cheer
Ok, I have attached the Bluetooth Chat here.
It would be nice if other HD2 users could test it(You will need the HD2 and another WinMob Phone with a Widcomm Stack). Please always post the Roms of the devices, especailly the HD2's.
If it is only occurs on some ROMS, it would be fine, so I will do a Rom upgrade for further testing
My results where:
HD2 - T-Mobile ROM 1.43.11.2 (70315) Ger
Kaiser - Custom Rom WinMob 6.5
Message HD2 to Kaiser: Works fine, but takes a second.
Message Kaiser to HD2: Connection error, no message!
I found following in the thread of WiiMöb: http://wiimob.codeplex.com/Thread/View.aspx?ThreadId=10953
"But it seems likely that any purely bluetooth work was a red herring, and we just need to tackle BTHHID.DLL and devise a P/Invoke library that will get us a Filehandle to the device through the HID stack."
Hi everybody,
I'm also looking for a solution for that.
As I had similar problems with my Notebook (Widcomm-BT-Stack), I could solve it with a different BT stack. But I don't want to part with the Widcomm on my HD2.
I think the main problem is that the OK softbutton is disabled as long as there is no passcode in the inputbox. It only gets enabled if you enter somthing, which would never match up with the empty passcode of the WiiMote (somthing <> nothing ;-).
If the OK softbutton was enabled even with empty passcode box, the codeless pairing might actually work.
Is there anybody capable of unlocking this OK button?
Please
ScruffR
The problem is that the WM Devices misses a special HID driver . You may connect it with out a passcode with some tricks but this won't help because you cannot connect to the device
Look at this Symbian project http://www.symbianresources.com/projects/wiirider.php - maybe that will help. I got the same problem like everybody - can't pair device :s
We cannot connect the WiMote low-level easily, that is the big problem. If we could it would be easy.
...I'm assuming this has been abandoned? :/
Until someone finds a way to get a stream, the development is stopped
There is a way to connect to the Wii Remote with a WM 6 device.
The driver you want to look for should come with WM 5 and 6 devices. It has the prefix "BHI" it is not meant for production use, and it somewhat bare-bones, however you can successfully connect to the Wii Remote with it.
The registry path for this driver is:
HKLM\Software\Microsoft\Bluetooth\Hid\Hid_Class
and
HKLM\Software\Microsoft\Bluetooth\Hid\Instance
If you activate these drivers using the Win32 ActivateDeviceEx command (upon hard reset you don't have to do this), you should be able to open up a file stream to the driver.
Code:
HANDLE read_test = CreateFile(L"BHI0:", 0, 0, NULL, OPEN_EXISTING, 0, NULL);
Code:
unsigned __int64 wii_addr = 0x002659F4EEEDL; // BT_ADDR, 64 bits (8 bytes)
Then, I call the DeviceIoControl function to connect to the Wii Remote:
Code:
bool device_io_success = DeviceIoControl(read_test, 1, &wii_addr, sizeof(wii_addr), NULL, 0, NULL,NULL);
e = GetLastError();
Just replace the wii_addr with your Wii Remote's Bluetooth address.
The source code for this driver can be found by googling:
"bthhid.cxx source code" it should be the first link.
The set of APIs it provides is minimal, and I was not able to get any other function to work besides HIDConnect.
I'm still working on getting some sort of data from it.
Let me know if this works for you,
Mike
Could you send me a link to the source? I am finding any
I will take a look later, maybe we get it running
Unfortunately, I can't post the link due to spam restrictions (I just joined the forums recently). However, I have attached the folder that includes all the source files with this post.
This folder comes with Windows CE Platform Builder. It is located here (if you have Platform Builder installed):
C:\WINCE500\PRIVATE\WINCEOS\COMM\BLUETOOTH\PROFILES\HID
If you navigate to the BASE folder, you will find bthid.cpp. This is the main source that contains the stream driver implementation.
The main section of this file to examine is around line 2500 on down. These are the functions that are exposed when you create a file handle to the driver.
Let me know how it works out,
Mike

Categories

Resources