Différences entre versions de « Bluefruit-LE-Shield-BLE-GAP »

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche
Ligne 27 : Ligne 27 :
  
 
== AT+GAPGETCONN ==
 
== AT+GAPGETCONN ==
{{traduction}}
 
 
 
Affiche le statut actuel de la connexion (si nous sommes connecté sur un autre périphérique BLE ou non).
 
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
 
* Codebase Revision: 0.3.0

Version du 19 juin 2017 à 07:38


MCHobby investit du temps et de l'argent dans la réalisation de traduction et/ou documentation. C'est un travail long et fastidieux réalisé dans l'esprit Open-Source... donc gratuit et librement accessible.
SI vous aimez nos traductions et documentations ALORS aidez nous à en produire plus en achetant vos produits chez MCHobby.

BLE GAP

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

Disconnects to the external device if we are currently connected.

  • Codebase Revision: 0.3.0
  • Parameters: None
  • Output: None
AT+GAPDISCONNECT
OK

AT+GAPDEVNAME

Gets or sets the device name, which is included in the advertising payload for the Bluefruit LE module

  • Codebase Revision: 0.3.0
  • Parameters:
    • None to read the current device name
    • The new device name if you want to change the value
  • Output: The device name if the command is executed in read mode
# Read the current device name
AT+GAPDEVNAME
UART
OK
  
# Update the device name to 'BLEFriend'
AT+GAPDEVNAME=BLEFriend
OK
# Reset to take effect
ATZ
OK

AT+GAPDELBONDS

Deletes and bonding information stored on the Bluefruit LE module.

  • Codebase Revision: 0.3.0
  • Parameters: None
  • Output: None
AT+GAPDELBONDS
OK

AT+GAPINTERVALS

Gets or sets the various advertising and connection intervals for the Bluefruit LE module.

Be extremely careful with this command since it can be easy to cause problems changing the intervals, and depending on the values selected some mobile devices may no longer recognize the module or refuse to connect to it.

  • Codebase Revision: 0.3.0
  • Parameters: If updating the GAP intervals, the following comma-separated values can be entered:
    • Minimum connection interval (in milliseconds)
    • Maximum connection interval (in milliseconds)
    • Fast Advertising interval (in milliseconds)
    • Fast Advertising timeout (in seconds)
    • >= 0.7.0: Low power advertising interval (in milliseconds), default = 417.5 ms

Please note the following min and max limitations for the GAP parameters:

  • Absolute minimum connection interval: 10ms
  • Absolute maximum connection interval: 4000ms
  • Absolute minimum fast advertising interval: 20ms
  • Absolute maximum fast advertisting interval: 10240ms
  • Absolute minimum low power advertising interval: 20ms
  • Absolute maximum low power advertising interval: 10240ms
  • Output: If reading the current GAP interval settings, the following comma-separated information will be displayed:
    • Minimum connection interval (in milliseconds)
    • Maximum connection interval (in milliseconds)
    • Advertising interval (in milliseconds)
    • Advertising timeout (in milliseconds)
# Read the current GAP intervals
AT+GAPINTERVALS
20,100,100,30
  
# Update all values
AT+GAPINTERVALS=20,200,200,30
OK
  
# Update only the advertising interval
AT+GAPINTERVALS=,,150,
OK

AT+GAPSTARTADV

Causes the Bluefruit LE module to start transmitting advertising packets if this isn't already the case (assuming we aren't already connected to an external device).

  • Codebase Revision: 0.3.0
  • Parameters: None
  • Output: None
# Command results when advertising data is not being sent
AT+GAPSTARTADV
OK
  
# Command results when we are already advertising
AT+GAPSTARTADV
ERROR
  
# Command results when we are connected to another device
AT+GAPSTARTADV
ERROR

AT+GAPSTOPADV

Stops advertising packets from being transmitted by the Bluefruit LE module.

  • Codebase Revision: 0.3.0
  • Parameters: None
  • Output: None
 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]

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).
  • 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:

Bluefruit-LE-Shield-BLE-GAP-00.png


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