24package trial.org.direct_bt;
26import java.util.ArrayList;
28import org.direct_bt.BTAdapter;
29import org.direct_bt.BTManager;
30import org.direct_bt.BTRole;
31import org.direct_bt.HCIStatusCode;
32import org.jau.io.PrintUtil;
33import org.junit.Assert;
90 Assert.assertNotNull(
"No adapter found for "+endpt.getClass().getSimpleName(), endpt.getAdapter());
95 List<DBTEndpoint> endpts =
new ArrayList<DBTEndpoint>();
106 if(
null == endpt.getAdapter() ) {
107 if( endpt.initAdapter( adapter ) ) {
108 endpt.setAdapter(adapter);
109 PrintUtil.println(System.err,
"****** Adapter-"+endpt.getClass().getSimpleName()+
" ADDED__: InitOK: " + adapter);
114 PrintUtil.println(System.err,
"****** Adapter ADDED__: Ignored: " + adapter);
120 if(
null != endpt.getAdapter() && adapter.
equals( endpt.getAdapter() ) ) {
121 endpt.setAdapter(
null);
122 PrintUtil.println(System.err,
"****** Adapter-"+endpt.getClass().getSimpleName()+
" REMOVED: " + adapter);
126 PrintUtil.println(System.err,
"****** Adapter REMOVED: Ignored " + adapter);
132 Assert.assertEquals(current_exp_discovering_state, adapter.
isDiscovering());
136 try { Thread.sleep(100); }
catch (
final InterruptedException e) { e.printStackTrace(); }
145 Assert.assertEquals(current_exp_discovering_state, adapter.
isDiscovering());
150 try { Thread.sleep(100); }
catch (
final InterruptedException e) { e.printStackTrace(); }
ChangedAdapterSetListener()
void adapterRemoved(final BTAdapter adapter)
BTAdapter was removed from the system.
ChangedAdapterSetListener(final List< DBTEndpoint > el)
boolean add(final DBTEndpoint e)
void adapterAdded(final BTAdapter adapter)
BTAdapter was added to the system.
Bluetooth roles from the perspective of the link layer (connection initiator).
Master
Master or central role, discovering remote devices and initiating connection.
BT Core Spec v5.2: Vol 1, Part F Controller Error Codes: 1.3 List of Error Codes.
BTAdapter represents one local Bluetooth Controller.
HCIStatusCode stopDiscovery()
Turns off device discovery if it is enabled.
HCIStatusCode startDiscovery()
Starts discovery using all default arguments, see startDiscovery(DiscoveryPolicy, boolean,...
boolean isInitialized()
Returns true, if initialize(BTMode) has already been called for this adapter, otherwise false.
boolean equals(final Object obj)
If both types are of BTAdapter, it compares their BDAddressAndType, see getAddressAndType().
boolean isAdvertising()
Returns the adapter's current advertising state.
boolean isPowered()
Returns whether the adapter is valid, plugged in and powered.
boolean isDiscovering()
Returns true if the meta discovering state is not ScanType#NONE.
BTRole getRole()
Return the current BTRole of this adapter.
int getBTMajorVersion()
Returns the Bluetooth major version of this adapter.
A thread safe singleton handler of the BTAdapter manager, e.g.
void addChangedAdapterSetListener(final ChangedAdapterSetListener l)
Add the given ChangedAdapterSetListener to this manager.
static void startDiscovery(final BTAdapter adapter, final boolean current_exp_discovering_state)
int getProtocolSessionsLeft()
String getName()
Return name of this endpoint, which becomes the adapter's name.
static void checkInitializedState(final DBTEndpoint endp)
void setProtocolSessionsLeft(final int v)
void close(final String msg)
int getProtocolSessionsDoneTotal()
int getProtocolSessionsDoneSuccess()
boolean initAdapter(BTAdapter adapter)
Initialize the given adapter for this endpoint.
void setAdapter(BTAdapter a)
Set the server adapter for this endpoint.
static void stopDiscovery(final BTAdapter adapter, final boolean current_exp_discovering_state)
BTAdapter getAdapter()
Return the adapter for this endpoint.
static ChangedAdapterSetListener initChangedAdapterSetListener(final BTManager manager, final List< DBTEndpoint > endpts)