class CBTPlugin

Bluetooth specific implementation of the PeerHood plugin interface.

Inheritance:


Public Methods

[more] CBTPlugin()
Default constructor, sets the internal variables to their default values.
[more]bool Start()
Starts the plugin's inquiry routine.
[more]bool LoadParameter(std::string& aParameter)
Loads a parameter from the configuration file.
[more]void Stop()
Stops the plugin's inquiry routine.
[more]const std::string& GetName()
Returns plugin's unique id string.
[more]void* ThreadStarter(void* aArguments)
Starts plugin's main (inquiry) thread.
[more]void* AdvertStarter(void* aArguments)
Starts plugin's advertising thread.
[more]void InquiryThread()
Plugin's main thread that performs BT inquiry at certain intervals.
[more]bool AddDevice(const std::string& aDeviceName)
Checks if the found device is new (i.e. not detected before).
[more]bool MakeOlder()
Increases each device's timestamp by one and checks if some of them exceeds the limit.
[more]bool Advert()
Inserts the PeerHood tag to the local SDP database.
[more]bool Unadvert()
Removes the PeerHood tag from the SDP database.
[more]bool HasPeerHood(const std::string& aAddress, int* aPSM)
Checks if the PeerHood tag can be found from remote device's SDP database.
[more]bool FetchInformation(CDaemonDevice* aDevice, int aPSM)
Fetch the required information from other device
[more]bool FetchDeviceInfo(CDaemonDevice* aDevice, CBTConnection* connection)
Fetch services from the remote device
[more]bool FetchServices(CDaemonDevice* aDevice)
Fecthes a list of services available on the given remote device.
[more]bool FetchServices(CDaemonDevice* aDevice, CBTConnection* connection)
Fetch services from the remote device
[more]bool FetchPrototypes(CDaemonDevice* aDevice, CBTConnection* connection)
Fetch prototypes from the remote device
[more]void AdvertThread()
Listens a PSM for incoming SERVICE LIST requests.
[more]int ResetAdapter()
 @memo Try to reset (put down - bring up) adapter
[more]int CreateLowlevelSocket()
Create a low level socket for BT ioctl calls
[more]int DoInquiry(int aLen, int aNrsp, const uint8_t* aLap, inquiry_info** aIi, long aFlags)
"Own" inquiry function for bluetooth


Inherited from MAbstractPlugin:

Public Methods

ovirtual void UpdateState()
ovirtual void LoadListeners()


Inherited from MAbstractStateConverter:

Public Methods

ovirtual void RegisterListener(MAbstractListener* aListener)
ovirtual void SetState(bool aActive)
ovirtual void TriggerShutdown()
ovirtual 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).

o CBTPlugin()
Default constructor, sets the internal variables to their default values.

Returns:
none

obool 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

obool 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

ovoid 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

oconst 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')

ovoid* 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

ovoid* 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

ovoid 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

obool 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

obool 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

obool 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

obool 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

obool 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

obool FetchInformation(CDaemonDevice* aDevice, int aPSM)
Returns:
true if all information is successfully fetched

obool 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

obool 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

obool 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

obool 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

ovoid 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

oint 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.

oint 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.

oint 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++.