AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Comunicación / Funciones Beacon
  • Overview
  • Principle
  • Implementation
  • Versión necesaria
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
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.
AndroidWidget Android Please note: Beacon management on Android uses the Android Beacon Library module, which is subject to licensing. 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: Automated detection of Beacon tags
    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 as 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)
    PROCEDURE ProcDetection(Group is beaconGroup, nType is int)
     
    IF nType = bdbLeave THEN
    // Stop the current track
    RETURN
    END
     
    IF nType = bdbEnter 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 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 museum tags.
    // The callback procedure passed as 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 museum tags
    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 tag
    DisplayMasterpieceInfo(NearestBeacon.Major, NearestBeacon.Minor)
    END

Versión necesaria

AndroidWidget Android Las funciones de baliza solo están disponibles en Android 4.3 o posterior (nivel de API 18).
Si se utiliza la función con una versión anterior del sistema, se produce un error fatal.
Para determinar la versión de Android en la que se está ejecutando la aplicación, utilice la función SysAndroidVersion.
iPhone/iPadIOS Widget Las funciones de baliza solo están disponibles en iOS11 o posterior.
Versión mínima requerida
  • Versión 23
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 28/03/2025

Señalar un error o enviar una sugerencia | Ayuda local