Developers guide

Chapter 22: Wireless Wide-Area Networking
Initializing The WWAN Driver
Psion Teklogix Mobile Devices SDK Developers Guide 203
// Try again.
retVal = WirelessWAN::GetReadyState(params, &wwanReadyStatePtr);
}
if ( retVal != WwanRequestSuccess ||
params.resultCode != WwanResultSuccess ||
wwanReadyStatePtr == 0)
{
// Unable to get the ready state. See return value/result code for reason.
return false;
}
ULONG readyState = wwanReadyStatePtr->State;
// Memory was allocated by "GetReadyState(...)"
free(wwanReadyStatePtr);
if ((readyState & WWAN_READY_STATE_INITIALIZED) != 0 )
{
// Already in the ready state.
return true;
}
// The wwan driver (or modem) is not in a usable state yet.
// Wait for it to become ready:
// Create and register the listener object to receive events
WWANReadyStateListener* myReadyStateListener = new WWANReadyStateListener();
WirelessWAN::SetIndicationsListener(myReadyStateListener);
WirelessWAN::SetIndicationsState(true);
// To prevent a race condition, check to see if the event occured between the
// time last check for the WWAN ready state and registration for the event.
retVal = WirelessWAN::GetReadyState(params, &wwanReadyStatePtr); // Try again.
if( retVal != WwanRequestSuccess ||
params.resultCode != WwanResultSuccess ||
wwanReadyStatePtr == 0)
{
// Unable to get the ready state. See return value/result code for reason.
// Remove indication registration and cleanup objects.
WirelessWAN::SetIndicationsListener(NULL);
WirelessWAN::SetIndicationsState(false);
delete myReadyStateListener;
return false;
}
// Check the ready state flag
readyState = wwanReadyStatePtr->State;
free(wwanReadyStatePtr); // Memory was allocated by "GetReadyState(...)"
if ((readyState & WWAN_READY_STATE_INITIALIZED) != 0 )
{
// Already in the ready state.
// Remove indication registration and cleanup objects
WirelessWAN::SetIndicationsListener(NULL);
WirelessWAN::SetIndicationsState(false);
delete myReadyStateListener;
return true;
Example 22.1 Initializing WWAN in C++ (Continued)