POSAPI
类 POSBluetoothAPI

java.lang.Object
  继承者 POSAPI.POSInterfaceAPI
      继承者 POSAPI.POSBluetoothAPI

public class POSBluetoothAPI
extends POSInterfaceAPI

文件:BluetoothManager.java
日期:2011-3-20 -- 2011-5-20
范围:Android 应用及相关。
描述:Android 蓝牙操作
备注:实现本机蓝牙的操作方法的封装。

版本:
1.0
作者:
BEIYANG

字段摘要
static int ERR_PROCESSING
           
static int POS_FAIL
           
static int POS_SUCCESS
           
static int READBYTEMAX
           
static int STATE_CONNECTED
           
static int STATE_CONNECTING
           
static int STATE_LISTEN
           
static int STATE_NONE
           
static int STATE_OFF
           
static int STATE_ON
           
static int STATE_TURNING_OFF
           
static int STATE_TURNING_ON
           
static int WRITEBYTEMAX
           
 
从类 POSAPI.POSInterfaceAPI 继承的字段
ERR_PARAM
 
方法摘要
 boolean cancelDiscovery()
          函数名称:cancelDiscovery 函数功能:取消搜索 参数描述: 返回值说明:
 boolean closeBluetooth()
          函数名称:closeBluetooth 函数功能:关闭蓝牙 参数描述: 返回值说明:
 int CloseDevice()
          函数名称:CloseDevice 函数功能:关闭端口 参数描述: 返回值说明:
 void finallize()
          描述:最终化方法,关闭串口和蓝牙
 java.lang.String getAddress()
          函数名称:getInstance 函数功能:获取本机蓝牙MAC地址 参数描述: 返回值说明:
 java.util.Set<BluetoothDevice> getBondedDevices()
          函数名称:getBondedDevices 函数功能:获取已配对的蓝牙模块 参数描述: 返回值说明:
 int getConnectState()
          函数名称:getConnectState 函数功能:连接状态标志位 connectState get方法 参数描述: 返回值说明:
static POSBluetoothAPI getInstance(Context context)
          函数名称:getInstance 函数功能:获取蓝牙操作的对象的实例。
 java.lang.String getName()
          函数名称:getInstance 函数功能:获取本机蓝牙名称 参数描述: 返回值说明:
 int getState()
          函数名称:getInstance 函数功能:获取本机蓝牙状态 参数描述: 返回值说明:
 boolean isBTSupport()
          函数名称:isBTSupport 函数功能:本机是否支持蓝牙 参数描述: 返回值说明:
 boolean isDiscovery()
          函数名称:isDiscovery 函数功能:是否正在搜索 参数描述: 返回值说明:
 boolean openBluetooth()
          函数名称:openBluetooth 函数功能:打开蓝牙,本机支持蓝牙返回true,否则返回false;打开失败也返回false 参数描述: 返回值说明:
 int OpenDevice(java.lang.String macAddress)
          函数名称:OpenDevice 函数功能:连接设备 参数描述:
 int ReadBuffer(byte[] ReadBuffer, int OffsetSize, int nBytesToRead, int ReadTimeOut)
          函数名称:ReadBuffer 函数功能:从设备中读取数据 参数描述:。
 boolean setDiscoverable(int time)
          函数名称:setDiscoverable 函数功能:设置本机蓝牙可见 参数描述:
 boolean startDiscovery()
          函数名称:startDiscovery 函数功能:开始搜索蓝牙设备 参数描述: 返回值说明:
 int WriteBuffer(byte[] WriteBuffer, int OffsetSize, int nBytesToWrite, int WriteTimeOut)
          函数名称:WriteBuffer 函数功能:发送数据 参数描述:
 
从类 POSAPI.POSInterfaceAPI 继承的方法
OpenDevice, OpenDevice, OpenDevice, ReadBuffer, WIFIsearchPort
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

POS_SUCCESS

public static final int POS_SUCCESS
另请参见:
常量字段值

ERR_PROCESSING

public static final int ERR_PROCESSING
另请参见:
常量字段值

POS_FAIL

public static final int POS_FAIL
另请参见:
常量字段值

WRITEBYTEMAX

public static final int WRITEBYTEMAX
另请参见:
常量字段值

READBYTEMAX

public static final int READBYTEMAX
另请参见:
常量字段值

STATE_ON

public static final int STATE_ON

STATE_OFF

public static final int STATE_OFF

STATE_TURNING_ON

public static final int STATE_TURNING_ON

STATE_TURNING_OFF

public static final int STATE_TURNING_OFF

STATE_NONE

public static final int STATE_NONE
另请参见:
常量字段值

STATE_LISTEN

public static final int STATE_LISTEN
另请参见:
常量字段值

STATE_CONNECTING

public static final int STATE_CONNECTING
另请参见:
常量字段值

STATE_CONNECTED

public static final int STATE_CONNECTED
另请参见:
常量字段值
方法详细信息

getInstance

public static POSBluetoothAPI getInstance(Context context)
函数名称:getInstance 函数功能:获取蓝牙操作的对象的实例。 单例模式 参数描述:

参数:
context[in]:上下文 - 返回值说明:
返回:
成功:BluetoothManager对象,失败:null

isBTSupport

public boolean isBTSupport()
函数名称:isBTSupport 函数功能:本机是否支持蓝牙 参数描述: 返回值说明:

返回:
支持:true,不支持:false

getAddress

public java.lang.String getAddress()
函数名称:getInstance 函数功能:获取本机蓝牙MAC地址 参数描述: 返回值说明:

返回:
成功:本机蓝牙Mac地址 String,失败:null

getName

public java.lang.String getName()
函数名称:getInstance 函数功能:获取本机蓝牙名称 参数描述: 返回值说明:

返回:
成功:本机蓝牙名称,失败:null

getState

public int getState()
函数名称:getInstance 函数功能:获取本机蓝牙状态 参数描述: 返回值说明:

返回:
蓝牙状态:STATE_ON,STATE_OFF,STATE_TURNING_ON,STATE_TURNING_OFF

getConnectState

public int getConnectState()
函数名称:getConnectState 函数功能:连接状态标志位 connectState get方法 参数描述: 返回值说明:

返回:
蓝牙状态:STATE_NONE,STATE_LISTEN,STATE_CONNECTING,STATE_CONNECTED

openBluetooth

public boolean openBluetooth()
函数名称:openBluetooth 函数功能:打开蓝牙,本机支持蓝牙返回true,否则返回false;打开失败也返回false 参数描述: 返回值说明:

返回:
成功:true,失败:false

closeBluetooth

public boolean closeBluetooth()
函数名称:closeBluetooth 函数功能:关闭蓝牙 参数描述: 返回值说明:

返回:
成功:true,失败:false

setDiscoverable

public boolean setDiscoverable(int time)
函数名称:setDiscoverable 函数功能:设置本机蓝牙可见 参数描述:

参数:
time[in]:可见时间 - 返回值说明:
返回:
成功:true,失败:false

startDiscovery

public boolean startDiscovery()
函数名称:startDiscovery 函数功能:开始搜索蓝牙设备 参数描述: 返回值说明:

返回:
成功:true,失败:false

isDiscovery

public boolean isDiscovery()
函数名称:isDiscovery 函数功能:是否正在搜索 参数描述: 返回值说明:

返回:
成功:true,失败:false

cancelDiscovery

public boolean cancelDiscovery()
函数名称:cancelDiscovery 函数功能:取消搜索 参数描述: 返回值说明:

返回:
成功:true,失败:false

getBondedDevices

public java.util.Set<BluetoothDevice> getBondedDevices()
函数名称:getBondedDevices 函数功能:获取已配对的蓝牙模块 参数描述: 返回值说明:

返回:
成功:BluetootnDevice Set 集合 ,失败:null

OpenDevice

public int OpenDevice(java.lang.String macAddress)
函数名称:OpenDevice 函数功能:连接设备 参数描述:

覆盖:
POSInterfaceAPI 中的 OpenDevice
参数:
macAddress[in]:待连接设备Mac地址 - 返回值说明:
返回:
成功:POS_SUCCESS,失败:ERR_PROCESSING

WriteBuffer

public int WriteBuffer(byte[] WriteBuffer,
                       int OffsetSize,
                       int nBytesToWrite,
                       int WriteTimeOut)
函数名称:WriteBuffer 函数功能:发送数据 参数描述:

覆盖:
POSInterfaceAPI 中的 WriteBuffer
参数:
WriteBuffer[in]: - 发送端口数据的缓冲区
OffsetSize[in]: - 发送数据的地址的偏移量
nBytesToWrite[in]:发送端口数据的字节数 -
WriteTimeOut[in]:发送端口数据超时设置 - 返回值说明:
返回:
成功:返回实际写入的字节数,失败:返回0

ReadBuffer

public int ReadBuffer(byte[] ReadBuffer,
                      int OffsetSize,
                      int nBytesToRead,
                      int ReadTimeOut)
函数名称:ReadBuffer 函数功能:从设备中读取数据 参数描述:。

覆盖:
POSInterfaceAPI 中的 ReadBuffer
参数:
ReadBuffer[in]: - 存放读取数据的缓冲区
OffsetSize[in]: - 读取数据的地址的偏移量
nBytesToWrite[in]:读取数据的字节数 -
ReadTimeOut[in]: - 读取数据超时设置 返回值说明:
返回:
成功:返回实际写入的字节数,失败:返回0

CloseDevice

public int CloseDevice()
函数名称:CloseDevice 函数功能:关闭端口 参数描述: 返回值说明:

覆盖:
POSInterfaceAPI 中的 CloseDevice
返回:
成功:POS_SUCCESS,失败:ERR_PROCESSING

finallize

public void finallize()
描述:最终化方法,关闭串口和蓝牙