PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • 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 the Beacon tags.
AndroidAndroid Widget Caution: In Android, the management of Beacon tags is using 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 Beacon tags
    This method consists in detecting groups of Beacon tags in background with BeaconDetectBackground. A specific action is performed when a group of tags 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.
    // We associate to each Beacon tag the same UUID corresponding to the museum and
    // a Major number corresponding to the room where the tag will be positioned.
    // A Beacon tag is placed at each entrance of each museum room.
    // 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 exits from the area 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 Beacon tags
    This method consists in using the precise detection (BeaconDetectPrecise) to get the nearest tag and to 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 tag
    // the same UUID corresponding to the museum as well as Major and Minor numbers
    // used to identify each tag in a unique way.
    // A Beacon tag is placed near each masterpiece.
    // The application must call the BeaconDetectPrecise function with a
    // BeaconGroup variable corresponding to the museum tags.
    // The callback procedure passed in parameter to the function will be called whenever
    // a new list of Beacon tags is detected. Then, all you have to do is find
    // the nearest tag to identify the masterpiece watched by the visitor 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 museum tags
    groupMuseum is beaconGroup
    groupMuseum..UUID = sUUID
    // Start the detection
    BeaconDetectPrecise(groupMuseum, ProcDetection)
    INTERNAL PROCÉDURE ProcDetection(arrInfo is array of beaconDetectionInfo)
    nMinDistance is int
    NearestTag is beaconDetectionInfo
    FOR EACH Information OF arrInfo
    IF nMinDistance = 0 _OR_ Information..Distance < nMinDistance
    NearestTag = Information
    END
    END
    // Display information about the masterpiece associated with the tag
    DisplayMasterpieceInfo(NearestTag..Major, NearestTag..Minor)
    END
Minimum required version
  • Version 23
Comments
Click [Add] to post a comment