Bluetooth specific implementation of the PeerHood plugin interface.
Inheritance:
Public Methods
-
CBTPlugin()
- Default constructor, sets the internal variables to their default values.
-
bool Start()
- Starts the plugin's inquiry routine.
-
bool LoadParameter(std::string& aParameter)
- Loads a parameter from the configuration file.
-
void Stop()
- Stops the plugin's inquiry routine.
-
const std::string& GetName()
- Returns plugin's unique id string.
-
void* ThreadStarter(void* aArguments)
- Starts plugin's main (inquiry) thread.
-
void* AdvertStarter(void* aArguments)
- Starts plugin's advertising thread.
-
void InquiryThread()
- Plugin's main thread that performs BT inquiry at certain intervals.
-
bool AddDevice(const std::string& aDeviceName)
- Checks if the found device is new (i.e. not detected before).
-
bool MakeOlder()
- Increases each device's timestamp by one and checks if some of them exceeds the limit.
-
bool Advert()
- Inserts the PeerHood tag to the local SDP database.
-
bool Unadvert()
- Removes the PeerHood tag from the SDP database.
-
bool HasPeerHood(const std::string& aAddress, int* aPSM)
- Checks if the PeerHood tag can be found from remote device's SDP database.
-
bool FetchInformation(CDaemonDevice* aDevice, int aPSM)
- Fetch the required information from other device
-
bool FetchDeviceInfo(CDaemonDevice* aDevice, CBTConnection* connection)
- Fetch services from the remote device
-
bool FetchServices(CDaemonDevice* aDevice)
- Fecthes a list of services available on the given remote device.
-
bool FetchServices(CDaemonDevice* aDevice, CBTConnection* connection)
- Fetch services from the remote device
-
bool FetchPrototypes(CDaemonDevice* aDevice, CBTConnection* connection)
- Fetch prototypes from the remote device
-
void AdvertThread()
- Listens a PSM for incoming SERVICE LIST requests.
-
int ResetAdapter()
- @memo Try to reset (put down - bring up) adapter
-
int CreateLowlevelSocket()
- Create a low level socket for BT ioctl calls
-
int DoInquiry(int aLen, int aNrsp, const uint8_t* aLap, inquiry_info** aIi, long aFlags)
- "Own" inquiry function for bluetooth
Public Methods
-
virtual void UpdateState()
-
virtual void LoadListeners()
Public Methods
-
virtual void RegisterListener(MAbstractListener* aListener)
-
virtual void SetState(bool aActive)
-
virtual void TriggerShutdown()
-
virtual void SetAdapter(const std::string& aInterface, int aId)
Documentation
This class is Bluetooth specific implementation of the PeerHood plugin
interface. Other PeerHood capable devices are located using Bluetooth's
device discovery method and Service Discovery Protocol (SDP).
CBTPlugin()
-
Default constructor, sets the internal variables to their default
values.
- Returns:
- none
bool Start()
-
Starts the plugin's inquiry routine. After this method is called the
plugin starts to monitor its environment and tries to locate nearby
PeerHood-capable devices. Whenever a change in the neighborhood status is
detected the plugin will update the device & service database . This plugin
uses Bluetooth's device discovery routine and also Service Discovery
Protocol to locate PeerHood-capable devices in the neighborhood.
This method loads monitoring and service checking interval variables from
configuration file.
- Returns:
- boolean telling if the plugin could be started
bool LoadParameter(std::string& aParameter)
-
Loads a parameter from the configuration file. If the requested
parameter is found then the argument <code>aParameter</code> is replaced
with parameter's value.
- Parameters:
- aParameter - Parameter's name.
- Returns:
- true if the requested parameter was found
void Stop()
-
Stops the plugin's inquiry routine. After this call is handled the
plugin will stop monitoring the environment. This means that daemon's
device & service database will be deprecated as the time passes.
- Returns:
- none
const std::string& GetName()
-
Returns plugin's unique id string. The id of this plugin is 'bt-base'.
- Returns:
- plugin's unique id string ('bt-base')
void* ThreadStarter(void* aArguments)
-
Starts plugin's main (inquiry) thread. This dummy function is required
because C++ doesn't allow non-static member functions to be started as a
thread. This function just calls plugin instance's real inquiry function.
- Parameters:
- aArguments - Pointer to the currently running instance.
- Returns:
- always NULL
void* AdvertStarter(void* aArguments)
-
Starts plugin's advertising thread. This dummy function is required
because C++ doesn't allow non-static member functions to be started as a
thread. This function just calls plugin instance's real advertising
function.
- Parameters:
- aArguments - Pointer to the currently running instance.
- Returns:
- always NULL
void InquiryThread()
-
Plugin's main thread that performs BT inquiry at certain intervals. All
found devices are stored to the DeviceStorage shared with all plugins and
the PeerHood Daemon. This plugin declares a device to be present if it's
found during inquiry. Otherwise the device is decided to be
absent.
- Returns:
- none
bool AddDevice(const std::string& aDeviceName)
-
Checks if the found device is new (i.e. not detected before). If this
is the case then it is added to plugin's internal device list and the common
device & service database should be updated later on.
There two kinds of counters for device: timestamp is used for to mark "old" devices
and lastchecked is for performing service checking on specific interval.
Timestamp is zerod every time when device is found. If timestamp reaches specific value
device is erased. If device is seen, lastchecked value is decreased. If lastchecked
reaches zero, device services are checked.
- Parameters:
- aDeviceName - Name of the device to be added.
- Returns:
- true if the checked device is new
bool MakeOlder()
-
Increases each device's timestamp value by one and checks if some of
them exceeds the limit defined by KEEP_ALIVE_STAMP. In that case the "old"
device is removed from the internal device list so the common device & service
database should be updated.
- Returns:
- true if some device was removed from the internal device list
bool Advert()
-
Inserts the PeerHood tag to the local SDP database. Other Bluetooth-
enabled PeerHood devices will look for this tag when they try to locate
the surrounding PeerHood devices. If this function fails other devices are
not capable of detecting PeerHood on this device.
- Returns:
- true if the advertising was started successfully
bool Unadvert()
-
Removes the PeerHood tag from the local SDP database. After this
function is invoked, other devices are not able to detect the existence of
the PeerHood service on this machine.
- Returns:
- true if the advertising was ended succesfully
bool HasPeerHood(const std::string& aAddress, int* aPSM)
-
Checks if the PeerHood tag can be found from remote device's SDP
database. If the tag if found then the remote device is assumed to be
PeerHood-capable without any further checking.
- Parameters:
- aAddress - The address of the remote device.
aPSM - On return contains the PSM of the remote address if PeerHood is
found, otherwise -1.%s", aActive ? "active" : "passive
- Returns:
- true if the PeerHood tag was found on remote device's SDP database
bool FetchInformation(CDaemonDevice* aDevice, int aPSM)
-
- Returns:
- true if all information is successfully fetched
bool FetchDeviceInfo(CDaemonDevice* aDevice, CBTConnection* connection)
-
Fetch services from remote device and add them to the list of this daemon device
- Returns:
- true if all information is successfully fetched
bool FetchServices(CDaemonDevice* aDevice)
-
Fetches a list of services available on the given remote device. This
is done by establishing a new connection to the remote device using address
information given in the parameter <code>aDevice</code> and invoking the
service list request on the remote device. Founded services are added to
the device.
- Parameters:
- aDevice - The device whose service list should be fetched.
- Returns:
- none
bool FetchServices(CDaemonDevice* aDevice, CBTConnection* connection)
-
Fetch services from remote device and add them to the list of this daemon device
- Returns:
- true if all information is successfully fetched
bool FetchPrototypes(CDaemonDevice* aDevice, CBTConnection* connection)
-
Fetch prototypes from remote device and add them to the list of this daemon device
- Returns:
- true if all information is successfully fetched
void AdvertThread()
-
Listens a PSM for incoming SERVICE LIST requests. If a new request is
received then a new CBTConnection object is created and passed to the
PeerHood Daemon that sends the list of available services. The created
connection object is freed by the daemon. This function is ran on a thread
of its own.
- Returns:
- none
int ResetAdapter()
-
@memo Try to reset (put down - bring up) adapter
Tries to reset the adapter via ioctl calls to adapter.
- Parameters:
- aAdapterId - adapter to use
- Returns:
- RESET_OK when successful, RESET_SOCK/DOWN/UP_FAIL when errors.
int CreateLowlevelSocket()
-
Creates a low level socket for BT ioctl calls.
- Returns:
- SOCKET_CREATED when successful, NO_SOCKET_CREATED when errors and EXISTING_SOCKET if socket already
created.
int DoInquiry(int aLen, int aNrsp, const uint8_t* aLap, inquiry_info** aIi, long aFlags)
-
Copied from Bluez 4.32 sources (/lib/hci.c), almost identical to hci_inquiry() -function EXCEPT this can use an
existing socket (!) and not to create new one with every inquiry.
- This class has no child classes.
- See Also:
- MAbstractPlugin
Alphabetic index HTML hierarchy of classes or Java
This page was generated with the help of DOC++.