cordova-plugin-ble. peripheral
Source: cordova-ble/
BLE Peripheral API. Experimental, supported only on Android.
Methods
notify(deviceHandle, characteristicHandle, data, win, fail)
Sends a notification to a remote device that a characteristic's value has been updated.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
deviceHandle |
int |
|
From a connectionStateChangeCallback. |
characteristicHandle |
int |
|
GattCharacteristic.handle |
data |
ArrayBufferView |
|
The characteristic's new value. |
win |
emptyCallback |
|
|
fail |
failCallback |
|
sendResponse(deviceHandle, requestId, data, win, fail)
Sends a response to a read or write request.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
deviceHandle |
int |
|
From a requestCallback. |
requestId |
int |
|
From the same requestCallback as deviceHandle. |
data |
ArrayBufferView |
|
Required for responses to read requests. May be set to null for write requests. |
win |
emptyCallback |
|
|
fail |
failCallback |
|
startAdvertise(settings, win, fail)
Starts BLE advertise. Fails if advertise is running. In that case, call stopAdvertise first.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
settings |
AdvertiseSettings |
|
|
win |
emptyCallback |
|
|
fail |
failCallback |
|
startGattServer(settings, win, fail)
Starts the GATT server. There can be only one server. If this function is called while the server is still running, the call will fail. Once this function succeeds, the server may be stopped by calling stopGattServer.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
settings |
GattSettings |
|
|
win |
emptyCallback |
|
|
fail |
failCallback |
|
stopAdvertise(win, fail)
Stops BLE advertise.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
win |
emptyCallback |
|
|
fail |
failCallback |
|
stopGattServer(win, fail)
Stops the GATT server. This stops any active advertisements and forcibly disconnects any clients. There can be only one server. If startGattServer() returned success, you may call this function once. Calling it more will result in failure.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
win |
emptyCallback |
|
|
fail |
failCallback |
|