当前位置: 首页>>代码示例>>Java>>正文


Java BluetoothGatt类代码示例

本文整理汇总了Java中com.samsung.android.sdk.bt.gatt.BluetoothGatt的典型用法代码示例。如果您正苦于以下问题:Java BluetoothGatt类的具体用法?Java BluetoothGatt怎么用?Java BluetoothGatt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BluetoothGatt类属于com.samsung.android.sdk.bt.gatt包,在下文中一共展示了BluetoothGatt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onConnectionStateChange

import com.samsung.android.sdk.bt.gatt.BluetoothGatt; //导入依赖的package包/类
@Override
public void onConnectionStateChange(BluetoothDevice device, int status,
		int newState) {
	if (mBluetoothGatt == null) {
		return;
	}

	if (status != BluetoothGatt.GATT_SUCCESS) {
		disconnect(device.getAddress());
		mService.bleGattDisConnected(device.getAddress());
		return;
	}

	if (newState == BluetoothProfile.STATE_CONNECTED) {
		mService.bleGattConnected(device);
		mService.addBleRequest(new BleRequest(
				RequestType.DISCOVER_SERVICE, device.getAddress()));
	} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
		mService.bleGattDisConnected(device.getAddress());
		disconnect(device.getAddress());
	}
}
 
开发者ID:xpg,项目名称:GizwitsBLE,代码行数:23,代码来源:SamsungBle.java

示例2: onCharacteristicRead

import com.samsung.android.sdk.bt.gatt.BluetoothGatt; //导入依赖的package包/类
@Override
public void onCharacteristicRead(BluetoothGattCharacteristic characteristic, int status) {
    Log.i(TAG, "onCharacteristicRead");
    super.onCharacteristicRead(characteristic, status);
    String deviceID = getDeviceID(characteristic.getService());
    CallbackContext callbackContext = null;
    if (mapReadValueCallBack != null) {
        callbackContext = mapReadValueCallBack.get(characteristic);
    }
    if (callbackContext != null) {
        if (status == BluetoothGatt.GATT_SUCCESS) {
            JSONObject jsonObject = new JSONObject();
            Tools.addProperty(jsonObject, Tools.DEVICE_ID, deviceID);
            Tools.addProperty(jsonObject, Tools.VALUE, Tools.encodeBase64(characteristic.getValue()));
            Tools.addProperty(jsonObject, Tools.DATE, Tools.getDateString());
            callbackContext.success(jsonObject);
        } else {
            Tools.sendErrorMsg(callbackContext);
        }
        mapReadValueCallBack.remove(deviceID);
    }
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:23,代码来源:BluetoothSam42.java

示例3: onReadRemoteRssi

import com.samsung.android.sdk.bt.gatt.BluetoothGatt; //导入依赖的package包/类
@Override
public void onReadRemoteRssi(BluetoothDevice device, int rssi, int status) {
    super.onReadRemoteRssi(device, rssi, status);
    Log.i(TAG, "onReadRemoteRssi");
    String deviceID = device.getAddress();
    CallbackContext callbackContext = null;
    if (mapGetRSSICallBack != null) {
        callbackContext = mapGetRSSICallBack.get(deviceID);
    }
    if (callbackContext != null) {
        if (status == BluetoothGatt.GATT_SUCCESS) {
            JSONObject jsonObject = new JSONObject();
            Tools.addProperty(jsonObject, Tools.DEVICE_ID, deviceID);
            Tools.addProperty(jsonObject, Tools.RSSI, Integer.toString(rssi));
            callbackContext.success(jsonObject);
        } else {
            Tools.sendErrorMsg(callbackContext);
        }
        mapGetRSSICallBack.remove(deviceID);
    }
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:22,代码来源:BluetoothSam42.java

示例4: onDescriptorRead

import com.samsung.android.sdk.bt.gatt.BluetoothGatt; //导入依赖的package包/类
@Override
public void onDescriptorRead(BluetoothGattDescriptor descriptor, int status) {
    super.onDescriptorRead(descriptor, status);
    Log.i(TAG, "onDescriptorRead");
    String deviceID = getDeviceID(descriptor.getCharacteristic().getService());
    CallbackContext callbackContext = mapReadValueCallBack.get(deviceID);
    if (callbackContext != null) {
        if (status == BluetoothGatt.GATT_SUCCESS) {
            JSONObject jsonObject = new JSONObject();
            Tools.addProperty(jsonObject, Tools.DEVICE_ID, deviceID);
            Tools.addProperty(jsonObject, Tools.VALUE, Tools.encodeBase64(descriptor.getValue()));
            Tools.addProperty(jsonObject, Tools.DATE, Tools.getDateString());
            callbackContext.success(jsonObject);
        } else {
            Tools.sendErrorMsg(callbackContext);
        }
        mapReadValueCallBack.remove(deviceID);
    }
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:20,代码来源:BluetoothSam42.java

示例5: onDescriptorWrite

import com.samsung.android.sdk.bt.gatt.BluetoothGatt; //导入依赖的package包/类
@Override
public void onDescriptorWrite(BluetoothGattDescriptor descriptor, int status) {
    super.onDescriptorWrite(descriptor, status);
    Log.i(TAG, "onDescriptorWrite");
    String deviceID = getDeviceID(descriptor.getCharacteristic().getService());
    CallbackContext writeValueCallbackContext = null;
    if (mapWriteValueCallBack != null) {
        writeValueCallbackContext = mapWriteValueCallBack.get(descriptor);
    }
    if (writeValueCallbackContext != null) {
        if (status == BluetoothGatt.GATT_SUCCESS) {
            Tools.sendSuccessMsg(writeValueCallbackContext);
        } else {
            Tools.sendErrorMsg(writeValueCallbackContext);
        }
        mapWriteValueCallBack.remove(deviceID);
    }
    
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:20,代码来源:BluetoothSam42.java

示例6: resultCodeToString

import com.samsung.android.sdk.bt.gatt.BluetoothGatt; //导入依赖的package包/类
private String resultCodeToString(int paramInt) {
	switch (paramInt) {
		case BluetoothGatt.GATT_SUCCESS:
			return "SUCCESS";
		case BluetoothGatt.GATT_INVALID_ATTRIBUTE_LENGTH:
			return "GATT_INVALID_ATTRIBUTE_LENGTH";
		case BluetoothGatt.GATT_WRITE_NOT_PERMITTED:
			return "GATT_WRITE_NOT_PERMITTED";
		case BluetoothGatt.GATT_ALREADY_OPEN:
			return "GATT_ALREADY_OPEN";
		case BluetoothGatt.GATT_ERROR:
			return "GATT_ERROR";
		case BluetoothGatt.GATT_INVALID_OFFSET:
			return "GATT_INVALID_OFFSET";
		case BluetoothGatt.GATT_INTERNAL_ERROR:
			return "GATT_INTERNAL_ERROR";
	default:
		return "UNKNOWN";
	}
}
 
开发者ID:TheGenuine,项目名称:BeaconScanner,代码行数:21,代码来源:HRPService.java

示例7: onServicesDiscovered

import com.samsung.android.sdk.bt.gatt.BluetoothGatt; //导入依赖的package包/类
@Override
public void onServicesDiscovered(BluetoothDevice device, int status) {
	String address = device.getAddress();
	if (status != BluetoothGatt.GATT_SUCCESS) {
		disconnect(address);
		mService.bleGattDisConnected(address);
		mService.requestProcessed(address,
				RequestType.DISCOVER_SERVICE, false);
		return;
	}
	mService.bleServiceDiscovered(device.getAddress());
}
 
开发者ID:xpg,项目名称:GizwitsBLE,代码行数:13,代码来源:SamsungBle.java

示例8: onCharacteristicRead

import com.samsung.android.sdk.bt.gatt.BluetoothGatt; //导入依赖的package包/类
@Override
public void onCharacteristicRead(
		BluetoothGattCharacteristic characteristic, int status) {
	BleRequest request = mService.getCurrentRequest();
	String address = request.address;
	if (status != BluetoothGatt.GATT_SUCCESS) {
		mService.requestProcessed(address,
				RequestType.READ_CHARACTERISTIC, false);
		return;
	}
	mService.bleCharacteristicRead(address, characteristic.getUuid()
			.toString(), status, characteristic.getValue());
}
 
开发者ID:xpg,项目名称:GizwitsBLE,代码行数:14,代码来源:SamsungBle.java

示例9: onCharacteristicWrite

import com.samsung.android.sdk.bt.gatt.BluetoothGatt; //导入依赖的package包/类
@Override
public void onCharacteristicWrite(
		BluetoothGattCharacteristic characteristic, int status) {
	BleRequest request = mService.getCurrentRequest();
	String address = request.address;
	if (status != BluetoothGatt.GATT_SUCCESS) {
		mService.requestProcessed(address,
				RequestType.WRITE_CHARACTERISTIC, false);
		return;
	}
	mService.bleCharacteristicWrite(address, characteristic.getUuid()
			.toString(), status);
}
 
开发者ID:xpg,项目名称:GizwitsBLE,代码行数:14,代码来源:SamsungBle.java

示例10: onDescriptorWrite

import com.samsung.android.sdk.bt.gatt.BluetoothGatt; //导入依赖的package包/类
@Override
public void onDescriptorWrite(BluetoothGattDescriptor descriptor,
		int status) {
	BleRequest request = mService.getCurrentRequest();
	String address = request.address;
	if (request.type == RequestType.CHARACTERISTIC_NOTIFICATION
			|| request.type == RequestType.CHARACTERISTIC_INDICATION
			|| request.type == RequestType.CHARACTERISTIC_STOP_NOTIFICATION) {
		if (status != BluetoothGatt.GATT_SUCCESS) {
			mService.requestProcessed(address, request.type, false);
			return;
		}

		if (request.type == RequestType.CHARACTERISTIC_NOTIFICATION) {
			mService.bleCharacteristicNotification(address, descriptor
					.getCharacteristic().getUuid().toString(), true,
					status);
		} else if (request.type == RequestType.CHARACTERISTIC_INDICATION) {
			mService.bleCharacteristicIndication(address, descriptor
					.getCharacteristic().getUuid().toString(), status);
		} else {
			mService.bleCharacteristicNotification(address, descriptor
					.getCharacteristic().getUuid().toString(), false,
					status);
		}
		return;
	}

}
 
开发者ID:xpg,项目名称:GizwitsBLE,代码行数:30,代码来源:SamsungBle.java

示例11: onCharacteristicWrite

import com.samsung.android.sdk.bt.gatt.BluetoothGatt; //导入依赖的package包/类
@Override
public void onCharacteristicWrite(BluetoothGattCharacteristic characteristic, int status) {
    super.onCharacteristicWrite(characteristic, status);
    Log.i(TAG, "onCharacteristicWrite");
    String deviceID = getDeviceID(characteristic.getService());
    CallbackContext callbackContext = mapWriteValueCallBack.get(characteristic);
    if (callbackContext != null) {
        if (status == BluetoothGatt.GATT_SUCCESS) {
            Tools.sendSuccessMsg(callbackContext);
        } else {
            Tools.sendErrorMsg(callbackContext);
        }
        mapWriteValueCallBack.remove(deviceID);
    }
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:16,代码来源:BluetoothSam42.java

示例12: onServiceAdded

import com.samsung.android.sdk.bt.gatt.BluetoothGatt; //导入依赖的package包/类
@Override
public void onServiceAdded(int status, BluetoothGattService bluetoothGattService) {
    super.onServiceAdded(status, bluetoothGattService);
    Log.i(TAG, "onServiceAdded");
    if (status == BluetoothGatt.GATT_SUCCESS) {
        addedServiceNumber++;
        if (addedServiceNumber == serviceNumber) {
            if (addServiceCallBack != null) {
                Tools.sendSuccessMsg(addServiceCallBack);
            }
            addedServiceNumber = 0;
        }
    }
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:15,代码来源:BluetoothSam42.java

示例13: onServiceConnected

import com.samsung.android.sdk.bt.gatt.BluetoothGatt; //导入依赖的package包/类
@SuppressLint("NewApi")
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
	if (profile == BluetoothGattAdapter.GATT) {
		mBluetoothGatt = (BluetoothGatt) proxy;
		mBluetoothGatt.registerApp(mGattCallbacks);
	}
}
 
开发者ID:TheGenuine,项目名称:BeaconScanner,代码行数:9,代码来源:HRPService.java

示例14: onServiceConnected

import com.samsung.android.sdk.bt.gatt.BluetoothGatt; //导入依赖的package包/类
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
	mBluetoothGatt = (BluetoothGatt) proxy;
	mBluetoothGatt.registerApp(mGattCallbacks);
}
 
开发者ID:xpg,项目名称:GizwitsBLE,代码行数:6,代码来源:SamsungBle.java

示例15: onConnectionStateChange

import com.samsung.android.sdk.bt.gatt.BluetoothGatt; //导入依赖的package包/类
@Override
public void onConnectionStateChange(BluetoothDevice device, int status, int newState) {
    super.onConnectionStateChange(device, status, newState);
    Log.i(TAG, "onConnectionStateChange");
    String deviceID = device.getAddress();
    CallbackContext connectCallbackContext = null;
    CallbackContext disConnectCallbackContext = null;
    JSONObject jsonObject = new JSONObject();
    if (mapConnectCallBack != null) {
        connectCallbackContext = mapConnectCallBack.get(deviceID);
    }
    if (mapDisconnectCallBack != null) {
        disConnectCallbackContext = mapDisconnectCallBack.get(deviceID);
    }
    if (disConnectCallbackContext == null && mapAddListenerCallBack != null) {
        disConnectCallbackContext = mapAddListenerCallBack.get(Tools.DISCONNECT);
    }
    if (connectCallbackContext != null) {
        if (status == BluetoothGatt.GATT_SUCCESS && newState == BluetoothProfile.STATE_CONNECTED) {
            Tools.addProperty(jsonObject, Tools.DEVICE_ID, deviceID);
            Tools.addProperty(jsonObject, Tools.MES, Tools.SUCCESS);
            connectCallbackContext.success(jsonObject);
        } else {
            Tools.sendErrorMsg(connectCallbackContext);
        }
        mapConnectCallBack.remove(deviceID);
        return;
    }
    if (disConnectCallbackContext != null) {
    	Log.i(TAG, "device: "+deviceID+" disconnect!");
        if (newState == BluetoothProfile.STATE_DISCONNECTED && status == BluetoothGatt.GATT_SUCCESS) {
            Tools.addProperty(jsonObject, Tools.DEVICE_ID, deviceID);
            Tools.addProperty(jsonObject, Tools.MES, Tools.SUCCESS);
            PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, jsonObject);
            pluginResult.setKeepCallback(true);
            disConnectCallbackContext.sendPluginResult(pluginResult);
        } else {
            Tools.sendErrorMsg(disConnectCallbackContext);
        }
        mapDisconnectCallBack.remove(deviceID);
    }
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:43,代码来源:BluetoothSam42.java


注:本文中的com.samsung.android.sdk.bt.gatt.BluetoothGatt类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。