Modifications

Sauter à la navigation Sauter à la recherche
2 261 octets ajoutés ,  22 juin 2017 à 13:41
Ligne 171 : Ligne 171 :  
** The second (optional) parameter is the new value to assign to this characteristic (within the MIN_SIZE and MAX_SIZE limits defined when creating it).
 
** The second (optional) parameter is the new value to assign to this characteristic (within the MIN_SIZE and MAX_SIZE limits defined when creating it).
 
* Response: If the command is used in read mode (only the characteristic index is provided as a value), the response will display the current value of the characteristics.  If the command is used in write mode (two comma-separated values are provided), the characteristics will be updated to use the provided value.
 
* Response: If the command is used in read mode (only the characteristic index is provided as a value), the response will display the current value of the characteristics.  If the command is used in write mode (two comma-separated values are provided), the characteristics will be updated to use the provided value.
 +
 +
<nowiki># Clear any previous custom services/characteristics
 +
AT+GATTCLEAR
 +
OK
 +
 +
# Add a battery service (UUID = 0x180F) to the peripheral
 +
AT+GATTADDSERVICE=UUID=0x180F
 +
1
 +
OK
 +
 
 +
# Add a battery measurement characteristic (UUID = 0x2A19), notify enabled
 +
AT+GATTADDCHAR=UUID=0x2A19,PROPERTIES=0x10,MIN_LEN=1,VALUE=100
 +
1
 +
OK
 +
 +
# Read the battery measurement characteristic (index ID = 1)
 +
AT+GATTCHAR=1
 +
0x64
 +
OK
 +
 +
# Update the battery measurement characteristic to 32 (hex 0x20)
 +
AT+GATTCHAR=1,32
 +
OK
 +
 +
# Verify the previous write attempt
 +
AT+GATTCHAR=1
 +
0x20
 +
OK</nowiki>
 +
 +
== AT+GATTLIST ==
 +
Lists all custom GATT services and characteristics that have been defined on the device.
 +
* Codebase Revision: 0.3.0
 +
* Parameters: None
 +
* Response: A list of all custom services and characteristics defined on the device.
 +
 +
<nowiki># Clear any previous custom services/characteristics
 +
AT+GATTCLEAR
 +
OK
 +
 +
# Add a battery service (UUID = 0x180F) to the peripheral
 +
AT+GATTADDSERVICE=UUID=0x180F
 +
1
 +
OK
 +
 
 +
# Add a battery measurement characteristic (UUID = 0x2A19), notify enabled
 +
AT+GATTADDCHAR=UUID=0x2A19,PROPERTIES=0x10,MIN_LEN=1,VALUE=100
 +
1
 +
OK
 +
 
 +
# Add a custom service to the peripheral
 +
AT+GATTADDSERVICE=UUID128=00-11-00-11-44-55-66-77-88-99-AA-BB-CC-DD-EE-FF
 +
2
 +
OK
 +
 +
# Add a custom characteristic to the above service (making sure that there
 +
# is no conflict between the 16-bit UUID and bytes 3+4 of the 128-bit service UUID)
 +
AT+GATTADDCHAR=UUID=0x0002,PROPERTIES=0x02,MIN_LEN=1,VALUE=100
 +
2
 +
OK
 +
 +
# Get a list of all custom GATT services and characteristics on the device
 +
AT+GATTLIST
 +
ID=01,UUID=0x180F
 +
  ID=01,UUID=0x2A19,PROPERTIES=0x10,MIN_LEN=1,MAX_LEN=1,VALUE=0x64
 +
ID=02,UUID=0x11, UUID128=00-11-00-11-44-55-66-77-88-99-AA-BB-CC-DD-EE-FF
 +
  ID=02,UUID=0x02,PROPERTIES=0x02,MIN_LEN=1,MAX_LEN=1,VALUE=0x64
 +
OK</nowiki>
 +
 +
== AT+GATTCHARRAW ==
 +
This read only command reads binary (instead of ASCII) data from a characteristic. It is non-printable but has less overhead and is easier when writing libraries in Arduino.
 +
* Codebase Revision: 0.7.0
 +
* Parameters: The numeric ID of the characteristic to display the data for
 +
* Output: Binary data corresponding to the specified characteristic.
 +
 +
{{ambox|text=Note: This is a specialized command and no NEWLINE is present at the end of the command!}}
    
{{Bluefruit-LE-Shield-TRAILER}}
 
{{Bluefruit-LE-Shield-TRAILER}}
29 917

modifications

Menu de navigation