Scans for nearby beacons. More...
Header: | #include <BeaconScanner.h> |
Since: | Esri::ArcGISRuntime 200.6 |
Inherits: | Esri::ArcGISRuntime::Object |
Public Functions
BeaconScanner(Esri::ArcGISRuntime::IndoorPositioningDefinition *definition, QObject *parent = nullptr) | |
virtual | ~BeaconScanner() override |
QList<Esri::ArcGISRuntime::BeaconInfo *> | allDiscoveredBeacons() const |
Esri::ArcGISRuntime::Error | error() const |
QFuture<void> | startAsync() |
Esri::ArcGISRuntime::BeaconScannerStatus | status() const |
QFuture<void> | stopAsync() |
Signals
void | beaconsDiscovered(const QList<Esri::ArcGISRuntime::BeaconInfo *> &beaconInfos) |
void | statusChanged(Esri::ArcGISRuntime::BeaconScannerStatus status) |
Detailed Description
BeaconScanner uses data stored in the 'Beacons' feature layer to perform a scan and report information related to iBeacon devices. Some of the data produced by BeaconScanner is not a part of the official iBeacon standard.
Note: BeaconScanner is only supported on Android and iOS.
On iOS, BeaconScanner requires the Qt bluetooth plugin. It must be added to apps via the following for qmake:
QT += bluetooth
or the following for CMake:
find_package(Qt6 COMPONENTS REQUIRED Bluetooth)
BeaconScanner requires both bluetooth and location permissions to operate.
Member Function Documentation
[explicit]
BeaconScanner::BeaconScanner (Esri::ArcGISRuntime::IndoorPositioningDefinition *definition, QObject *parent = nullptr)
Creates a new BeaconScanner object using the information contained in the provided IndoorPositioningDefinition.
- definition - The IndoorPositioningDefinition from an IPS-aware map.
- parent - The optional parent QObject.
BeaconScanner uses the 'Beacons' feature layer from the ArcGIS Indoors Information Model, which is stored in IndoorPositioningDefinition, to perform scans for a list of beacons.
For a map to be IPS-aware, one of the following must be true:
- A reference to an indoor positioning data service is defined in the web map properties.
- It contains an "ips_positioning" feature table. If a map is IPS-aware, an IndoorPositioningDefinition can be returned using Map::indoorPositioningDefinition.
[override virtual]
BeaconScanner::~BeaconScanner ()
Destructor.
QList<Esri::ArcGISRuntime::BeaconInfo *> BeaconScanner::allDiscoveredBeacons () const
Returns a list of all beacons discovered in the last scanning session.
A scanning session starts when you call startAsync and ends by calling stopAsync. This property resets when user starts a new scanning session (by calling startAsync). A BeaconInfo::lastRssi value of 127 means the iBeacon device was detected, but no iBeacon data was received. While BeaconScanner is running, some entries can have a BeaconInfo::lastRssi of 127 even if this iBeacon device transmits iBeacon data due to how iBeacon devices transmit multiple packets with different information. If a packet not related to iBeacon is received first, then BeaconScanner may consider this device as a beacon that does not transmit iBeacon data until the first iBeacon data arrives. To avoid that scenario, check for a BeaconInfo::lastRssi value of 127 after stopping a scan session.
[signal]
void BeaconScanner::beaconsDiscovered (const QList<Esri::ArcGISRuntime::BeaconInfo *> &beaconInfos )
Returns a list of iBeacons discovered in the last second.
- beaconInfos - Details of iBeacon data.
This event is triggered every second to provide all iBeacons visible in the last second. A visible iBeacon is a beacon that transmits iBeacon data in the advertisement data. If an iBeacon device does not produce an iBeacon advertisement packet, it will not be included in the list of visible beacons.
Note: We recommend using RAII techniques to ensure Esri::ArcGISRuntime::BeaconInfo is deleted after you are done with it.
Esri::ArcGISRuntime::Error BeaconScanner::error() const
Returns an error that describes a problem encountered while starting the BeaconScanner.
This property notifies the user about errors that occur in BeaconScanner. If BeaconScanner cannot be started, this property stores information related to what caused BeaconScanner to fail to start.
QFuture<void> BeaconScanner::startAsync ()
Starts the BeaconScanner.
If IndoorPositioningDefinition is not loaded when BeaconScanner starts, IndoorPositioningDefinition performs loading during the starting phase, which can lead to a significant delay before BeaconScanner is started. To prevent such a delay, manually load IndoorPositioningDefinition before starting BeaconScanner.
This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.
See Working with QFuture for further details.
Esri::ArcGISRuntime::BeaconScannerStatus BeaconScanner::status() const
Returns the current status of the BeaconScanner.
The status indicates if the BeaconScanner is starting, started, stopping, stopped, or has failed to start.
[signal]
void BeaconScanner::statusChanged (Esri::ArcGISRuntime::BeaconScannerStatus status)
Set the status changed callback function for the beacon scanner.
QFuture<void> BeaconScanner::stopAsync ()
Stops the BeaconScanner.
This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.
See Working with QFuture for further details.