I am developing an application on a device with os Windows ce3.0 Handheld PC 2000. My application is depending on a GPRS connection. So i wrote a couple control function in my application. First of all my application checks if there is an GPRS connection active. if not then it starts the connection using RasDial(). But somethimes when my application starts the connection it fails with the following error: ERROR_PORT_NOT_AVAILABLE The strange thing is that the Nokia Manager application tells me there is no GPRS connection active. But when I try to activate the connection it immidiatly pops up with a "disconnected" message following "ready to activate GPRS". But when i try it again, of course it fails again. The only thing I can do is remove the d211 from my device and insert it again to solve the problem. Is this a bug in the nokia driver? Does anybody have had simmilar problems and how did they solved it?
The activation usually fails if APN is incorrect or if connection requires setting IP address to DNS settings. However, ERROR_PORT_NOT_AVAILABLE sounds like the port was left open in a previous attempt. The RasDial() is a Windows RAS API function. If it is left open you need to ensure it is closed before attempting new connection with Nokia D211 SW. You could try RasDial() by giving it as parameter the phone book entry called 'GPRS' that comes with the D211 SW. Maybe the problem is caused by some entry that has incorrect information. Another alternative might be that something goes wrong when you check the status of active GPRS connection. How do you do the checking?
I don't think reseting the GPRS part will help in this case (Although there might be a command for that in the SDK, I'm don't remember for sure). The problem is more probably in RAS or COM port. Does the GPRS activation work at all? I mean can you activate GPRS when you try to activate connection manually or with some other SW? If this is the case then you need to check that GPRS is activated in your SIM and APN is entered correctly.
Another reason might be that you use you PDA while it is connected to PC through desk stand or serial cable. This causes the device to open connection and parallel connection cannot be opened.
The reason why Nokia D211 SW cannot open connection is because it also uses RasDial(). If you have some hyperterminal SW available for your PDA you might want to try activating attachment and context with AT commands to verify that it succeeds that way. APN must naturally be set beforehand.
ERROR_PORT_NOT_AVAILABLE indicates that the port may already be open. Have you checked that your program always terminates the connection by calling RasHangUp(). Forgetting to call RasHangUp() might cause such symptoms as you describe. There is also the following remark in the Windows Platform SDK:
"An application should not call RasHangUp and then immediately exit. The connection state machine needs time to properly terminate. If the system prematurely terminates the state machine, the state machine may fail to properly close a port, leaving the port in an inconsistent state. A simple way to avoid this problem is to call Sleep(3000) after returning from RasHangUp; after that pause, the application can exit. A more responsive way to avoid the problem is, after returning from RasHangUp, to call RasGetConnectStatus(hrasconn) and Sleep(0) in a loop until RasGetConnectStatus returns ERROR_INVALID_HANDLE."
Nokia D211 Support
Naturally the best way of testing the case of lost connection would be to cause a real loss of signal, e.g. find an area where the signal is weak and then cover the aerial. The NET service set in the D211 SDK provides functions/messages that could be useful. For example, the REQ_NET_POWEROFF_GSMRADIO turns the GSM phone off (the phone can be restarted only by removing the card).
Nokia D211 Support