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 (
) 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.
source to share
I would use the route command from the shell.
server1 ip: 220.127.116.11 server2 ip: 18.104.22.168 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 22.214.171.124 MASK 255.255.255.255 192.168.1.1
route add: 126.96.36.199 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 188.8.131.52 tracert 184.108.40.206
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
(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:
source to share