Arendi.BleLibrary  6.2.1.1599
Arendi.BleLibrary for Android
Arendi.BleLibrary.Extention.PeripheralManager< TPeripheral > Class Template Referenceabstract

Peripheral manager class. The peripheral manager may manage the known peripherals of an application. More...

Inheritance diagram for Arendi.BleLibrary.Extention.PeripheralManager< TPeripheral >:
Arendi.BleLibrary.Extention.IPeripheralManager< TPeripheral >

Public Member Functions

 PeripheralManager (ICentral central, Func< IPeripheral, AdvertiseInfoList, int, TPeripheral > createPeripheralFunction)
 Create a peripheral manager More...
 
void Clear ()
 Clear the list with all peripherals.
 
void Add (TPeripheral peripheral)
 Add peripheral to the list of known peripherals.
 
void Remove (TPeripheral peripheral)
 Remove peripheral from the list of known peripherals.
 
void Remove (IEnumerable< TPeripheral > peripheralsToRemove)
 Remove peripherals from the list of known peripherals.
 
TPeripheral Find (Uuid uuid)
 Find peripheral according to it's UUID.
 
void StartScan ()
 Start scan for peripherals.
 
void StopScan ()
 Stop scan for peripherals.
 
virtual void Dispose ()
 Dispose the peripheral manager. More...
 

Protected Member Functions

virtual bool CheckDiscovered (IPeripheral peripheral, AdvertiseInfoList advertiseInfoList, int rssi)
 Method the check if a discovered peripheral is valid or should be ignored. If this method is not overwritten any peripheral is valid. More...
 
abstract bool CheckRemove (TPeripheral peripheral)
 Method called when a peripheral has not been seen (advertised) for the configured PeripheralInvisibleTimeout time to check if this peripheral can be removed from the list. A derived class may overwrite this method to add other criteria's for the check (e.g. Peripheral is currently selected by the application). More...
 

Properties

ILog Log [get]
 Log instance More...
 
ICentral Central [get]
 Gets the central instance the peripheral manager uses. More...
 
bool IsScanning [get]
 
Uuid [] UuidFilter [get, set]
 
int PeripheralInvisibleTimeout [get, set]
 
bool DisposePeripheralOnRemove [get, set]
 
bool UpdateNameByAdvertisedData [get, set]
 
bool IsBluetoothDisabled [get]
 
bool IsBluetoothEnabled [get]
 
IEnumerable< TPeripheral > Peripherals [get]
 
bool IsDisposed [get]
 
- Properties inherited from Arendi.BleLibrary.Extention.IPeripheralManager< TPeripheral >
bool IsScanning [get]
 Check if the peripheral manager is scanning for peripherals or not. More...
 
Uuid [] UuidFilter [get, set]
 Array with service UUID's to check in advertise data. Only peripherals advertising one of the UUID's are added to the peripheral list. If set to null or an empty array all visible peripherals are added to the list. More...
 
int PeripheralInvisibleTimeout [get, set]
 Duration in seconds a device must be invisible (no advertising and not connected) until it gets removed from the peripheral manger. If the value is set to 0 the peripherals are not removed from the list automatically. More...
 
bool DisposePeripheralOnRemove [get, set]
 Enable/Disable the call of the dispose method on removed peripherals. By default this is enabled but if the removed peripherals should be disposed later the automatic Dispose may be disabled. More...
 
bool UpdateNameByAdvertisedData [get, set]
 Enable/Disable that advertised name information is used to update the peripheral name. If disabled the assigned name given by the bluetooth stack is always used. More...
 
bool IsBluetoothDisabled [get]
 Check if the bluetooth interface is disabled. Because there are more state of the bluetooth adapter than disabled and enabled, IsBluetoothDisabled is not equal to !IsBluetoothEnabled at any time More...
 
bool IsBluetoothEnabled [get]
 Check if the bluetooth interface is enabled. Because there are more state of the bluetooth adapter than disabled and enabled, IsBluetoothDisabled is not equal to !IsBluetoothEnabled at any time More...
 
IEnumerable< TPeripheral > Peripherals [get]
 Get a list with all managed peripherals. The returned list is a copy of the internal peripheral list. More...
 
bool IsDisposed [get]
 Check if the peripheral manager is already disposed. More...
 

Events

EventHandler< PeripheralAddedEventArgs< TPeripheral > > PeripheralAdded = delegate { }
 
EventHandler< PeripheralRemovedEventArgs< TPeripheral > > PeripheralRemoved = delegate { }
 
EventHandler BluetoothDisabled = delegate { }
 
EventHandler BluetoothEnabled = delegate { }
 
- Events inherited from Arendi.BleLibrary.Extention.IPeripheralManager< TPeripheral >
EventHandler< PeripheralAddedEventArgs< TPeripheral > > PeripheralAdded
 Occurs when a new peripheral was added to the peripherals list More...
 
EventHandler< PeripheralRemovedEventArgs< TPeripheral > > PeripheralRemoved
 Occurs when a peripheral removed from the peripherals list More...
 
EventHandler BluetoothDisabled
 Event triggered, when the bluetooth interface gets disabled More...
 
EventHandler BluetoothEnabled
 Event triggered, when the bluetooth interface gets enabled On iOS, the bluetooth interface needs some time until it is ready. At this time, his state is not enabled and neither disabled. Wait for the BluetoothEnabled event before accessing the stack. More...
 

Detailed Description

Peripheral manager class. The peripheral manager may manage the known peripherals of an application.

Template Parameters
TPeripheralClass of the managed peripherals. They must implement the IManagedPeripheral interface.
Type Constraints
TPeripheral :IManagedPeripheral 

Constructor & Destructor Documentation

◆ PeripheralManager()

Arendi.BleLibrary.Extention.PeripheralManager< TPeripheral >.PeripheralManager ( ICentral  central,
Func< IPeripheral, AdvertiseInfoList, int, TPeripheral >  createPeripheralFunction 
)

Create a peripheral manager

Parameters
centralCentral object to be used by the peripheral manger.
createPeripheralFunctionFunction to create a peripheral object. This function must have a IPeripheral as argument.

Member Function Documentation

◆ CheckDiscovered()

virtual bool Arendi.BleLibrary.Extention.PeripheralManager< TPeripheral >.CheckDiscovered ( IPeripheral  peripheral,
AdvertiseInfoList  advertiseInfoList,
int  rssi 
)
protectedvirtual

Method the check if a discovered peripheral is valid or should be ignored. If this method is not overwritten any peripheral is valid.

Parameters
peripheralDiscovered peripheral.
advertiseInfoListAdvertisement info.
rssiRSSI level.
Returns
True if the discovered peripheral is valid, false if not.

◆ CheckRemove()

abstract bool Arendi.BleLibrary.Extention.PeripheralManager< TPeripheral >.CheckRemove ( TPeripheral  peripheral)
protectedpure virtual

Method called when a peripheral has not been seen (advertised) for the configured PeripheralInvisibleTimeout time to check if this peripheral can be removed from the list. A derived class may overwrite this method to add other criteria's for the check (e.g. Peripheral is currently selected by the application).

Parameters
peripheral
Returns

◆ Dispose()

virtual void Arendi.BleLibrary.Extention.PeripheralManager< TPeripheral >.Dispose ( )
virtual

Dispose the peripheral manager.

Property Documentation

◆ Central

Gets the central instance the peripheral manager uses.

◆ Log

ILog Arendi.BleLibrary.Extention.PeripheralManager< TPeripheral >.Log
get

Log instance