public AcceptThread(boolean secure)
{
//Tmp变量
BluetoothServerSocket tmp = null;
//初始化类型
mSocketType = secure ? "Secure":"Insecure";
// 创建一个服务的Listener
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
java类android.bluetooth.BluetoothServerSocket的实例源码
BluetoothSPPService.java 文件源码
项目:BleDemo
阅读 34
收藏 0
点赞 0
评论 0
BluetoothIOGateway.java 文件源码
项目:ELM327
阅读 36
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure)
{
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Create a new listening server socket
try
{
if (secure)
{
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
}
else
{
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
}
}
catch (IOException e)
{
MyLog.e(TAG, "Listen to " + mSocketType + " socket type failed. More: ", e);
}
mmServerSocket = tmp;
}
BluetoothListener.java 文件源码
项目:VR-One
阅读 43
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
mState = STATE_LISTEN;
}
BluetoothChatService.java 文件源码
项目:bluetooth-chat-appliction
阅读 42
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
mState = STATE_LISTEN;
}
BTAdt.java 文件源码
项目:AndroidSDK2.0
阅读 39
收藏 0
点赞 0
评论 0
/**
* Sets new server socket.
*/
public void setNewServerSocket()
{
BluetoothServerSocket tmp = null;
try
{
if(mProtocolVer == 2)
tmp = mAdapter.listenUsingRfcommWithServiceRecord( NAME_PEN, NeoOne_UUID );
else
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord( NAME_PEN, NeoOne_UUID );
NLog.d( "[BTAdt] ListenThread new BT ServerSocket assigned" );
}
catch ( IOException e )
{
NLog.e( "[BTAdt] ListenThread new BT ServerSocket assign fail", e );
}
mmServerSocket = tmp;
}
BluetoothChatService.java 文件源码
项目:SmartRC
阅读 47
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
DroidtoothPlugin.java 文件源码
项目:Nird2
阅读 47
收藏 0
点赞 0
评论 0
@Override
public KeyAgreementListener createKeyAgreementListener(byte[] commitment) {
if (!isRunning()) return null;
// There's no point listening if we can't discover our own address
String address = AndroidUtils.getBluetoothAddress(appContext, adapter);
if (address.isEmpty()) return null;
// No truncation necessary because COMMIT_LENGTH = 16
UUID uuid = UUID.nameUUIDFromBytes(commitment);
if (LOG.isLoggable(INFO)) LOG.info("Key agreement UUID " + uuid);
// Bind a server socket for receiving invitation connections
BluetoothServerSocket ss;
try {
ss = adapter.listenUsingInsecureRfcommWithServiceRecord(
"RFCOMM", uuid);
} catch (IOException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return null;
}
BdfList descriptor = new BdfList();
descriptor.add(TRANSPORT_ID_BLUETOOTH);
descriptor.add(StringUtils.macToBytes(address));
return new BluetoothKeyAgreementListener(descriptor, ss);
}
DroidtoothPlugin.java 文件源码
项目:Nird2
阅读 39
收藏 0
点赞 0
评论 0
@Override
public KeyAgreementListener createKeyAgreementListener(byte[] commitment) {
if (!isRunning()) return null;
// There's no point listening if we can't discover our own address
String address = AndroidUtils.getBluetoothAddress(appContext, adapter);
if (address.isEmpty()) return null;
// No truncation necessary because COMMIT_LENGTH = 16
UUID uuid = UUID.nameUUIDFromBytes(commitment);
if (LOG.isLoggable(INFO)) LOG.info("Key agreement UUID " + uuid);
// Bind a server socket for receiving invitation connections
BluetoothServerSocket ss;
try {
ss = adapter.listenUsingInsecureRfcommWithServiceRecord(
"RFCOMM", uuid);
} catch (IOException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
return null;
}
BdfList descriptor = new BdfList();
descriptor.add(TRANSPORT_ID_BLUETOOTH);
descriptor.add(StringUtils.macToBytes(address));
return new BluetoothKeyAgreementListener(descriptor, ss);
}
BluetoothChatService.java 文件源码
项目:SecretTalk
阅读 34
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
mState = STATE_LISTEN;
}
SerialThreadService.java 文件源码
项目:grblcontroller
阅读 36
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException | NullPointerException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
mState = STATE_LISTEN;
}
ServerThread.java 文件源码
项目:LittleBitLouder
阅读 40
收藏 0
点赞 0
评论 0
public ServerThread(BluetoothAdapter adapter, Handler handler, boolean secure) {
this.handler = handler;
BluetoothServerSocket tempSocket = null;
try {
if (secure)
tempSocket = adapter.listenUsingRfcommWithServiceRecord(Constants.NAME, UUID.fromString(Constants.UUID_STRING));
else
tempSocket = adapter.listenUsingInsecureRfcommWithServiceRecord(Constants.NAME, UUID.fromString(Constants.UUID_STRING));
} catch (IOException ioe) {
Log.e(TAG, ioe.toString());
}
serverSocket = tempSocket;
}
BluetoothChatService.java 文件源码
项目:buildAPKsSamples
阅读 48
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure":"Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
BluetoothManager.java 文件源码
项目:libcommon
阅读 29
收藏 0
点赞 0
评论 0
/**
* コンストラクタ
* @param secure セキュア接続を待機するならtrue
*/
public ListeningThread(final boolean secure) {
super("ListeningThread:" + mName);
// Create a new listening server socket
BluetoothServerSocket tmp = null;
try {
if (secure) {
// セキュアな接続を行うためのBluetoothServerSocketを生成
tmp = mAdapter.listenUsingRfcommWithServiceRecord(mName, mSecureProfileUUID);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(mName, mInSecureProfileUUID);
}
} catch (final IOException e) {
Log.w(TAG, e);
}
mmServerSocket = tmp;
}
BluetoothChatService.java 文件源码
项目:pet
阅读 45
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure":"Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
}
mmServerSocket = tmp;
}
BlueService.java 文件源码
项目:BlueDroid
阅读 37
收藏 0
点赞 0
评论 0
public AcceptThread(boolean isAndroid, boolean secure) {
BluetoothServerSocket tmp = null;
try {
if (secure) {
if (isAndroid)
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, UUID_ANDROID_DEVICE);
else
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, UUID_OTHER_DEVICE);
} else {
if (isAndroid)
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_SECURE, UUID_ANDROID_DEVICE);
else
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_SECURE, UUID_OTHER_DEVICE);
}
} catch (IOException e) {
e.printStackTrace();
}
mmServerSocket = tmp;
}
BTAdt.java 文件源码
项目:AndroidSDK
阅读 31
收藏 0
点赞 0
评论 0
public void setNewServerSocket()
{
BluetoothServerSocket tmp = null;
try
{
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord( NAME_PEN, NeoOne_UUID );
//tmp = mAdapter.listenUsingRfcommWithServiceRecord( NAME_PEN, NeoOne_UUID );
NLog.d( "[BTAdt] ListenThread new BT ServerSocket assigned" );
}
catch ( IOException e )
{
NLog.e( "[BTAdt] ListenThread new BT ServerSocket assign fail", e );
}
mmServerSocket = tmp;
}
BluetoothControlerImpl.java 文件源码
项目:Run-With-You
阅读 37
收藏 0
点赞 0
评论 0
AcceptThread(boolean secure, int timeout) {
BluetoothServerSocket tmp = null;
this.mSecure = secure;
this.mTimeout = timeout;
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + getSocketType(secure) + "listen() failed", e);
}
mmServerSocket = tmp;
}
AcceptThread.java 文件源码
项目:TastySnake
阅读 35
收藏 0
点赞 0
评论 0
/**
* Initialize the thread.
*
* @param adapter The bluetooth adapter
*/
public AcceptThread(BluetoothAdapter adapter,
OnSocketEstablishedListener onSocketEstablishedListener,
OnStateChangedListener stateListener,
OnErrorListener errorListener) {
super(TAG);
this.onSocketEstablishedListener = onSocketEstablishedListener;
this.stateListener = stateListener;
this.errorListener = errorListener;
BluetoothServerSocket tmp = null;
try {
tmp = adapter.listenUsingRfcommWithServiceRecord(
Config.BLUETOOTH_SERVICE_NAME,
UUID.fromString(Config.BLUETOOTH_UUID_STR));
} catch (IOException e) {
Log.e(TAG, "Error:", e);
errorListener.onError(OnErrorListener.ERR_SOCKET_CREATE, e);
}
serverSocket = tmp;
}
BluetoothChatService.java 文件源码
项目:react-native-bluetooth-io
阅读 29
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
BluetoothManager.java 文件源码
项目:IOT-DB410c-Course-3
阅读 42
收藏 0
点赞 0
评论 0
/**********************************************************************
* Name: AcceptThread
* Description: Constructor for the class. Attempts to instantiate the
* ServerSocket based on the passed parameter
*
* @param secure boolean indicating the type of connection to
* listen for
**********************************************************************/
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Create a new listening server socket
try {
if (secure)
tmp = btAdapter.listenUsingRfcommWithServiceRecord(
NAME_SECURE, UUID_SECURE);
else
tmp = btAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, UUID_INSECURE);
} catch (IOException e) {
e.printStackTrace();
}
mmServerSocket = tmp;
}
AcceptThread.java 文件源码
项目:gesture-framework
阅读 31
收藏 0
点赞 0
评论 0
public AcceptThread(BluetoothChannel channel, BluetoothAdapter bluetoothAdapter) {
this.mChannel = channel;
bluetoothAdapter.cancelDiscovery();
BluetoothServerSocket tmp = null;
try {
tmp = bluetoothAdapter.listenUsingRfcommWithServiceRecord("SysplaceApp",
BluetoothChannel.MY_UUID);
} catch (IOException e) {
Log.e(TAG, "Could not open Server Socket");
}
mmServerSocket = tmp;
}
BluetoothSerialService.java 文件源码
项目:blink
阅读 33
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure":"Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
BluetoothSerialService.java 文件源码
项目:blink
阅读 31
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure":"Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
BluetoothChatService.java 文件源码
项目:phonepick
阅读 43
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
//mSocketType = secure ? "Secure" : "Insecure";
mSocketType = "Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
BluetoothServerTask.java 文件源码
项目:secureit
阅读 39
收藏 0
点赞 0
评论 0
public BluetoothServerTask(Context context) throws NoBluetoothException {
Log.i("BluetoothServerTask", "Created");
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
// Device does not support Bluetooth
throw new NoBluetoothException();
}
this.context = context;
Log.i("BluetoothServerTask", "Got adapter");
// Use a temporary object that is later assigned to mmServerSocket,
// because mmServerSocket is final
BluetoothServerSocket tmp = null;
try {
// MY_UUID is the app's UUID string, also used by the client code
tmp = mBluetoothAdapter.listenUsingInsecureRfcommWithServiceRecord(
Remote.BLUETOOTH_NAME,
Remote.BLUETOOTH_UUID);
Log.i("BluetoothServerTask", "Created insecure server socket");
} catch (IOException e) {
throw new NoBluetoothException();
}
mmServerSocket = tmp;
}
BluetoothChatService.java 文件源码
项目:honki_android
阅读 32
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
BluetoothSerialService.java 文件源码
项目:DemoArduinoAndroidCordovaBT
阅读 31
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure":"Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
BluetoothSerialService.java 文件源码
项目:DemoArduinoAndroidCordovaBT
阅读 33
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure":"Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
BluetoothChatService.java 文件源码
项目:pga309-blutooth-android-tensometer
阅读 54
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
BluetoothServerSocket tmp = null;
mSocketType = secure ? "Secure" : "Insecure";
// Create a new listening server socket
try {
if (secure) {
tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
MY_UUID_SECURE);
} else {
tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
NAME_INSECURE, MY_UUID_INSECURE);
}
} catch (IOException e) {
Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
}
mmServerSocket = tmp;
}
BluetoothServerService.java 文件源码
项目:tilt-game-android
阅读 30
收藏 0
点赞 0
评论 0
public AcceptThread(boolean secure) {
_socketType = secure ? "Secure" : "Insecure";
// Create a new listening server socket
BluetoothServerSocket serverSocket = null;
try {
if (secure) {
if (_debug) Log.d(TAG, "AcceptThread: started listening secure, uuid = " + _secureUuid + ", spd name = " + _secureSPDName);
serverSocket = _adapter.listenUsingRfcommWithServiceRecord(_secureSPDName, _secureUuid);
} else {
if (_debug) Log.d(TAG, "AcceptThread: started listening insecure, uuid = " + _insecureUuid + ", spd name = " + _insecureSPDName);
serverSocket = _adapter.listenUsingInsecureRfcommWithServiceRecord(_insecureSPDName, _insecureUuid);
}
} catch (IOException e) {
Log.e(TAG, "AcceptThread: listen failed");
e.printStackTrace();
}
_serverSocket = serverSocket;
_isListening = true;
}