public class BlaubotWifiP2PBeacon extends java.lang.Object implements IBlaubotBeacon, IBlaubotBroadcastReceiver, IEthernetBeacon, java.io.Closeable, IBlaubotAndroidComponent
BeaconMessage to exchange their states.
Sadly we can not communicate additional attributes via upnp service requests (which we should be according to the upnp standard)
on android so we have to actively ask for this attributes (beaconId, state) by connecting to the device.
see: https://code.google.com/p/android/issues/detail?id=40003| Constructor and Description |
|---|
BlaubotWifiP2PBeacon(WifiP2pManager wifiP2pManager,
Channel beaconChannel,
int beaconPort)
The string that we exploit to pre-filter upnp devices before we probe them if they are really a
blaubot beacon.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
java.lang.Thread |
getAcceptThread() |
IBlaubotAdapter |
getAdapter()
Get the adapter of which this acceptor is part of.
|
int |
getBeaconPort() |
ConnectionMetaDataDTO |
getConnectionMetaData()
Get the connection meta data needed to connect to this connector
This infos can range from mac addresses over ip addresses to port numbers.
|
IntentFilter |
getIntentFilter() |
BroadcastReceiver |
getReceiver() |
boolean |
isStarted()
Retrieves the started state of this acceptor.
|
void |
onConnectionStateMachineStateChanged(IBlaubotState state)
Called when the
ConnectionStateMachine's state has changed. |
void |
onNewIntent(Intent intent)
Gets called when a new intent was received on the foreground activity
|
void |
onPause(Activity context)
Gets called when onPause was called on the foreground activity
|
void |
onResume(Activity context)
Gets called when onResume was called on the foreground activity
|
void |
setAcceptorListener(IBlaubotIncomingConnectionListener acceptorListener)
Sets a listener that receives callbacks whenever a connection was accepted by the acceptor.
|
void |
setBeaconStore(IBlaubotBeaconStore beaconStore)
Setter method for the dependency injection of a beacon store.
|
void |
setBlaubot(Blaubot blaubot)
Dependency injecton of the blaubot instance the beacon is working for.
|
void |
setCurrentContext(Context context)
Gets called if the android context changes (onResume).
|
void |
setDiscoveryActivated(boolean active)
Enables and disables the discovery of other (remote) blaubot devices.
|
void |
setDiscoveryEventListener(IBlaubotDiscoveryEventListener discoveryEventListener)
Sets the discovery event listener which gets called whenever another remote device's
state was discovered by this beacon or the
BlaubotBeaconService. |
void |
setListeningStateListener(IBlaubotListeningStateListener stateListener)
Sets a listener that receives callbacks, when the acceptor started accepting connections (is listening).
|
void |
startListening()
Starts the connection acceptor.
|
void |
stopListening()
Stops a running acceptor.
|
public BlaubotWifiP2PBeacon(WifiP2pManager wifiP2pManager,
Channel beaconChannel,
int beaconPort)
wifiP2pManager - android's wifi p2p manager servicebeaconChannel - the wifi p2p channel to be used for this beaconbeaconPort - the tcp port for this beacon to listen onpublic java.lang.Thread getAcceptThread()
getAcceptThread in interface IEthernetBeaconpublic int getBeaconPort()
getBeaconPort in interface IEthernetBeaconpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic void setCurrentContext(Context context)
IBlaubotAndroidComponentsetCurrentContext in interface IBlaubotAndroidComponentcontext - the contextpublic void onResume(Activity context)
IBlaubotAndroidComponentonResume in interface IBlaubotAndroidComponentcontext - the foregroudn activitypublic void onPause(Activity context)
IBlaubotAndroidComponentonPause in interface IBlaubotAndroidComponentcontext - the current android contextpublic void onNewIntent(Intent intent)
IBlaubotAndroidComponentonNewIntent in interface IBlaubotAndroidComponentintent - the new intentpublic IBlaubotAdapter getAdapter()
IBlaubotConnectionAcceptorgetAdapter in interface IBlaubotConnectionAcceptorpublic void startListening()
IBlaubotConnectionAcceptorstartListening in interface IBlaubotConnectionAcceptorpublic void stopListening()
IBlaubotConnectionAcceptorstopListening in interface IBlaubotConnectionAcceptorpublic boolean isStarted()
IBlaubotConnectionAcceptorisStarted in interface IBlaubotConnectionAcceptorpublic void setListeningStateListener(IBlaubotListeningStateListener stateListener)
IBlaubotConnectionAcceptorsetListeningStateListener in interface IBlaubotConnectionAcceptorstateListener - the listner to setpublic void setAcceptorListener(IBlaubotIncomingConnectionListener acceptorListener)
IBlaubotConnectionAcceptorsetAcceptorListener in interface IBlaubotConnectionAcceptoracceptorListener - the listener to be setpublic ConnectionMetaDataDTO getConnectionMetaData()
IBlaubotConnectionAcceptorgetConnectionMetaData in interface IBlaubotConnectionAcceptorpublic void setDiscoveryEventListener(IBlaubotDiscoveryEventListener discoveryEventListener)
IBlaubotBeaconBlaubotBeaconService.setDiscoveryEventListener in interface IBlaubotBeacondiscoveryEventListener - the listener to be setpublic void onConnectionStateMachineStateChanged(IBlaubotState state)
IBlaubotBeaconConnectionStateMachine's state has changed.
An implementation has to expose this state as soon as possible to compatible beacons.onConnectionStateMachineStateChanged in interface IBlaubotBeaconstate - the new state of the ConnectionStateMachinepublic void setDiscoveryActivated(boolean active)
IBlaubotBeaconsetDiscoveryActivated in interface IBlaubotBeaconactive - if set to true, the discovery (if running) will be active - inactive otherwisepublic void setBlaubot(Blaubot blaubot)
IBlaubotBeaconsetBlaubot in interface IBlaubotBeaconblaubot - the blaubot instancepublic void setBeaconStore(IBlaubotBeaconStore beaconStore)
IBlaubotBeaconsetBeaconStore in interface IBlaubotBeaconsetBeaconStore in interface IBlaubotConnectionAcceptorbeaconStore - the beacon store implementationpublic BroadcastReceiver getReceiver()
getReceiver in interface IBlaubotBroadcastReceiverpublic IntentFilter getIntentFilter()
getIntentFilter in interface IBlaubotBroadcastReceiverIntentFilter containing the intents needed by the BroadcastReceiver retrievable via getReceiver()