ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / BTLE functions
  • Required permissions
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Used to connect to a Bluetooth Low Energy device.
Two syntaxes are available:
  • Syntax 1: Locking connection.
  • Syntax 2: Non-locking connection. This syntax is used to connect to a Bluetooth device from its physical address. You can for example connect the application to a device whose physical address was stored during a previous detection (with BTLEListDevice) as soon as this device is switched on and/or enters in the detection area of device.
In Windows, this function has no effect. The system automatically determines whether a connection should be opened or not when a request is made. However, you must use BTLEInitialize to set the btleDevice type to a valid status.
Example
myDevice is btleDevice
BTLEConnect(myDevice)
Syntax

Connecting to a Bluetooth Low Energy device (locking connection) Hide the details

<Result> = BTLEConnect(<Device> [, <Timeout>])
<Result>: Boolean
  • True if the connection was established,
  • False otherwise. ErrorInfo returns more information on the error.
<Device>: btleDevice variable
Name of the btleDevice variable that represents the Bluetooth Low Energy device with which the connection will be established. This device was detected by BTLEListDevice.
<Timeout>: Optional integer or optional Duration
Connection timeout (in milliseconds). If the connection was not established during this timeout, <Result> is set to False.
If this parameter is not specified, the default connection timeout is set to 5 seconds.
This parameter can be:
  • an integer corresponding to the number of milliseconds,
  • a Duration variable,
  • the duration in a readable format (e.g., 1 s or 10 ms).

Connecting to a Bluetooth Low Energy device (non-locking connection) Hide the details

BTLEConnect(<Device> , <WLanguage procedure>)
<Device>: btleDevice variable or character string
  • Name of the btleDevice variable that represents the Bluetooth Low Energy device with which the connection will be established.
  • Identifier of Bluetooth Low Energy device with which the connection will be established (Identifier property of btleDevice type).
    iPhone/iPad Caution: The device must have been identified by BTLEListDevice since the start of application.
There is no need for the device to be accessible during the call: the connection will be established as soon as the device is accessible. The procedure will be called whenever the device is switched on and/or whenever it enters in the detection area of device.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback" procedure) that will be called when connecting to the Bluetooth Low Energy device.
This procedure has the following format:
PROCEDURE <Procedure name> (<Device>, <Result>)
where:
  • <Device> is a variable of type btleDevice that corresponds to the connected Bluetooth device.
  • <Result> is a boolean variable:
    • True if the connection was established,
    • False otherwise. ErrorInfo returns more information on the error.
Remarks
Android

Required permissions

The call to this function modifies the permissions required by the application.
Required permission: BLUETOOTH.
This permission allows the applications to connect to the Bluetooth services.
Related Examples:
WM Bluetooth 4 Cross-platform examples (WINDEV Mobile): WM Bluetooth 4
[ + ] This example explains how to use the Bluetooth Low Energy functions (Bluetooth LE): BTLExxx.

It is an application allowing you to find the nearby BTLE devices, to connect to them and to interact with the proposed services.
Business / UI classification: Business Logic
Component: wd290android.aar
Minimum version required
  • Version 21
Comments
Click [Add] to post a comment

Last update: 06/27/2023

Send a report | Local help