response = getGateway().getATHandler().getSimStatus();
}
if (response.indexOf("SIM PIN2") >= 0)
{
Logger.getInstance().logDebug("SIM requesting PIN2.", null, getGateway().getGatewayId());
if ((getGateway().getSimPin2() == null) || (getGateway().getSimPin2().length() == 0)) throw new GatewayException("The GSM modem requires SIM PIN2 to operate.");
if (!getGateway().getATHandler().enterPin(getGateway().getSimPin2())) throw new GatewayException("SIM PIN2 provided is not accepted by the GSM modem.");
Thread.sleep(Service.getInstance().getSettings().AT_WAIT_SIMPIN);
continue;
}
else if (response.indexOf("SIM PIN") >= 0)
{
Logger.getInstance().logDebug("SIM requesting PIN.", null, getGateway().getGatewayId());
if ((getGateway().getSimPin() == null) || (getGateway().getSimPin().length() == 0)) throw new GatewayException("The GSM modem requires SIM PIN to operate.");
if (!getGateway().getATHandler().enterPin(getGateway().getSimPin())) throw new GatewayException("SIM PIN provided is not accepted by the GSM modem.");
Thread.sleep(Service.getInstance().getSettings().AT_WAIT_SIMPIN);
continue;
}
else if (response.indexOf("READY") >= 0) break;
else if (response.indexOf("OK") >= 0) break;
else if (response.indexOf("ERROR") >= 0)
{
Logger.getInstance().logWarn("Erroneous CPIN response, proceeding with defaults.", null, getGateway().getGatewayId());
break;
}
Logger.getInstance().logWarn("Cannot understand SIMPIN response: " + response + ", will wait for a while...", null, getGateway().getGatewayId());
Thread.sleep(Service.getInstance().getSettings().AT_WAIT_SIMPIN);
}
getGateway().getATHandler().echoOff();
getGateway().getATHandler().init();
getGateway().getATHandler().echoOff();
if (!waitForNetworkRegistration()) Logger.getInstance().logWarn("Network Registration failed, proceeding with defaults.", null, getGateway().getGatewayId());
getGateway().getATHandler().setVerboseErrors();
if (getGateway().getATHandler().getStorageLocations().length() == 0)
{
try
{
getGateway().getATHandler().readStorageLocations();
Logger.getInstance().logInfo("MEM: Storage Locations Found: " + getGateway().getATHandler().getStorageLocations(), null, getGateway().getGatewayId());
}
catch (Exception e)
{
getGateway().getATHandler().setStorageLocations("--");
Logger.getInstance().logWarn("Storage locations could *not* be retrieved, will proceed with defaults.", e, getGateway().getGatewayId());
}
}
if (!getGateway().getATHandler().setIndications())
{
Logger.getInstance().logWarn("Callback indications were *not* set succesfully!", null, getGateway().getGatewayId());
getCnmiEmulationProcessor().enable();
}
else
{
if (getGateway().getATHandler().getIndications().getMode().equals("0")) getCnmiEmulationProcessor().enable();
}
if (getGateway().getProtocol() == Protocols.PDU)
{
if (!getGateway().getATHandler().setPduProtocol()) throw new GatewayException("The GSM modem does not support the PDU protocol.");
}
else if (getGateway().getProtocol() == Protocols.TEXT)
{
if (!getGateway().getATHandler().setTextProtocol()) throw new GatewayException("The GSM modem does not support the TEXT protocol.");
}
}
catch (TimeoutException t)
{
try