PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Overview
  • Principle
  • Implementation
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
A "beacon" is a hardware transmitter that can "dialog" on a small perimeter with smartphones or tablets via a Bluetooth connection. The technology used is the one of BTLE (Bluetooth Low Energy).
The Beacon can for example indicate the proximity of an art masterpiece in a museum; the application can display the explanation text, or it can start a video or an audio file.
On the commercial side, a Beacon can trigger a message regarding a bargain on a nearby product. A Beacon can also inform a user that he is not far away from a store that sells a product he is looking for.
Principle
An application asks the phone to be warned when one or more Beacons are found nearby. This application can be closed immediately, therefore it consumes no battery.
When the phone detects a Beacon, it restarts the application and transmits the Beacon information.
Furthermore, the phone warns the application when it exits from the emission area of Beacon.
Implementation
Several WLanguage functions and 2 specific types can be used to manage Beacons.
AndroidAndroid Widget Caution: In Android, the management of Beacons uses the Android Beacon Library module, subject to license. You must comply with this license, available from the WINDEV Mobile license.
Depending on the use mode of your application, you have the ability to use one of the following methods:
  • Method 1: Automatic detection of Beacons
    This method consists in detecting groups of Beacons in the background with BeaconDetectBackground. A specific action is performed when a group of Beacons is detected. Example:
    // In a museum, we want to trigger the reading (resp. the stop) of an audio guide
    // when the visitor enters into (resp. exits from) a room.
    // Each Beacon is associated with the same UUID corresponding to the museum and
    // a Major number corresponding to the room in which the beacon will be positioned.
    // A Beacon is placed at each entrance to each room of the museum..
    // The application must call the BeaconDetectBackground function
    // with an array of BeaconGroup variables corresponding to each museum room.
     
    // The callback procedure passed in parameter to the function will be called
    // whenever entering into or exiting from a room and it will give information
    // about the detected groupe of beacons in order to
    // emulate the audio-guide to play the corresponding track.
     
    // Museum UUID
    sUUID is string = "f4231ab6-5ef2-6c99-4229-af6c72e0446e"
    // Create a beaconGroup variable for each room
    groupRoom1 is beaconGroup
    groupRoom1..UUID = sUUID
    groupRoom1..Major = 1
    groupRoom2 is beaconGroup
    groupRoom2..UUID = sUUID
    groupRoom2..Major = 2
    groupRoom3 is beaconGroup
    groupRoom3..UUID = sUUID
    groupRoom3..Major = 3
    groupRoom4 is beaconGroup
    groupRoom4..UUID = sUUID
    groupRoom4..Major = 4
    // Start the detection
    arrBeaconGroup is array of beaconGroup = [groupRoom1, ...
       groupRoom2, groupRoom3, groupRoom4)
    // The ProcDetection procedure will be run whenever the mobile enters into
    // or leaves the range defined by each group of beacons.
    BeaconDetectBackground(arrBeaconGroup, ProcDetection)
    PROCÉDURE ProcDetection(Group is beaconGroup, nType is int)

    IF nType = bdapLeave THEN
    // Stop the current track
    RETURN
    END

    IF nType = bdapEnter THEN
    SWITCH Group..Major
    CASE 1
    // Read the track for room 1
    CASE 2
    // Read the track for room 2
    ...
    END
    END
  • Method 2: Precise detection of Beacons
    This method consists in using the precise detection (BeaconDetectPrecise) to get the nearest Beacon and perform a specific operation. Example:
    // In a museum, we want to display on the visitor device the information
    // regarding the masterpiece he is looking at. Associate to each Beacon
    // the same UUID corresponding to the museum as well as Major and Minor numbers
    // allowing each Beacon to be uniquely identified.
    // A Beacon is placed next to each work of art in the museum.
    // The application must call the BeaconDetectPrecise function with a
    // BeaconGroup variable corresponding to the Beacons in the museum.
    // The callback procedure passed in parameter to the function will be called whenever
    // a new list of Beacons is detected. Then, all you have to do is find
    // the nearest Beacon to identify the work the visitor is looking at and to display
    // the corresponding information in the application.
     
    // Museum UUID
    sUUID is string = "f4231ab6-5ef2-6c99-4229-af6c72e0446e"
    // Create a beaconGroup variable corresponding to the Beacons in the museum
    groupMuseum is beaconGroup
    groupMuseum..UUID = sUUID
    // Start the detection
    BeaconDetectPrecise(groupMuseum, ProcDetection)
    INTERNAL PROCEDURE ProcDetection(arrInfo is array of beaconDetectionInfo)
    nMinDistance is int
    NearestBeacon is beaconDetectionInfo
    FOR EACH Information OF arrInfo
    IF nMinDistance = 0 _OR_ Information..Distance < nMinDistance
    NearestBeacon = Information
    END
    END
    // Display information about the masterpiece associated with the Beacon
    DisplayMasterpieceInfo(NearestBeacon..Major, NearestBeacon..Minor)
    END
Minimum version required
  • Version 23
Comments
Click [Add] to post a comment