public class BasicBluetoothServer
extends java.lang.Object
implements ej.bluetooth.callbacks.ConnectionCallbacks, ej.bluetooth.callbacks.AdvertisementCallbacks
| Constructor and Description |
|---|
BasicBluetoothServer(ej.bluetooth.BluetoothAdapter adapter,
BluetoothPayloadBuilder bluetoothPayloadBuilder)
Instantiates a new
BasicBluetoothServer. |
BasicBluetoothServer(ej.bluetooth.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(ej.bluetooth.BluetoothService service)
Add a service to the server.
|
int |
getAdvertisingThreshold()
Gets the advertisingThreshold.
|
ej.bluetooth.BluetoothDevice[] |
getDevices()
Gets the devices.
|
void |
notifyDevices(BasicServerCharacteristic characteristic)
Notifies the devices that are register to a characteristics.
|
void |
onAdvertisementCompleted(ej.bluetooth.BluetoothAdapter adapter) |
void |
onConnected(ej.bluetooth.BluetoothDevice device) |
void |
onConnectFailed(ej.bluetooth.BluetoothDevice device) |
void |
onDisconnected(ej.bluetooth.BluetoothDevice device) |
void |
onPairCompleted(ej.bluetooth.BluetoothDevice device,
boolean success) |
void |
onPairRequest(ej.bluetooth.BluetoothDevice device) |
void |
onPasskeyGenerated(ej.bluetooth.BluetoothDevice device,
int passkey) |
void |
onPasskeyRequest(ej.bluetooth.BluetoothDevice device) |
void |
onServicesDiscovered(ej.bluetooth.BluetoothDevice device) |
void |
setAdvertisingThreshold(int advertisingThreshold)
Sets the advertisingThreshold.
|
void |
start()
Starts the server.
|
void |
start(ej.bluetooth.callbacks.AdvertisementCallbacks advertisment,
ej.bluetooth.callbacks.ConnectionCallbacks connectionCallbacks)
Starts the server.
|
void |
startAdvertising()
Start advertising.
|
void |
stop()
Stops the server.
|
void |
stopAdvertising()
Stops the advertising.
|
public BasicBluetoothServer(@NonNull
ej.bluetooth.BluetoothAdapter adapter,
@NonNull
BluetoothPayloadBuilder bluetoothPayloadBuilder)
BasicBluetoothServer.adapter - the adaptater to use.bluetoothPayloadBuilder - the payload to add.public BasicBluetoothServer(@NonNull
ej.bluetooth.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
ej.bluetooth.callbacks.AdvertisementCallbacks advertisment,
@Nullable
ej.bluetooth.callbacks.ConnectionCallbacks connectionCallbacks)
advertisment - the advertisment callback.connectionCallbacks - the connection callback.public void stop()
public void stopAdvertising()
BluetoothAdapter.stopAdvertising()public void onConnectFailed(ej.bluetooth.BluetoothDevice device)
onConnectFailed in interface ej.bluetooth.callbacks.ConnectionCallbackspublic void onConnected(ej.bluetooth.BluetoothDevice device)
onConnected in interface ej.bluetooth.callbacks.ConnectionCallbackspublic void onDisconnected(ej.bluetooth.BluetoothDevice device)
onDisconnected in interface ej.bluetooth.callbacks.ConnectionCallbackspublic void onPairRequest(ej.bluetooth.BluetoothDevice device)
onPairRequest in interface ej.bluetooth.callbacks.ConnectionCallbackspublic void onPairCompleted(ej.bluetooth.BluetoothDevice device,
boolean success)
onPairCompleted in interface ej.bluetooth.callbacks.ConnectionCallbackspublic void onPasskeyRequest(ej.bluetooth.BluetoothDevice device)
onPasskeyRequest in interface ej.bluetooth.callbacks.ConnectionCallbackspublic void onPasskeyGenerated(ej.bluetooth.BluetoothDevice device,
int passkey)
onPasskeyGenerated in interface ej.bluetooth.callbacks.ConnectionCallbackspublic void onServicesDiscovered(ej.bluetooth.BluetoothDevice device)
onServicesDiscovered in interface ej.bluetooth.callbacks.ConnectionCallbackspublic ej.bluetooth.BluetoothDevice[] getDevices()
BluetoothAdapter.getDevices()public void notifyDevices(BasicServerCharacteristic characteristic)
characteristic - the characteristic to notify.public void onAdvertisementCompleted(ej.bluetooth.BluetoothAdapter adapter)
onAdvertisementCompleted in interface ej.bluetooth.callbacks.AdvertisementCallbackspublic void addService(ej.bluetooth.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()