本文整理汇总了Java中com.samsung.android.sdk.bt.gatt.BluetoothGattService类的典型用法代码示例。如果您正苦于以下问题:Java BluetoothGattService类的具体用法?Java BluetoothGattService怎么用?Java BluetoothGattService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BluetoothGattService类属于com.samsung.android.sdk.bt.gatt包,在下文中一共展示了BluetoothGattService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDeviceAllData
import com.samsung.android.sdk.bt.gatt.BluetoothGattService; //导入依赖的package包/类
@Override
public void getDeviceAllData(JSONArray json, CallbackContext callbackContext) {
Log.i(TAG, "getDeviceAllData");
if (!isInitialized(callbackContext)) {
return;
}
String deviceID = Tools.getData(json, Tools.DEVICE_ID);
if (deviceID == null) {
Tools.sendErrorMsg(callbackContext);
return;
}
BluetoothDevice device = bluetoothAdapter.getRemoteDevice(deviceID);
if (!isConnected(device)) {
Tools.sendErrorMsg(callbackContext);
return;
}
if (mapDeviceServices == null) {
mapDeviceServices = new HashMap<String, List<BluetoothGattService>>();
}
if (mapGetDeviceAllDataCallBack == null) {
mapGetDeviceAllDataCallBack = new HashMap<String, CallbackContext>();
}
mapGetDeviceAllDataCallBack.put(deviceID, callbackContext);
bluetoothGatt.discoverServices(device);
}
示例2: DummyReadForSecLevelCheck
import com.samsung.android.sdk.bt.gatt.BluetoothGattService; //导入依赖的package包/类
public void DummyReadForSecLevelCheck(BluetoothDevice device) {
boolean result = false;
if (mBluetoothGatt != null && device != null) {
BluetoothGattService disService = mBluetoothGatt.getService(device, DIS_UUID);
if (disService == null) {
showMessage("Dis service not found!");
return;
}
BluetoothGattCharacteristic firmwareIdCharc = disService.getCharacteristic(FIRMWARE_REVISON_UUID);
if (firmwareIdCharc == null) {
showMessage("firmware revison charateristic not found!");
return;
}
result = mBluetoothGatt.readCharacteristic(firmwareIdCharc);
if (result == false) {
showMessage("firmware revison reading is failed!");
}
}
}
示例3: enableHRNotification
import com.samsung.android.sdk.bt.gatt.BluetoothGattService; //导入依赖的package包/类
public void enableHRNotification(BluetoothDevice device) {
boolean result = false;
Log.i(TAG, "enableHRNotification ");
isNoti = true;
BluetoothGattService mHRP = mBluetoothGatt.getService(device, HRP_SERVICE);
if (mHRP == null) {
Log.e(TAG, "HRP service not found!");
return;
}
BluetoothGattCharacteristic mHRMcharac = mHRP.getCharacteristic(HEART_RATE_MEASUREMENT_CHARAC);
if (mHRMcharac == null) {
Log.e(TAG, "HEART RATE MEASUREMENT charateristic not found!");
return;
}
BluetoothGattDescriptor mHRMccc = mHRMcharac.getDescriptor(CCC);
if (mHRMccc == null) {
Log.e(TAG, "CCC for HEART RATE MEASUREMENT charateristic not found!");
return;
}
result = mBluetoothGatt.readDescriptor(mHRMccc);
if (result == false) {
Log.e(TAG, "readDescriptor() is failed");
return;
}
}
示例4: ResetEnergyExpended
import com.samsung.android.sdk.bt.gatt.BluetoothGattService; //导入依赖的package包/类
public void ResetEnergyExpended(BluetoothDevice device) {
Log.i(TAG, "ResetEnergyExpended ");
BluetoothGattService mHRP = mBluetoothGatt.getService(device, HRP_SERVICE);
if (mHRP == null) {
Log.e(TAG, "HRP service not found!");
return;
}
BluetoothGattCharacteristic mHRCPcharac = mHRP.getCharacteristic(HeartRate_ControlPoint);
if (mHRCPcharac == null) {
Log.e(TAG, "HEART RATE Copntrol Point charateristic not found!");
return;
}
byte[] value = new byte[1];
value[0] = (byte) RESET_ENERGY_EXPANDED;
mHRCPcharac.setValue(value);
mBluetoothGatt.writeCharacteristic(mHRCPcharac);
}
示例5: disableNotification
import com.samsung.android.sdk.bt.gatt.BluetoothGattService; //导入依赖的package包/类
public void disableNotification(BluetoothDevice device) {
BluetoothGattService mHRP = mBluetoothGatt.getService(device, HRP_SERVICE);
if (mHRP == null) {
Log.e(TAG, "HRP service not found!");
return;
}
BluetoothGattCharacteristic mHRMcharac = mHRP.getCharacteristic(HEART_RATE_MEASUREMENT_CHARAC);
if (mHRMcharac == null) {
Log.e(TAG, "HEART RATE MEASUREMENT charateristic not found!");
return;
}
BluetoothGattDescriptor mHRMccc = mHRMcharac.getDescriptor(CCC);
if (mHRMccc == null) {
Log.e(TAG, "CCC for HEART RATE MEASUREMENT charateristic not found!");
return;
}
byte[] value = mHRMccc.getValue();
if (value != null && value[0] == BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE[0]) {
enableNotification(false, mHRMcharac);
}
}
示例6: getServices
import com.samsung.android.sdk.bt.gatt.BluetoothGattService; //导入依赖的package包/类
@Override
public ArrayList<BleGattService> getServices(String address) {
ArrayList<BleGattService> list = new ArrayList<BleGattService>();
BluetoothDevice device = mBtAdapter.getRemoteDevice(address);
List<BluetoothGattService> services = mBluetoothGatt
.getServices(device);
for (BluetoothGattService s : services) {
list.add(new BleGattService(s));
}
return list;
}
示例7: getService
import com.samsung.android.sdk.bt.gatt.BluetoothGattService; //导入依赖的package包/类
@Override
public BleGattService getService(String address, UUID uuid) {
BluetoothGattService service = mBluetoothGatt.getService(
mBtAdapter.getRemoteDevice(address), uuid);
if (service == null) {
return null;
} else {
return new BleGattService(service);
}
}
示例8: addServices
import com.samsung.android.sdk.bt.gatt.BluetoothGattService; //导入依赖的package包/类
@Override
public void addServices(JSONArray json, CallbackContext callbackContext) {
Log.i(TAG, "addService");
JSONObject jsonServices = Tools.getObjectFromArray(json);
JSONArray jsonArray = Tools.getArray(json, Tools.SERVICES);
if(mapRemoteServices == null){
mapRemoteServices = new HashMap<String, BluetoothGattService>();
}
addServiceCallBack = callbackContext;
serviceNumber = jsonServices.length();
for (int i = 0; i < jsonServices.length(); i++) {
String serviceIndex = Tools.getData(jsonArray, Tools.UINQUE_ID);
String serviceType = Tools.getData(jsonArray, Tools.SERVICE_TYPE);
String strServiceUUID = Tools.getData(jsonArray, Tools.SERVICE_UUID);
String[] args = new String[] { serviceIndex, serviceType, strServiceUUID };
if (!isNullOrEmpty(args, callbackContext)) {
return;
}
UUID serviceUUID = UUID.fromString(strServiceUUID);
MutableBluetoothGattService bluetoothGattService = createService(serviceUUID, serviceType);
JSONArray jsonCharacteristics = Tools.getArray(jsonArray, Tools.CHARACTERISTICS);
addCharacteristics(bluetoothGattService, jsonCharacteristics, callbackContext);
if (bluetoothGattServer.addService(bluetoothGattService)) {
mapRemoteServices.put(serviceIndex, bluetoothGattService);
}
}
}
示例9: createService
import com.samsung.android.sdk.bt.gatt.BluetoothGattService; //导入依赖的package包/类
private MutableBluetoothGattService createService(UUID uuid, String serviceType) {
int type = -1;
if ("0".equals(serviceType)) {
type = BluetoothGattService.SERVICE_TYPE_PRIMARY;
} else {
type = BluetoothGattService.SERVICE_TYPE_SECONDARY;
}
return new MutableBluetoothGattService(uuid, type);
}
示例10: getDeviceID
import com.samsung.android.sdk.bt.gatt.BluetoothGattService; //导入依赖的package包/类
private String getDeviceID(BluetoothGattService service) {
String deviceID = "";
Iterator<Entry<String, List<BluetoothGattService>>> it = mapDeviceServices.entrySet().iterator();
while (it.hasNext()) {
Entry<String, List<BluetoothGattService>> bluetoothEntry = it.next();
if (bluetoothEntry.getValue().contains(service)) {
deviceID = bluetoothEntry.getKey();
break;
}
}
return deviceID;
}
示例11: getServiceIndex
import com.samsung.android.sdk.bt.gatt.BluetoothGattService; //导入依赖的package包/类
private String getServiceIndex(BluetoothGattService service) {
String serviceIndex = "";
Iterator<Entry<String, List<BluetoothGattService>>> it = mapDeviceServices.entrySet().iterator();
while (it.hasNext()) {
List<BluetoothGattService> bluetoothGattServices = it.next().getValue();
int index = bluetoothGattServices.indexOf(service);
if (index != -1) {
serviceIndex = String.valueOf(index);
break;
}
}
return serviceIndex;
}
示例12: onServiceAdded
import com.samsung.android.sdk.bt.gatt.BluetoothGattService; //导入依赖的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;
}
}
}
示例13: getView
import com.samsung.android.sdk.bt.gatt.BluetoothGattService; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View vg;
if (convertView != null) {
vg = (View) convertView;
} else {
vg = (View) inflater.inflate(android.R.layout.simple_list_item_1, null);
}
BluetoothGattService btService = mList.get(position);
((TextView) vg).setText(btService.getUuid().toString());
return vg;
}
示例14: getBodySensorLoc
import com.samsung.android.sdk.bt.gatt.BluetoothGattService; //导入依赖的package包/类
public void getBodySensorLoc(BluetoothDevice device) {
Log.i(TAG, "getBodySensorLoc");
BluetoothGattService mHRP = mBluetoothGatt.getService(device, HRP_SERVICE);
if (mHRP == null) {
Log.e(TAG, "getBodySensorLoc: mHRP = null");
return;
}
BluetoothGattCharacteristic mBSLcharac = mHRP.getCharacteristic(BODY_SENSOR_LOCATION);
if (mBSLcharac == null) {
Log.e(TAG, "getBodySensorLoc: mBSLcharac = null");
return;
}
mBluetoothGatt.readCharacteristic(mBSLcharac);
}
示例15: read_uuid_read_25
import com.samsung.android.sdk.bt.gatt.BluetoothGattService; //导入依赖的package包/类
public void read_uuid_read_25(BluetoothDevice device) {
Log.i(TAG, "read 0x2A25 uuid charachteristic");
BluetoothGattService mDI = mBluetoothGatt.getService(device, DEVICE_INFORMATION);
if (mDI == null) {
Log.e(TAG, "Device Information Service Not Found!!!");
return;
}
BluetoothGattCharacteristic mSNS = mDI.getCharacteristic(SERIAL_NUMBER_STRING);
if (mSNS == null) {
Log.e(TAG, "Serial Number String Characteristic Not Found!!!");
return;
}
mBluetoothGatt.readCharacteristic(mSNS);
}