當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。