Différences entre versions de « Bluefruit-LE-Shield-BLE-GAP »
Ligne 147 : | Ligne 147 : | ||
== AT+GAPSTOPADV == | == AT+GAPSTOPADV == | ||
− | + | Arrête l'émission des paquets d'annonce depuis le module Bluefruit LE. | |
* Codebase Revision: 0.3.0 | * Codebase Revision: 0.3.0 | ||
− | * | + | * Paramètre: Aucun |
− | * | + | * Sortie: Aucun |
<nowiki>AT+GAPSTOPADV | <nowiki>AT+GAPSTOPADV |
Version du 20 juin 2017 à 21:30
BLE GAP
En cours de traduction/élaboration. |
GAP (Adafruit, Anglais) qui signifie Generic Access Profile gouverne l'annonce et les connexions avec les périphériques Bluetooth Low Energy.
Les commandes suivantes peuvent être utilisées pour configurer les paramètres GAP sur le module BLE.
Vous pouvez utiliser ces commandes pour modifier les données d'annonce (advertising data). Par exemple: le nom du périphérique tel qu'il doit apparaître sur votre smartphone durant le processus d'appairage. Les commandes permettent également de récupérer des informations concernant la connexion qui a été établie entre deux périphériques, ou la déconnexion si vous ne désirez pas maintenir une connexion.
AT+GAPCONNECTABLE
Cette commande est utilisé pour rendre le périphérique 'non connectable'.
- Codebase Revision: 0.7.0
- Paramètre: Indique si le périphérique doit (ou ne doit pas) s'annoncer comme "connectable". Utiliser une des valeurs suivantes:
- 1 ou yes - s'annoncer comme connectable
- 0 ou no - ne pas s'annoncer comme connectable
- Sortie: Afficher l'état 'connectable' du périphérique si la commande est appelée sans paramètre
# Rendre le périphérique non-connectable (avertissement uniquement) AT+GAPCONNECTABLE=0 OK # Vérifier le statut "connectable" actuel du module. AT+GAPCONNECTABLE 1 OK
AT+GAPGETCONN
Affiche le statut actuel de la connexion (si nous sommes connecté sur un autre périphérique BLE ou non).
- Codebase Revision: 0.3.0
- Paramètres: Aucun
- Sortie: 1 si connecté, sinon 0
# Connecté AT+GAPGETCONN 1 OK # Non connecté AT+GAPGETCONN 0 OK
AT+GAPDISCONNECT
Déconnecter le module du périphérique centrale (smartphone).
- Codebase Revision: 0.3.0
- Paramètre: Aucun
- Sortie: Aucun
AT+GAPDISCONNECT OK
AT+GAPDEVNAME
Obtenir ou modifier le nom du module, celui qui est inclus dans le payload d'annonce du module Bluefruit LE
- Codebase Revision: 0.3.0
- Paramètre:
- Aucun pour lire le nom actuel du périphérique
- Le nouveau nom du périphérique si vous voulez changer le nom
- Sortie: Le nom actuel du périphérique si la commande est exécutée en mode lecture.
Le nom du module est stocké dans la mémoire non volatile. Ce nouveau nom est donc persistant. La modification est effective dès la réinitialisation du système (ATZ). Pour réinitialiser le périphérique aux valeurs d'usine et effacer les données de configuration, il faut utiliser la commande AT+FACTORYRESET |
# Lecture du nom actuel du périphérique AT+GAPDEVNAME UART OK # Changer le nom du module BLE à 'BLEFriend' AT+GAPDEVNAME=BLEFriend OK # Réinitialisation système pour appliquer les modifications ATZ OK
AT+GAPDELBONDS
Efface les informations d'appairage stockés dans le module Bluefruit LE.
- Codebase Revision: 0.3.0
- Paramètres: Aucun
- Sortie: Aucun
AT+GAPDELBONDS OK
AT+GAPINTERVALS
Retrouver ou modifier les différentes intervalles d'annonce et de connexion pour le module Bluefruit LE.
Soyez extrêmement attentif en utilisant cette commande puisque vous pouvez facilement provoquer des problèmes en modifiant les intervalles. En effet, certains téléphones mobile pourrait ne plus reconnaître le module ou refuser de s'y connecter.
- Codebase Revision: 0.3.0
- Paramètres: Si vous désirez modifier les intervalles GAP, les données doivent être saisi dans l'ordre suivant (séparés avec des virgules):
- Minimum connection interval (Intervalle de connexion minimal, en millisecondes)
- Maximum connection interval (Intervalle de connexion maximal, en millisecondes)
- Fast Advertising interval (Intervalle d'annonce rapide, en millisecondes)
- Fast Advertising timeout (Timeout d'annonce rapide, en millisecondes)
- >= 0.7.0: Low power advertising interval (Intervalle d'annonce en mode d'économie d'énergie, en millisecondes), 417.5 ms par défaut
Afin d'économisé l'énergie, les modules Bluefruit passent en mode "lower advertising rate" (faible débit d'annonce) après avoir atteind le temps "fast advertising timeout" (en secondes). La valeur par défaut est de 30 secondes (Fast Advertising Timeout). L'intervalle "low power advertising interval" est hard-codé à environ 0.6s dans les firmwares avant < 0.7.0. La support du paramétrage "low power interval" à été ajouté dans le firmware 0.7.0 via un 5ieme paramètre optionnel. |
Voici les différentes limitations min et max pour les paramètres GAP:
- Absolute minimum connection interval (minimum absolu pour l'intervalle de connexion): 10ms
- Absolute maximum connection interval (maximum absolu pour l'intervalle de connexion) : 4000ms
- Absolute minimum fast advertising interval (minimum absolu pour l'intervalle d'annonce rapide): 20ms
- Absolute maximum fast advertisting interval (maximum absolu pour l'intervalle d'annonce rapide): 10240ms
- Absolute minimum low power advertising interval (minimum absolu pour l'intervalle annonce en économie d'énergie): 20ms
- Absolute maximum low power advertising interval (maximum absolu pour l'intervalle annonce en économie d'énergie): 10240ms
Si vous désirez uniquement modifier un intervalle alors laissez les autres valeurs -entre les virgules- vides (ex: ",,110," modifiera uniquement la 3ième valeur "advertising interval"). |
- Sortie: en lisant les paramètres d'intervalle GAP, les informations suivantes seront affichées (séparés par des virgules):
- Minimum connection interval (interval de connexion minimum, en milisecondes)
- Maximum connection interval (interval de connexion maximum, en milisecondes)
- Advertising interval (interval d'annonce, en milisecondes)
- Advertising timeout (timeout d'annonce, en milisecondes)
La modification des intervalles GAP est enregistré dans la mémoire non-volatile et les nouvelles valeurs seront utilisées après la réinitialisation du système. Pour réinitialiser le périphérique aux paramètres d'usine (et effacer vos paramètres de la mémoire), vous pouvez utiliser la commande AT+FACTORYRESET |
# Lecture des différents intervales GAP AT+GAPINTERVALS 20,100,100,30 # Modification de tous les intervalles AT+GAPINTERVALS=20,200,200,30 OK # Modifier uniquement l'intervalle d'annonce (advertising interval) AT+GAPINTERVALS=,,150, OK
AT+GAPSTARTADV
En cours de traduction/élaboration. |
Force le module Bluefruit LE commencer l'émission des paquets d'annonce si ce n'est pas déjà le cas (et en partant du principe qu'il n'est pas déjà connecté sur un pérhiphérique externe).
- Codebase Revision: 0.3.0
- Paramètre: Aucun
- Sortie: Aucun
# Résultat de la commande lorsque le module n’émet pas de paquet d'annonce AT+GAPSTARTADV OK # Résultat de la commande lorsque le Bluefruit émet déjà des paquets d'annonce AT+GAPSTARTADV ERROR # Résulatat de la commande lorque le module est déjà connecté sur un autre périphérique AT+GAPSTARTADV ERROR
AT+GAPSTOPADV
Arrête l'émission des paquets d'annonce depuis le module Bluefruit LE.
- Codebase Revision: 0.3.0
- Paramètre: Aucun
- Sortie: Aucun
AT+GAPSTOPADV OK
AT+GAPSETADVDATA
Sets the raw advertising data payload to the specified byte array (overriding the normal advertising data), following the guidelines in the Bluetooth 4.0 or 4.1 Core Specification.
In particular, Core Specification Supplement (CSS) v4 contains the details on common advertising data fields like 'Flags' (Part A, Section 1.3) and the various Service UUID lists (Part A, Section 1.1). A list of all possible GAP Data Types is available on the Bluetooth SIG's Generic Access Profile page.
The Advertising Data payload consists of Generic Access Profile data that is inserted into the advertising packet in the following format: [U8:LEN] [U8:Data Type Value] [n:Value]
WARNING: This command requires a degree of knowledge about the low level details of the Bluetooth 4.0 or 4.1 Core Specification, and should only be used by expert users. Misuse of this command can easily cause your device to be undetectable by central devices in radio range. |
WARNING: This command will override the normal advertising payload and may prevent some services from acting as expected. |
To restore the advertising data to the normal default values use the AT+FACTORYRESET command. |
For example, to insert the 'Flags' Data Type (Data Type Value 0x01), and set the value to 0x06/0b00000110 (BR/EDR Not Supported and LE General Discoverable Mode) we would use the following byte array:
02-01-06
- 0x02 indicates the number of bytes in the entry
- 0x01 is the 'Data Type Value' and indicates that this is a 'Flag'
- 0x06 (0b00000110) is the Flag value, and asserts the following fields (see Core Specification 4.0, Volume 3, Part C, 18.1):
- LE General Discoverable Mode (i.e. anyone can discover this device)
- BR/EDR Not Supported (i.e. this is a Bluetooth Low Energy only device)
If we also want to include two 16-bit service UUIDs in the advertising data (so that listening devices know that we support these services) we could append the following data to the byte array:
05-02-0D-18-0A-18
- 0x05 indicates that the number of bytes in the entry (5)
- 0x02 is the 'Data Type Value' and indicates that this is an "Incomplete List of 16-bit Service Class UUIDs"
- 0x0D 0x18 is the first 16-bit UUID (which translates to 0x180D, corresponding to the Heart Rate Service).
- 0x0A 0x18 is another 16-bit UUID (which translates to 0x180A, corresponding to the Device Information Service).
Including the service UUIDs is important since some mobile applications will only work with devices that advertise a specific service UUID in the advertising packet. This is true for most apps from Nordic Semiconductors, for example. |
- Codebase Revision: 0.3.0
- Parameters: The raw byte array that should be inserted into the advertising data section of the advertising packet, being careful to stay within the space limits defined by the Bluetooth Core Specification.
- Response: None
# Advertise as Discoverable and BLE only with 16-bit UUIDs 0x180D and 0x180A AT+GAPSETADVDATA=02-01-06-05-02-0d-18-0a-18 OK
The results of this command can be seen in the screenshot below, taken from a sniffer analyzing the advertising packets in Wireshark. The advertising data payload is higlighted in blue in the raw byte array at the bottom of the image, and the packet analysis is in the upper section:
Basé sur "Bluefruit LE Shield" d'Adafruit Industries, écrit par
Kevin Townsend - Traduit en Français par shop.mchobby.be CC-BY-SA pour la traduction
Toute copie doit contenir ce crédit, lien vers cette page et la section "crédit de traduction".
Based on "Bluefruit LE Shield" from Adafruit Industries, written by
Kevin Townsend - Translated to French by shop.mchobby.be CC-BY-SA for the translation
Copies must includes this credit, link to this page and the section "crédit de traduction" (translation credit).
Traduit avec l'autorisation d'AdaFruit Industries - Translated with the permission from Adafruit Industries - www.adafruit.com