public class BasicBluetoothServer
extends java.lang.Object
Constructor and Description |
---|
BasicBluetoothServer(BluetoothAdapter adapter,
BluetoothPayloadBuilder bluetoothPayloadBuilder)
Instantiates a new
BasicBluetoothServer . |
BasicBluetoothServer(BluetoothAdapter adapter,
java.lang.String localName)
Instantiates a new
BasicBluetoothServer . |
BasicBluetoothServer(java.lang.String localName)
Instantiates a new
BasicBluetoothServer with the default BluetoothAdapter . |
Modifier and Type | Method and Description |
---|---|
void |
addService(BluetoothService service)
Add a service to the server.
|
int |
getAdvertisingThreshold()
Gets the advertisingThreshold.
|
BluetoothDevice[] |
getDevices()
Gets the devices.
|
void |
notifyDevices(BasicServerCharacteristic characteristic)
Notifies the devices that are register to a characteristics.
|
void |
onAdvertisementCompleted(BluetoothAdapter adapter) |
void |
onConnected(BluetoothDevice device) |
void |
onConnectFailed(BluetoothDevice device) |
void |
onDisconnected(BluetoothDevice device) |
void |
onPairCompleted(BluetoothDevice device,
boolean success) |
void |
onPairRequest(BluetoothDevice device) |
void |
onPasskeyGenerated(BluetoothDevice device,
int passkey) |
void |
onPasskeyRequest(BluetoothDevice device) |
void |
onServicesDiscovered(BluetoothDevice device) |
void |
setAdvertisingThreshold(int advertisingThreshold)
Sets the advertisingThreshold.
|
void |
start()
Starts the server.
|
void |
start(AdvertisementCallbacks advertisment,
ConnectionCallbacks connectionCallbacks)
Starts the server.
|
void |
startAdvertising()
Start advertising.
|
void |
stop()
Stops the server.
|
void |
stopAdvertising()
Stops the advertising.
|
public BasicBluetoothServer(@NonNull BluetoothAdapter adapter, @NonNull BluetoothPayloadBuilder bluetoothPayloadBuilder)
BasicBluetoothServer
.adapter
- the adaptater to use.bluetoothPayloadBuilder
- the payload to add.public BasicBluetoothServer(@NonNull BluetoothAdapter adapter, @NonNull java.lang.String localName)
BasicBluetoothServer
.adapter
- the adapter to use.localName
- the local name to advertise.public BasicBluetoothServer(@NonNull java.lang.String localName)
BasicBluetoothServer
with the default BluetoothAdapter
.localName
- the local name to advertise.BluetoothAdapter#getDefaultAdapter()
public void start()
public void startAdvertising()
public void start(@Nullable AdvertisementCallbacks advertisment, @Nullable ConnectionCallbacks connectionCallbacks)
advertisment
- the advertisment callback.connectionCallbacks
- the connection callback.public void stop()
public void stopAdvertising()
BluetoothAdapter#stopAdvertising()
public void onConnectFailed(BluetoothDevice device)
public void onConnected(BluetoothDevice device)
public void onDisconnected(BluetoothDevice device)
public void onPairRequest(BluetoothDevice device)
public void onPairCompleted(BluetoothDevice device, boolean success)
public void onPasskeyRequest(BluetoothDevice device)
public void onPasskeyGenerated(BluetoothDevice device, int passkey)
public void onServicesDiscovered(BluetoothDevice device)
public BluetoothDevice[] getDevices()
BluetoothAdapter#getDevices()
public void notifyDevices(BasicServerCharacteristic characteristic)
characteristic
- the characteristic to notify.public void onAdvertisementCompleted(BluetoothAdapter adapter)
public void addService(BluetoothService service)
service
- the service to add.BluetoothAdapter#addService(ej.bluetooth.BluetoothService)
public void setAdvertisingThreshold(int advertisingThreshold)
advertisingThreshold
- the advertisingThreshold to set. 0 to not using it.public int getAdvertisingThreshold()