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


Java BluetoothGattService类代码示例

本文整理汇总了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);
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:26,代码来源:BluetoothSam42.java

示例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!");
		}
	}
}
 
开发者ID:TheGenuine,项目名称:BeaconScanner,代码行数:21,代码来源:HRPService.java

示例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;
	}

}
 
开发者ID:TheGenuine,项目名称:BeaconScanner,代码行数:27,代码来源:HRPService.java

示例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);
}
 
开发者ID:TheGenuine,项目名称:BeaconScanner,代码行数:19,代码来源:HRPService.java

示例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);
	}
}
 
开发者ID:TheGenuine,项目名称:BeaconScanner,代码行数:22,代码来源:HRPService.java

示例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;
}
 
开发者ID:xpg,项目名称:GizwitsBLE,代码行数:12,代码来源:SamsungBle.java

示例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);
	}
}
 
开发者ID:xpg,项目名称:GizwitsBLE,代码行数:11,代码来源:SamsungBle.java

示例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);
          }
      }

  }
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:29,代码来源:BluetoothSam42.java

示例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);
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:10,代码来源:BluetoothSam42.java

示例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;
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:13,代码来源:BluetoothSam42.java

示例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;
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:14,代码来源:BluetoothSam42.java

示例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;
        }
    }
}
 
开发者ID:hfeeki,项目名称:bluetooth,代码行数:15,代码来源:BluetoothSam42.java

示例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;
}
 
开发者ID:TheGenuine,项目名称:BeaconScanner,代码行数:16,代码来源:MainActivity.java

示例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);
}
 
开发者ID:TheGenuine,项目名称:BeaconScanner,代码行数:16,代码来源:HRPService.java

示例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);
}
 
开发者ID:TheGenuine,项目名称:BeaconScanner,代码行数:15,代码来源:HRPService.java


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