The BLE Component can be used with various kinds of Bluetooth Low Energy devices. It provides a set of events for the results of finding and connecting to devices. It can also be used with broadcast-only devices like Beacons.
You add one BLE Component to your Project to enable Bluetooth, then each beacon is entered as a BLE Item under the BLE component. Each beacon requires its own ID number to be typed in so that the system can identify it. Then you add actions to the BLE Items that will occur when users come within the range of the beacon.
For example: the beacon’s interaction with the Project can map and direct consumers’ movement within a space; when the consumer comes close to the beacon, the project can notify them with a text popup of special offers, exclusive rewards or extra product information.
Beacons can also be used in the Offline Map component to provide indoor location.
Setting up a BLE Component
- Click the large plus button to the right of your project name – this opens the Component Selector
- Go to the IoT tab
- Insert a BLE Component
- A BLE Component has no Properties to set
Check Bluetooth Permission
Important: You will need to add the Check Bluetooth Permission action before any other Bluetooth actions can be used. The “After Page Show” event is a good place for this. Further Bluetooth actions can then be added to the “On Permission Granted” event of the BLE Component.
Users will only be shown the Check Bluetooth Permission dialog the first time they use the app. If the user happens to choose ‘Deny’, they will need to go the the device’s App Settings to give Bluetooth permission before the App can run any Bluetooth functions.
Starting Bluetooth Scanning
You will need to add a Set BLE Frequency action somewhere to start Bluetooth scanning. You might place this action on a BLE Component’s “On Permission Granted” event, or on a Button click. If the user has not enabled Bluetooth on their device, they will usually be prompted to allow the App to use Bluetooth.
Go on to add BLE Items under the BLE component for each beacon.
Except for On Enable and On Disable these events require advanced programming knowledge. Refer to IoT/SDK documentation for the other events.
- On Device Connected
- On Device Disconnected
- On Device Discovered
- On Device Error
- On Permission Granted: Occurs when permission has been granted for the device to use Bluetooth, after the Check Bluetooth Permission action has run.
- On Permission Denied
- On Enable: Occurs when Bluetooth has been successfully enabled on the device, after an Enable Bluetooth or Set BLE Frequency action. This may have required the user’s permission to enable it.
- On Disabled: Occurs when Bluetooth has been disabled on the device.
- On Scan Start: Occurs when a scanning cycle starts.
- On Scan End: Occurs when a scanning cycle ends.
Actions affecting the BLE Component
There are several specific actions related to the BLE Component in the IoT Actions tab. Using either Set BLE Frequency or Enable Bluetooth is required to start operation. See IoT Actions.
If you’re only using Beacons, and no other types of Bluetooth device, only the Set BLE Frequency action is useful.
Setting up a BLE Item
Using the plus button on the BLE Component you can add BLE Items for each Kontakt Beacon you want to scan for. These will be grouped under the BLE Component.
BLE Item properties
|ID||Required. Pops up text editor panel to enter the Kontakt Beacon ID, such as “rtFXp8”|
|Close||Defines the signal strength that will be considered “Close”. Slider to indicate signal strength in|
decibels (-180 to 0) The default setting is -80 and is generally a very appropriate level.
|Very Close||Defines the signal strength that will be considered “Very Close”. Slider (-180 to 0) The default|
setting is -60 and is generally a very appropriate level.
BLE Item Events
BLE Items have the following events that can occur:
- On Recognize: The beacon has been found, at any distance. In addition to this event, one of the
following will fire:
- On Recognize Close: The beacon has been found at a close range.
- On Recognize Very Close: The beacon has been found at a very short distance (typically a
- On Recognize Far: The beacon has been found at a further distance.
- On Recognize Closest: The beacon has been found and is the strongest signal (closest) of all the
beacons that have been found.
- On Recognize Closest Lost: The beacon is no longer the closest one found.
- On Device Lost: The beacon was found before but has now been lost – could not be found in the
last scan. Useful for an item security app.
The actions may be connected to the movement of a phone, your car keys or travel luggage as examples.