Adafruit Feather 32u4 Bluefruit LE: BLE GAP: Difference between revisions

From UNamur InfoSec
Jump to navigation Jump to search
Line 40: Line 40:
Sets the raw advertising data payload to the specified byte array (overriding the normal advertising data), following the guidelines in the [https://www.bluetooth.org/en-us/specification/adopted-specifications Bluetooth 4.0 or 4.1 Core Specification].
Sets the raw advertising data payload to the specified byte array (overriding the normal advertising data), following the guidelines in the [https://www.bluetooth.org/en-us/specification/adopted-specifications 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 [https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile Generic Access Profile] page.
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 [https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile Generic Access Profile] page.


The Advertising Data payload consists of [https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile Generic Access Profile] data that is inserted into the advertising packet in the following format: [U8:LEN] [U8:Data Type Value] [n:Value]
The Advertising Data payload consists of [https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile 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 [https://www.bluetooth.org/en-us/specification/assigned-numbers/generic-access-profile '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)


== Reference ==
== Reference ==

Revision as of 15:01, 14 December 2017

BLE GAP

GAP, which stands for the Generic Access Profile, governs advertising and connections with Bluetooth Low Energy devices.

The following commands can be used to configure the GAP settings on the BLE module.

You can use these commands to modify the advertising data (for ex. the device name that appears during the advertising process), to retrieve information about the connection that has been established between two devices, or the disconnect if you no longer wish to maintain a connection.

AT Commands

The Bluefruit LE modules use a Hayes AT-style command set to configure the device.

The advantage of an AT style command set is that it's easy to use in machine to machine communication, while still being somewhat user friendly for humans.

  • Test Command Mode '=?'

'Test' mode is used to check whether or not the specified command exists on the system or not.

Certain firmware versions or configurations may or may not include a specific command, and you can determine if the command is present by taking the command name and appending '=?' to it, as shown below

AT+BLESTARTADV=?
  • Write Command Mode '=xxx'

'Write' mode is used to assign specific value(s) to the command, such as changing the radio's transmit power level using the command we used above.

To write a value to the command, simple append an '=' sign to the command followed by any paramater(s) you wish to write (other than a lone '?' character which will be interpretted as tet mode):

AT+BLEPOWERLEVEL=-8
  • Execute Mode

'Execute' mode will cause the specific command to 'run', if possible, and will be used when the command name is entered with no additional parameters.

AT+FACTORYRESET
  • Read Command Mode '?'

'Read' mode is used to read the current value of a command.

Not every command supports read mode, but you generally use this to retrieve information like the current transmit power level for the radio by appending a '?' to the command, as shown below:

AT+BLEPOWERLEVEL?

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)

Reference

Adafruit Learn BLE GAP https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le/ble-gap

Adafruit Learn AT Commands https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le/at-commands