WinCE 6.0, work with GPRS / WiFi

I am working on a project that needs to connect to servers via wifi / gprs. Project is a Windows CE 6.0 application that I am writing in Visual Studio 2008 in C #.

I have two severs to work with. First I have to connect via wifi, second via gprs. So I need to know how can I change the connection method between wifi and gprs?

I found and tried this way: I enable both wifi and gprs on my device. So I work over Wi-Fi because it has a higher priority. When I need to work through gprs, I will disable the wifi ( SetDevicePower

) function . But when I turn on Wi-Fi, it doesn't connect to my preferred network.

Also I've heard about how to programmatically change the priority between gprs / wifi in the OS priority table, but I haven't found any information on how to do this.

I hope you can help me.

+3


source to share


1 answer


I would use the route command from the shell.

suggests

server1 ip: 123.123.123.1
server2 ip: 123.123.123.2

wifi ip   : 192.168.1.101
   gateway: 192.168.1.1

gprs ip   : 10.1.2.3
   gateway: 10.1.1.1

      

You can now subtract on the command line

route add 123.123.123.1 MASK 255.255.255.255 192.168.1.1

      

and

route add: 123.123.123.2 MASK 255.255.255.255 10.1.1.1

      

This should route all traffic to server 1 over wifi and server 2 over gprs without changing a single line of code in your application.

You can check if it works with



tracert 123.123.123.1
tracert 123.123.123.2

      

However, you can use your app to periodically do this task (I assume the gprs ip may change from time to time) using Process.Start (...)

- delete route 1
- add route 1
- delete route 2
- add route 2

      

You could even specify an interface using a switch IF 2

(the route list prints the interface id for your network cards).

Another interesting post to read: http://ce4all.blogspot.com/2007/05/routing-ip-traffic-via-specified.html

The author uses GetAdapterAddresses () and CreateIpForwardEntry () P / Invokes:

http://msdn.microsoft.com/en-us/library/ms927384.aspx

http://msdn.microsoft.com/en-us/library/ee495149%28v=winembedded.60%29.aspx

+2


source







All Articles