public class BluetoothService
extends BroadcastReceiver
修飾子とタイプ | フィールドと説明 |
---|---|
static byte |
ACK |
protected java.util.List<IBluetoothCallback<?>> |
callbackList
コールバックオブジェクトの配列
|
static byte |
NAK |
protected java.util.List<IBluetoothObserver> |
observers
オブサーバオブジェクトの配列
|
protected int |
POST_CONECT_FAILED
接続失敗の通知を表す。
|
protected int |
POST_CONNECTED
接続完了の通知を表す。
|
protected int |
POST_CONNECTION_LOST
切断の通知をを表す。
|
protected int |
POST_RECEIVE
データ受信の通知を表す。
|
protected int |
POST_WRITE
データ送信の通知を表す。
|
コンストラクタと説明 |
---|
BluetoothService() |
修飾子とタイプ | メソッドと説明 |
---|---|
void |
addCallback(IBluetoothCallback<?> callback)
コールバックを追加する。
|
void |
addObserver(IBluetoothObserver observer)
オブサーバを追加する。
|
void |
cancelDiscovery()
端末検索をキャンセルする。
|
void |
connect(BluetoothDevice device,
boolean secure)
接続作成スレッドを開始する。
|
void |
connect(java.lang.String address,
boolean secure)
接続作成スレッドを開始する。
|
void |
connected(BluetoothSocket socket,
BluetoothDevice device,
java.lang.String socketType)
接続管理スレッドを開始する。
|
protected byte[] |
convertToWriteStyle(java.lang.String command)
文字列をバイトに変換してESCとCRで挟む( opn2002送信用)
|
java.lang.Boolean |
doDiscovery(Context context,
DoDiscoveryCallback callback)
ペアリングしていない端末を検索する。
|
protected <T> boolean |
executeCallback(IBluetoothCallback<T> callback,
T parameter)
コールバックを実行する。
|
static java.nio.charset.Charset |
getCharaSet()
受信データの文字コードを取得する。
|
java.util.Set<BluetoothDevice> |
getPairedDevices()
ペアリングされた端末を取得する。
|
byte |
getResponseValue()
端末より受信したデータを取得する。
|
BluetoothServiceState |
getState()
接続状態を取得する。
|
boolean |
isSupportBluetooth()
Bluetoothをサポートしているかどうか。
|
void |
onReceive(Context context,
Intent intent) |
protected void |
postObserver(IBluetoothObserver observer,
int postType,
java.lang.Object[] obj)
オブザーバに通知処理を行う。
|
protected void |
postObserver(int postType,
java.lang.Object... obj)
オブザーバに通知処理を行う。
|
void |
removeCallback(IBluetoothCallback<?> callback)
コールバックを削除する。
|
void |
removeObserver(IBluetoothObserver observer)
オブサーバを削除する。
|
static void |
setCharaSet(java.nio.charset.Charset charaSet)
受信データの文字コードを設定する。
|
boolean |
showBluetoothSetting(Activity activity)
Bluetooth有効設定画面を表示させたかどうか。
|
boolean |
showBluetoothSetting(Context context)
Bluetooth有効設定画面を表示させたかどうか。
|
boolean |
showDiscoverable(Context context)
Bluetooth検索可能設定を表示させたかどうか。
|
void |
start()
Bluetooth通信サービスを開始する。
|
void |
stop()
全スレッド停止する。
|
protected boolean |
write(java.util.List<byte[]> commandList)
複数のコマンドを連続して送信する。
|
boolean |
write(java.lang.String out)
文字列を送信する。
|
protected java.util.List<IBluetoothObserver> observers
protected java.util.List<IBluetoothCallback<?>> callbackList
public static byte ACK
public static byte NAK
protected final int POST_CONNECTED
protected final int POST_CONECT_FAILED
protected final int POST_CONNECTION_LOST
protected final int POST_WRITE
protected final int POST_RECEIVE
public static java.nio.charset.Charset getCharaSet()
public static void setCharaSet(java.nio.charset.Charset charaSet)
charaSet
- 文字コードpublic void addCallback(IBluetoothCallback<?> callback)
callback
- コールバックpublic void removeCallback(IBluetoothCallback<?> callback)
callback
- コールバックpublic void addObserver(IBluetoothObserver observer)
observer
- オブサーバpublic void removeObserver(IBluetoothObserver observer)
observer
- オブザーバprotected void postObserver(int postType, java.lang.Object... obj)
postType
- 通知の種別obj
- パラメータprotected <T> boolean executeCallback(IBluetoothCallback<T> callback, T parameter)
callback
- 実行するコールバックparameter
- コールバック実行の際の引数protected void postObserver(IBluetoothObserver observer, int postType, java.lang.Object[] obj)
observer
- オブザーバpostType
- 通知の種別obj
- パラメータpublic boolean isSupportBluetooth()
public boolean showBluetoothSetting(Context context)
context
- 設定画面を表示させるコンテキストpublic boolean showBluetoothSetting(Activity activity)
activity
- 設定画面を表示させるアクティビティpublic boolean showDiscoverable(Context context)
context
- 設定画面を表示させるコンテキストpublic java.util.Set<BluetoothDevice> getPairedDevices()
public java.lang.Boolean doDiscovery(Context context, DoDiscoveryCallback callback)
context
- 端末検索レシーバを登録するコンテキストcallback
- 端末検索コールバックpublic void cancelDiscovery()
public void onReceive(Context context, Intent intent)
public byte getResponseValue()
public BluetoothServiceState getState()
public void start()
public void connect(java.lang.String address, boolean secure)
address
- 端末マックアドレスsecure
- 暗号化するかどうかpublic void connect(BluetoothDevice device, boolean secure)
device
- 端末secure
- 暗号化するかどうかpublic void connected(BluetoothSocket socket, BluetoothDevice device, java.lang.String socketType)
socket
- BluetoothSocketdevice
- 端末public void stop()
protected byte[] convertToWriteStyle(java.lang.String command)
command
- public boolean write(java.lang.String out)
out
- 送信文字列protected boolean write(java.util.List<byte[]> commandList)
commandList
- コマンドのリスト