28import java.util.ArrayList;
46 private volatile long nativeInstance;
47 long getNativeInstance() {
return nativeInstance; }
54 public static abstract class Listener implements AutoCloseable {
55 private volatile long nativeInstance;
56 long getNativeInstance() {
return nativeInstance; }
64 nativeInstance = ctorImpl();
66 private native
long ctorImpl();
71 synchronized( this ) {
72 handle = nativeInstance;
79 private static native
void dtorImpl(
final long nativeInstance);
178 final byte[] value,
final int value_offset);
202 final boolean notificationEnabled,
final boolean indicationEnabled);
211 public boolean equals(
final Object other) {
212 return this == other;
227 final List<DBGattService> services;
237 public DBGattServer(
final int max_att_mtu_,
final List<DBGattService> services_) {
238 services = services_;
240 final long[] nativeServices =
new long[services_.size()];
241 for(
int i=0; i < nativeServices.length; i++) {
242 nativeServices[i] = services_.get(i).getNativeInstance();
244 nativeInstance = ctorImpl(Math.max(512+1, max_att_mtu_), nativeServices);
246 private native
long ctorImpl(
final int max_att_mtu,
final long[] services);
251 synchronized( this ) {
252 handle = nativeInstance;
259 private static native
void dtorImpl(
final long nativeInstance);
271 this(512+1, services_);
277 this(512+1,
new ArrayList<DBGattService>());
282 if( service_uuid.equals( s.getType() ) ) {
290 if(
null == service ) {
313 final DBGattChar r = s.findGattCharByValueHandle(char_value_handle);
322 return addListenerImpl(l);
324 private native
boolean addListenerImpl(Listener l);
327 return removeListenerImpl(l);
329 private native
boolean removeListenerImpl(Listener l);
332 final String newline = System.lineSeparator();
333 final StringBuilder res =
new StringBuilder(
toString()+newline);
335 res.append(
" ").append(s.toString()).append(newline);
337 res.append(
" ").append(c.
toString()).append(newline);
339 res.append(
" ").append(d.
toString()).append(newline);
343 return res.toString();
Representing a Gatt Characteristic object from the GATT server perspective.
DBGattDesc getClientCharConfig()
Representing a Gatt Characteristic Descriptor object from the GATT server perspective.
native void bzero()
Fill value with zero bytes.
Listener to remote master device's operations on the local GATT-Server.
abstract boolean readCharValue(final BTDevice device, final DBGattService s, final DBGattChar c)
Signals attempt to read a value.
abstract void writeDescValueDone(final BTDevice device, final DBGattService s, final DBGattChar c, final DBGattDesc d)
Notifies completion of single or bulk writeDescValue() after having accepted and performed all write ...
abstract void connected(final BTDevice device, final int initialMTU)
Notification that device got connected.
abstract void clientCharConfigChanged(final BTDevice device, final DBGattService s, final DBGattChar c, final DBGattDesc d, final boolean notificationEnabled, final boolean indicationEnabled)
Notifies a change of the Client Characteristic Configuration Descriptor (CCCD) value.
abstract boolean writeCharValue(final BTDevice device, final DBGattService s, final DBGattChar c, final byte[] value, final int value_offset)
Signals attempt to write a single or bulk (prepare) value.
abstract void mtuChanged(final BTDevice device, final int mtu)
Notification that the MTU has changed.
abstract void disconnected(final BTDevice device)
Notification that device got disconnected.
abstract boolean writeDescValue(final BTDevice device, final DBGattService s, final DBGattChar c, final DBGattDesc d, final byte[] value, final int value_offset)
Signals attempt to write a single or bulk (prepare) value.
abstract void writeCharValueDone(final BTDevice device, final DBGattService s, final DBGattChar c)
Notifies completion of single or bulk writeCharValue() after having accepted and performed all write ...
abstract boolean readDescValue(final BTDevice device, final DBGattService s, final DBGattChar c, final DBGattDesc d)
Signals attempt to read a value.
boolean equals(final Object other)
Default comparison operator, merely testing for same memory reference.
Representing a complete list of Gatt Service objects from the GATT server perspective,...
DBGattService findGattService(final String service_uuid)
native void setMaxAttMTU(final int v)
Set maximum server Rx ATT_MTU, defaults to 512+1 limit.
DBGattDesc findGattClientCharConfig(final String service_uuid, final String char_uuid)
boolean resetGattClientCharConfig(final String service_uuid, final String char_uuid)
native int getMaxAttMTU()
Used maximum server Rx ATT_MTU, defaults to 512+1.
DBGattChar findGattCharByValueHandle(final short char_value_handle)
DBGattChar findGattChar(final String service_uuid, final String char_uuid)
DBGattServer()
Default empty ctor.
synchronized boolean removeListener(final Listener l)
synchronized boolean addListener(final Listener l)
DBGattServer(final int max_att_mtu_, final List< DBGattService > services_)
List< DBGattService > getServices()
List of Services.
DBGattServer(final List< DBGattService > services_)
Ctor using default maximum ATT_MTU of 512+1.
Representing a Gatt Service object from the ::GATTRole::Server perspective.
DBGattChar findGattChar(final String char_uuid)
BTDevice represents one remote Bluetooth device.