ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Communication / BTLE functions
  • Required permissions
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Used to connect to a Bluetooth Low Energy device.
Two syntaxes are available:
  • Syntax 1: Blocking connection.
  • Syntax 2: non-blocking 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
monPeriph is btleDevice
BTLEConnect(monPeriph)
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 correspond to:
  • an integer representing 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 Attention: The device must have been identified by the BTLEListDevice function since the application was launched..
It is not necessary for the device to be accessible at the time of the call: the connection will be made 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 (also called "callback") 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

This function changes the permissions required by the application.
Permission required: 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: wd300android.aar
Minimum version required
  • Version 21
Comments
Click [Add] to post a comment

Last update: 03/25/2025

Send a report | Local help