⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aathandler.java

📁 发送短信 接收短信 多种接口com/net/modem 开发库
💻 JAVA
字号:
// SMSLib for Java v3
// A Java API library for sending and receiving SMS via a GSM modem
// or other supported gateways.
// Web Site: http://www.smslib.org
//
// Copyright (C) 2002-2009, Thanasis Delenikas, Athens/GREECE.
// SMSLib is distributed under the terms of the Apache License version 2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.smslib.modem.athandler;

import java.io.IOException;
import java.lang.reflect.Constructor;
import org.smslib.GatewayException;
import org.smslib.TimeoutException;
import org.smslib.AGateway.AsyncEvents;
import org.smslib.InboundMessage.MessageClasses;
import org.smslib.modem.CNMIDetector;
import org.smslib.modem.ModemGateway;

public abstract class AATHandler
{
	private ModemGateway gateway;

	private String storageLocations;

	private String description;

	String[] terminators;
	String[] unsolicitedResponses;

	public AATHandler(ModemGateway myGateway)
	{
		this.gateway = myGateway;
		this.storageLocations = "";
	}

	public ModemGateway getGateway()
	{
		return this.gateway;
	}

	public String getDescription()
	{
		return this.description;
	}

	public String getStorageLocations()
	{
		return this.storageLocations;
	}

	public void setStorageLocations(String myStorageLocations)
	{
		this.storageLocations = myStorageLocations;
	}

	public void addStorageLocation(String myStorageLocation)
	{
		this.storageLocations += myStorageLocation;
	}

	public String[] getTerminators()
	{
		return this.terminators;
	}

	public String[] getUnsolicitedResponses()
	{
		return this.unsolicitedResponses;
	}

	public String getUnsolicitedResponse(int index)
	{
		return this.unsolicitedResponses[index];
	}

	public abstract void sync() throws IOException, InterruptedException;

	public abstract void reset() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract void echoOff() throws IOException, InterruptedException;

	public abstract void init() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract void done() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract boolean isAlive() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract String getSimStatus() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract boolean enterPin(String pin) throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract boolean setVerboseErrors() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract boolean setPduProtocol() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract boolean setTextProtocol() throws TimeoutException, GatewayException, IOException, InterruptedException;
	
	public abstract boolean setIndications() throws TimeoutException, GatewayException, IOException, InterruptedException;
	
	public abstract CNMIDetector getIndications();

	public abstract String getManufacturer() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract String getModel() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract String getSerialNo() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract String getImsi() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract String getSwVersion() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract String getBatteryLevel() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract String getSignalLevel() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract boolean switchStorageLocation(String mem) throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract void switchToCmdMode() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract int sendMessage(int size, String pdu, String phone, String text) throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract String listMessages(MessageClasses messageClass) throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract String getMessageByIndex(int msgIndex) throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract boolean deleteMessage(int memIndex, String memLocation) throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract String getGprsStatus() throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract String send(String s) throws TimeoutException, GatewayException, IOException, InterruptedException;

	public abstract String getNetworkRegistration() throws GatewayException, TimeoutException, IOException, InterruptedException;

	public abstract void readStorageLocations() throws Exception;

	public abstract String sendCustomATCommand(String atCommand) throws GatewayException, TimeoutException, IOException, InterruptedException;

	public abstract String readPhonebookLocations() throws GatewayException, TimeoutException, IOException, InterruptedException;

	public abstract String readPhonebook(String location) throws GatewayException, TimeoutException, IOException;

	public abstract AsyncEvents processUnsolicitedEvents(String response) throws IOException;

	public static AATHandler load(ModemGateway gateway, String gsmManuf, String gsmModel) throws RuntimeException
	{
		String BASE_HANDLER = ATHandler.class.getName();
		String[] handlerClassNames = { null, null, BASE_HANDLER };
		String[] handlerDescriptions = { null, null, "Generic" };
		StringBuffer handlerClassName = new StringBuffer(BASE_HANDLER);
		if (gsmManuf != null && gsmManuf.length() != 0)
		{
			handlerClassName.append("_").append(gsmManuf);
			handlerClassNames[1] = handlerClassName.toString();
			handlerDescriptions[1] = gsmManuf + " (Generic)";
			if (gsmModel != null && gsmModel.length() != 0)
			{
				handlerClassName.append("_").append(gsmModel);
				handlerClassNames[0] = handlerClassName.toString();
				handlerDescriptions[0] = gsmManuf + " " + gsmModel;
			}
		}
		AATHandler atHandler = null;
		for (int i = 0; i < 3; ++i)
		{
			try
			{
				if (handlerClassNames[i] != null)
				{
					Class<?> handlerClass = Class.forName(handlerClassNames[i]);
					Constructor<?> handlerConstructor = handlerClass.getConstructor(new Class[] { ModemGateway.class });
					atHandler = (AATHandler) handlerConstructor.newInstance(new Object[] { gateway });
					atHandler.description = handlerDescriptions[i];
					break;
				}
			}
			catch (Exception ex)
			{
				if (i == 2)
				{
					ex.printStackTrace();
					throw new RuntimeException("Class AATHandler: Cannot initialize handler!");
				}
			}
		}
		return atHandler;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -