Android Open Source - BLEService B T Characteristic Profile

From Project

Back to project page BLEService.


The source code is released under:

Copyright (c) 2014, Ratio LLC. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...

If you think the Android project BLEService listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ratio.deviceService;
/*from  ww w . j  a  v a2s  .  co m*/
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import com.ratio.util.UUIDUtils;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattService;
import android.os.Parcel;
import android.os.Parcelable;

 * external description of a device profile, so once we query the device services and characteristics
 * we can send it back from the service to the activity in a bundle, which can be received by the BroadcastReceiver
 * @author mreynolds

public class BTCharacteristicProfile implements Parcelable {
  protected BluetoothGattCharacteristic mCharacteristic;
  public BTCharacteristicProfile(BluetoothGattCharacteristic characteristic) {
    mCharacteristic = characteristic;
  public BTCharacteristicProfile(UUID uuid, int properties, int permissions) {
    mCharacteristic = new BluetoothGattCharacteristic(uuid, properties, permissions);
  public BluetoothGattCharacteristic getCharacteristic() {
    return mCharacteristic;
  public static List<BluetoothGattCharacteristic> getCharacteristicList(List<BTCharacteristicProfile> characteristicProfileList) {
    ArrayList<BluetoothGattCharacteristic> charList = new ArrayList<BluetoothGattCharacteristic>(characteristicProfileList.size());
    for (BTCharacteristicProfile profile : characteristicProfileList) {
    return charList;
  public int describeContents() {
    return 0;
  public void writeToParcel(Parcel dest, int flags) {
    UUIDUtils.writeToParcel(mCharacteristic.getUuid(), dest);
  public BTCharacteristicProfile(Parcel in) {
    UUID uuid = UUIDUtils.readFromParcel(in);
    int properties = in.readInt();
    int permissions = in.readInt();
    byte[] value = in.createByteArray();
    mCharacteristic = new BluetoothGattCharacteristic(uuid, properties, permissions);
  public static final Parcelable.Creator<BTCharacteristicProfile> CREATOR = 
        new Parcelable.Creator<BTCharacteristicProfile>() {

            public BTCharacteristicProfile createFromParcel(Parcel source) {
                return new BTCharacteristicProfile(source);

            public BTCharacteristicProfile[] newArray(int size) {
                return new BTCharacteristicProfile[size];

Java Source Code List