Différences entre versions de « Bluefruit-LE-Shield-BLE-Services »
Ligne 28 : | Ligne 28 : | ||
{{ambox-stop|text= You must be connected to another device for this command to execute}} | {{ambox-stop|text= You must be connected to another device for this command to execute}} | ||
− | < | + | <nowiki> |
# Send a string when connected to another device | # Send a string when connected to another device | ||
AT+BLEUARTTX=THIS IS A TEST | AT+BLEUARTTX=THIS IS A TEST | ||
Ligne 36 : | Ligne 36 : | ||
AT+BLEUARTTX=THIS IS A TEST | AT+BLEUARTTX=THIS IS A TEST | ||
ERROR | ERROR | ||
− | </ | + | </nowiki> |
=== Gestion de la mémoire tampon de réception === | === Gestion de la mémoire tampon de réception === | ||
Ligne 69 : | Ligne 69 : | ||
{{ambox|text= You can also use the AT+BLEUARTFIFO=RX command to check if any incoming data is available or not.}} | {{ambox|text= You can also use the AT+BLEUARTFIFO=RX command to check if any incoming data is available or not.}} | ||
− | < | + | <nowiki> |
# Command results when data is available | # Command results when data is available | ||
AT+BLEUARTRX | AT+BLEUARTRX | ||
Ligne 78 : | Ligne 78 : | ||
AT+BLEUARTRX | AT+BLEUARTRX | ||
OK | OK | ||
− | </ | + | </nowiki> |
== AT+BLEUARTFIFO == | == AT+BLEUARTFIFO == | ||
Ligne 87 : | Ligne 87 : | ||
* Output: The free space remaining in the TX and RX FIFO buffer if no parameter is present, otherwise the free space remaining in the specified FIFO buffer. | * Output: The free space remaining in the TX and RX FIFO buffer if no parameter is present, otherwise the free space remaining in the specified FIFO buffer. | ||
− | < | + | <nowiki> |
AT+BLEUARTFIFO | AT+BLEUARTFIFO | ||
1024,1024 | 1024,1024 | ||
Ligne 99 : | Ligne 99 : | ||
1024 | 1024 | ||
OK | OK | ||
− | </ | + | </nowiki> |
{{Bluefruit-LE-Shield-TRAILER}} | {{Bluefruit-LE-Shield-TRAILER}} |
Version du 12 juin 2017 à 14:49
Services BLE
The following commands allow you to interact with various GATT services present on Bluefruit LE modules when running in Command Mode.
Le service GATT et ses caractéristiques (Adafruit, anglais) gouvernent l'organisation et l'échange de données entre les périphériques.
AT+BLEUARTTX
This command will transmit the specified text message out via the UART Service while you are running in Command Mode.
- Codebase Revision: 0.3.0
- Parameters: The message payload to transmit. The payload can be up to 240 characters (since AT command strings are limited to a maximum of 256 bytes total).
- Output: This command will produce an ERROR message if you are not connected to a central device, or if the internal TX FIFO on the Bluefruit LE module is full.
As of firmware release 0.6.2 and higher, AT+BLEUARTTX can accept a limited set of escape code sequences:
- \r = carriage return
- \n = new line
- \t = tab
- \b = backspace
- \\ = backward slash
As of firmware release 0.6.7 and higher, AT+BLEUARTTX can accept the following escape code sequence since AT+BLEUARTTX=? has a specific meaning to the AT parser:
- \? = transmits a single question mark
As of firmware release 0.7.6 and higher, AT+BLEUARTTX can accept the following escape code sequence:
- \+ = transmit a single '+' character without having to worry about `+++` mode switch combinations
ESCAPE SEQUENCE NOTE: If you are trying to send escape sequences in code via something like 'ble.print("...");' please note that you will need to send a double back-slash for the escape code to arrive as-intended in the AT command. For example: ble.println("AT+BLEUARTTX=Some Test\\r\\n"); |
You must be connected to another device for this command to execute |
# Send a string when connected to another device AT+BLEUARTTX=THIS IS A TEST OK # Send a string when not connected AT+BLEUARTTX=THIS IS A TEST ERROR
Gestion de la mémoire tampon de réception
Starting with firmware version 0.6.7, when the TX FIFO buffer is full a 200ms blocking delay will be used to see if any free space becomes available in the FIFO before returning ERROR. The exact process is detailed in the flow chart below:
Note: The TX FIFO full check will happen for each GATT transaction (of up to 20 bytes of data each), so large data transfers may have multiple 200ms wait states. |
You can use the AT+BLEUARTFIFO=TX command to check the size of the TX FIFO before sending data to ensure that you have enough free space available in the buffer.
The TX FIFO has the following size, depending on the firmware version used:
- Firmware <=0.6.6: 160 characters wide
- Firmware >=0.6.7: 1024 characters wide
It IS possible with large data transfers that part of the payload can be transmitted, and the command can still produce an ERROR if the FIFO doesn't empty in time in the middle of the payload transfer (since data is transmitted in maximum 20 byte chunks). If you need to ensure reliable data transfer, you should always check the TX FIFO size before sending data, which you can do using the AT+BLEUARTFIFO command. If not enough space is available for the entire payload, add a SW delay until enough space is available. Any single AT+BLEUARTTX command can fit into the FIFO, but multiple large instances of this command may cause the FIFO to fill up mid transfer. |
AT+BLEUARTTXF
This is a convenience function the serves the same purpose as AT+BLEUARTTX, but data is immediately sent in a single BLE packet ('F' for force packet). This command will accept a maximum of 20 characters, which is the limit of what can be send in a single packet.
- Codebase Revision: 0.7.6
- Parameters: See AT+BLEUARTTX
- Output: See AT+BLEUARTTX
AT+BLEUARTRX
This command will dump the UART service's RX buffer to the display if any data has been received from from the UART service while running in Command Mode. The data will be removed from the buffer once it is displayed using this command.
Any characters left in the buffer when switching back to Data Mode will cause the buffered characters to be displayed as soon as the mode switch is complete (within the limits of available buffer space, which is 1024 bytes on current black 32KB SRAM devices, or 160 bytes for the blue first generation BLEFriend board based on 16KB SRAM parts).
- Codebase Revision: 0.3.0
- Parameters: None
- Output: The RX buffer's content if any data is available, otherwise nothing.
You can also use the AT+BLEUARTFIFO=RX command to check if any incoming data is available or not. |
# Command results when data is available AT+BLEUARTRX Sent from Android OK # Command results when no data is available AT+BLEUARTRX OK
AT+BLEUARTFIFO
This command will return the free space available in the BLE UART TX and RX FIFOs. If you are transmitting large chunks of data, you may want to check if you have enough free space in the TX FIFO before sending, keeping in mind that individual GATT packets can contain up to 20 user bytes each.
- Codebase Revision: 0.6.7
- Parameters: Running this command with no parameters will return two comma-separated values indicating the free space in the TX buffer, following by the RX buffer. To request a specific buffer, you can execute the command with either a "TX" or "RX" value (For example: "AT+BLEUARTFIFO=TX").
- Output: The free space remaining in the TX and RX FIFO buffer if no parameter is present, otherwise the free space remaining in the specified FIFO buffer.
AT+BLEUARTFIFO 1024,1024 OK AT+BLEUARTFIFO=TX 1024 OK AT+BLEUARTFIFO=RX 1024 OK
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