Class LocalService

implements Attribute
Defines a BLE service with characteristics.

Class summary


constructor peripheral-manager/Peripheral uuid/BleUuid

Constructors

constructor peripheral-manager/Peripheral uuid/BleUuid

Methods

add-characteristic uuid/BleUuid --properties/int --permissions/int --value/Data=null --read-timeout-ms/int -> LocalCharacteristic
Deprecated. Pass the timeout to the LocalCharacteristic.handle-read-request function instead.

add-characteristic uuid/BleUuid --properties/int --permissions/int --value/Data=null -> LocalCharacteristic
Adds a characteristic to this service with the given parameters.
The uuid is the uuid of the characteristic
The properties is one of the CHARACTERISTIC-PROPERTY-* values (see CHARACTERISTIC-PROPERTY-BROADCAST and similar).
permissions is one of the CHARACTERISTIC-PERMISSIONS-* values (see CHARACTERISTIC-PERMISSION-READ and similar).
If value is specified and the characteristic supports reads, it is used as the initial value for the characteristic. If value is null or an empty ByteArray, then the characteristic supports callback reads and the client needs to call LocalCharacteristic.handle-read-request to provide the value upon request.
NOTE: Read callbacks are not supported in MacOS.
The peripheral must not yet be deployed.

Convenience method to add an indication characteristic with the given uuid.
Contrary to notifications (add-notification-characteristic), indications require an acknowledgment from the client.

Convenience method to add a notification characteristic with the given uuid.
Contrary to indications (add-indication-characteristic), notifications do not require an acknowledgment from the client.

add-read-only-characteristic uuid/BleUuid --value/Data --read-timeout-ms/int=DEFAULT-READ-TIMEOUT-MS -> LocalCharacteristic
Convenience method to add a read-only characteristic with the given uuid and value.
If value is specified, it is used as the initial value for the characteristic. If value is null or an empty ByteArray, then the characteristic supports callback reads and the client needs to call LocalCharacteristic.handle-read-request to provide the value upon request.
NOTE: Read callbacks are not supported in MacOS.
When using read callbacks, the read-timeout-ms specifies the time the callback function is allowed to use.

Convenience method to add a write-only characteristic with the given uuid.
If requires-response is true, the client must acknowledge the write operation. Any RemoteCharacteristic.write operation will block until the client acknowledges the write. The acknowledgment is frequently done by the BLE stack. An acknowledgment thus does not necessarily mean that the write operation has been processed by the client.

Convenience method to add a write-only characteristic with the given uuid.
If requires-response is true, the client must acknowledge the write operation. Any RemoteCharacteristic.write operation will block until the client acknowledges the write. The acknowledgment is frequently done by the BLE stack. An acknowledgment thus does not necessarily mean that the write operation has been processed by the client.

deploy -> none
Deploys this service.
After deployment, no more characteristics can be added.
Deprecated. Use Peripheral.deploy instead.

operator == other/any -> bool
Whether this object is equal to the other.
By default, identical is used for equality.
Inheritance
Classes overwrite this operator to get an equality specific to their needs. Equality operators often compare the type and field contents. For example:

class Pin:
  number/int

  constructor .number:

  operator == other:
    if other is not Pin: return false
    return number == other.number
A class doesn't have to follow the above format, but it must keep the operator in sync with any hash-code method. That is, if a class has a hash-code member, then the equality and hash-code must agree. If two instances are equal (a == b), then their hash codes must also be equal (a.hash-code == b.hash-code).

Stringifies this object.
Inheritance
Objects that need a human-friendly string representation should overwrite this method. The default string is based on the internal class-ID.

Fields

The UUID of the service.