[Windows Mobile Development and Hacking General] yobdren:
Hi,

I am attempting to develop a program which must have good control over the state of the built in GPRS or CDMA unit of a Windows Mobile 2003 PDA device.

One requirement is to be able to enter “flight mode” on demand (when the user selects a menu option). The user can not select the connection manager notification and manually select the “enter flight mode” link as this is a fully locked down application (the user does not have access to it). Hence I am looking for ways to programmatically enter/leave/query the status of flight mode.

At present we are using Connection Manager to deal with connection management and RIL to deal with entering/leaving flight mode. In previous versions we used TAPI (the lineGetEquipmentState and lineSetEquipmentState functions) to enter/leave flight mode.

Both approaches (using RIL or TAPI) are causing us grief, mainly due to having to support numerous PDA devices from numerous OEMs.

How have other people approached entering a device into flight mode via code? I am interested in suggestions on the following issues we have having with various techniques, and wondering if anyone has a solution which works well across a wide range of devices (we support various Symbol, Intermec, HTC, HHP, and Panasonic devices to name a few).

Our current issues are as follows:

If using TAPI to enter flight mode:

On some devices such as the Intermec 760 after using lineSetEquipmentState to enter LINEEQUIPSTATE_MINIMUM, querying the state via lineGetEquipmentState only returns the error LINEERR_OPERATIONFAILED. Entering full power mode again means lineGetEquipmentState starts returning proper values again. However you can’t assume that lineGetEquipmentState returning LINERR_OPERATIONFAILED means being in flight mode as periodically some devices are returning this even while in full power mode (i.e. call it 5 times, three might return LINEERR_OPERATIONFAILED and the other two will return valid results).

Alternatively I have tried using the lineGetLineDevStatus function and checking flags within the returned dwDevStatusFlags field. For instance LINEDEVSTATUSFLAGS_CONNECTED or, LINEDEVSTATUSFLAGS_INSERVICE. Again in testing this on numerous devices (eg. Xda IIi and Intermec 760 for instance) both the connect and inservice fields appear to be constantly set, even if in a GPRS based devices there is no SIM card present.

If using RIL to enter flight mode:

We have also tried accessing RIL (using information from http://www.xda-developers.com/ was very helpful in using this “undocumented” API), via calling RIL_SetEquipmentState(RIL_EQSTATE_MINIMUM) and listening for RIL_NOTIFY_RADIOEQUIPMENTSTATECHANGED notifications to tell us when the radio enters/leaves various power states. The problem with this approach is that on some devices (in certain cases) we appear to never get a notification indicating that we have returned to FULL power mode, instead we get RIL_EQSTATE_UNKNOWN being constantly returned.

On one device using the RIL interface even appears to lock up the device (followed by a soft reset a couple of minutes later) while we attempt to enter flight mode by calling, RIL_Hangup, RIL_UnregisterFromNetwork and RIL_SetEquipmentState in that sequence.

I’m open to suggestions on how to enter flight mode via code. Does Microsoft provide an API to do this across all devices in a consistent manor? I guess from previous similar experiences that is wishing too much.

At present I am somewhat dubious about using the RIL interface to enter flight mode while also using Connection Manager at the same time to maintain a connection. At present before attempting to enter flight mode I’m calling ConnMgrReleaseConnection in order to try to tidy up Connection Manager’s state as much as possible, but is it possible that Connection Manager is still getting confused by me going in underneath it (via RIL) and “pulling the carpet out from underneath it”?

Thanks,

Christopher Fairbairn