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;
/*fromwww.java2s.com*/import java.util.UUID;
import com.ratio.util.UUIDUtils;
import android.bluetooth.BluetoothGattDescriptor;
import android.os.Parcel;
import android.os.Parcelable;
/**
* external description of a device profile, so once we query the device services and descriptors
* we can send it back from the service to the activity in a bundle, which can be received by the BroadcastReceiver
* @author mreynolds
*
*/publicclass BTDescriptorProfile implements Parcelable {
protected BluetoothGattDescriptor mDescriptor;
public BTDescriptorProfile(BluetoothGattDescriptor descriptor) {
mDescriptor = descriptor;
}
public BTDescriptorProfile(UUID uuid, int permissions) {
mDescriptor = new BluetoothGattDescriptor(uuid, permissions);
}
public BluetoothGattDescriptor getDescriptor() {
return mDescriptor;
}
@Override
publicint describeContents() {
return 0;
}
@Override
publicvoid writeToParcel(Parcel dest, int flags) {
UUIDUtils.writeToParcel(mDescriptor.getUuid(), dest);
dest.writeInt(mDescriptor.getPermissions());
dest.writeByteArray(mDescriptor.getValue());
}
public BTDescriptorProfile(Parcel in) {
UUID uuid = UUIDUtils.readFromParcel(in);
int permissions = in.readInt();
byte[] value = in.createByteArray();
mDescriptor = new BluetoothGattDescriptor(uuid, permissions);
mDescriptor.setValue(value);
}
publicstaticfinal Parcelable.Creator<BTDescriptorProfile> CREATOR =
new Parcelable.Creator<BTDescriptorProfile>() {
@Override
public BTDescriptorProfile createFromParcel(Parcel source) {
returnnew BTDescriptorProfile(source);
}
@Override
public BTDescriptorProfile[] newArray(int size) {
returnnew BTDescriptorProfile[size];
}
};
}