GAP API for bletiny

Generic Access Profile (GAP) defines the generic procedures related to discovery of Bluetooth devices (idle mode procedures) and link management aspects of connecting to Bluetooth devices (connecting mode procedures). It also defines procedures related to use of different security levels.

Several different modes and procedures may be performed simultaneously over an LE physical transport. The following modes and procedures are defined for use over an LE physical transport:

  1. Broadcast mode and observation procedure
    • These allow two devices to communicate in a unidirectional connectionless manner using the advertising events.
  2. Discovery modes and procedures
    • All devices shall be in either non-discoverable mode or one of the discoverable modes.
    • A device in the discoverable mode shall be in either the general discoverable mode or the limited discoverable mode.
    • A device in non-discoverable mode will not be discovered by any device that is performing either the general discovery procedure or the limited discovery procedure.
  3. Connection modes and procedures
    • allow a device to establish a connection to another device.
    • allow updating of parameters of the connection
    • allow termination of the connection
  4. Bonding modes and procedures
    • Bonding allows two connected devices to exchange and store security and identity information to create a trusted relationship.
    • Bonding can occur only between two devices in bondable mode.

Usage API

Item No.Modes and ProceduresnimBLE command
1Broadcast Modeb adv conn=non disc=x
Observation Procedureb scan dur=x disc=x type=x filt=x
2Non-Discoverable modeb adv conn=x disc=non
Limited Discoverable modeb adv conn=x disc=ltd
General Discoverable modeb adv conn=x disc=gen
Limited Discovery procedureb scan dur=x disc=ltd type=active filt=no_wl
General Discovery procedureb scan dur=x disc=gen type=active filt=no_wl
Name Discovery procedureb scan dur=x
b scan cancel
b conn peer_addr_type=x peer_addr=x
b read conn=x uuid=0x2a00
3Non-connectable modeb adv conn=non disc=x
Directed connectable modeb adv conn=dir [own_addr_type=x] [disc=x] [dur=x]
Undirected connectable modeb adv conn=und [own_addr_type=x] [disc=x] [dur=x]
Auto connection establishment procedureb wl addr_type=x addr=x [addr_type=y addr=y] [...]
b conn addr_type=wl
General connection establishment procedureb scan dur=x
b scan cancel
b conn peer_addr_type=x peer_addr=x
Selective connection establishment procedureb wl addr_type=x addr=x [addr_type=y addr=y] [...]
b scan filt=use_wl dur=x
b scan cancel
b conn peer_addr_type=x peer_addr=x [own_addr_type=x]
Direct connection establishment procedureb conn addr_type=x addr=x [params]
Connection parameter update procedureb update conn=x <params>
Terminate connection procedureb term conn=x
4Non-Bondable modeb set sm_data bonding=0 [*]
Bondable modeb set sm_data bonding=1 [*]
Bonding procedureb sec start conn=x [*]

[*] Security is disabled by default in bletiny. To use the bonding modes and procedures, add BLE_SM_LEGACY: 1 or BLE_SM_SC: 1 to your syscfg.yml file depending on your needs.

Address Types

| bletiny string | Description | Notes | |------------------|---------------| | public | Public address. | | | random | Random static address. | | | rpa_pub | Resolvable private address, public identity. | Not available for all commands. | | rpa_rnd | Resolvable private address, random static identity. | Not available for all commands. | | wl | Use white list; ignore peer_addr parameter. | Only availble for “conn” command. |

Connection Types

Bluetooth Specification Version 5.0 allows for different types of connections:

Descriptionbletiny ext parameter value
Legacy connectionnone
Extended connection with 1M PHY1M
Extended connection with coded PHYcoded
Extended connection with both 1M and coded PHYboth
Extended connection with 1M, 2M and coded PHYsall

Connection Parameters

Connection parameter definitions can be found in Section 7.8.12 of the BLUETOOTH SPECIFICATION Version 5.0 [Vol 2, Part E].

Connection parameters for all types of connections:

NameDescriptionbletiny string
Connection TypeParameter indicating the type of connectionext
Peer_Address_TypeWhether the peer is using a public or random address (see Address types table).peer_addr_type
Peer_AddressThe 6-byte device address of the peer; ignored if white list is usedpeer_addr
Own_Address_TypeThe type of address to use when initiating the connection (see Address types table)own_addr_type
DurationNumber of milliseconds before aborting the connect attemptdur

Connection parameters for legacy and 1M PHY extended connection:

NameDescriptionbletiny string
LE_Scan_IntervalRecommendation from the Host on how long the Controller should scanscan_itvl
LE_Scan_WindowRecommendation from the Host on how frequently the Controller should scanscan_window
Conn_Interval_MinDefines minimum allowed connection intervalitvl_min
Conn_Interval_MaxDefines maximum allowed connection intervalitvl_max
Conn_LatencyDefines the maximum allowed connection latencylatency
Supervision_TimeoutLink supervision timeout for the connection.timeout
Minimum_CE_LengthInformative parameter providing the Controller with the expected minimum length of the connection eventmin_ce_len
Maximum_CE_LengthInformative parameter providing the Controller with the expected maximum length of the connection eventmax_ce_len

Extended Connection parameters for coded PHY connection:

NameDescriptionbletiny string
LE_Scan_IntervalRecommendation from the Host on how long the Controller should scancoded_scan_itvl
LE_Scan_WindowRecommendation from the Host on how frequently the Controller should scancoded_scan_window
Conn_Interval_MinDefines minimum allowed connection intervalcoded_itvl_min
Conn_Interval_MaxDefines maximum allowed connection intervalcoded_itvl_max
Conn_LatencyDefines the maximum allowed connection latencycoded_latency
Supervision_TimeoutLink supervision timeout for the connection.coded_timeout
Minimum_CE_LengthInformative parameter providing the Controller with the expected minimum length of the connection eventcoded_min_ce_len
Maximum_CE_LengthInformative parameter providing the Controller with the expected maximum length of the connection eventcoded_max_ce_len

Extended Connection parameters for 2M PHY connection:

NameDescriptionbletiny string
Conn_Interval_MinDefines minimum allowed connection interval2M_itvl_min
Conn_Interval_MaxDefines maximum allowed connection interval2M_itvl_max
Conn_LatencyDefines the maximum allowed connection latency2M_latency
Supervision_TimeoutLink supervision timeout for the connection.2M_timeout
Minimum_CE_LengthInformative parameter providing the Controller with the expected minimum length of the connection event2M_min_ce_len
Maximum_CE_LengthInformative parameter providing the Controller with the expected maximum length of the connection event2M_max_ce_len

Scan Types

Bluetooth Specification Version 5.0 allows for different types of scan:

Descriptionbletiny ext parameter value
Legacy scan0
Extended scan with 1M PHY1M
Extended scan with coded PHYcoded
Extended scan with both 1M and coded PHYboth

Scan Parameters

Scan parameter definitions can be found in Section 7.8.10 of the BLUETOOTH SPECIFICATION Version 5.0 [Vol 2, Part E].

NameDescriptionbletiny string
Scan TypeParameter indicating the type of scanext
LE_Scan_TypeControls the type of scan to perform (passive or active)passive
LE_Scan_IntervalRecommendation from the Host on how long the Controller should scanitvl
LE_Scan_WindowRecommendation from the Host on how frequently the Controller should scanwindow
Scanning_Filter_PolicyPolicy about which advertising packets to acceptfilter
DurationNumber of milliseconds before canceling scan proceduredur
LimitedLimited scan procedureltd
No duplicatesFilter out duplicates in shell outputnodups
Own_Address_TypeThe type of address to use when scanning (see Address types table)own_addr_type

Extended Scan parameters:

NameDescriptionbletiny string
DurationNumber of milliseconds before canceling scan procedureduration
PeriodPeriod in which scan should be enabled for specified durationperiod
LE_Scan_TypeControls the type of scan to perform (passive or active)lr_passive
LE_Scan_IntervalRecommendation from the Host on how long the Controller should scanlr_itvl
LE_Scan_WindowRecommendation from the Host on how frequently the Controller should scanlr_window

Advertisment Parameters

bletiny stringDescriptionNotesDefault
connConnectable modeSee Connectable Modes table.und
discDiscoverable modeSee Discoverable Modes table.gen
own_addr_typeThe type of address to advertise withSee Address Types table.public
peer_addr_typeThe peer's address typeOnly used for directed advertising; see Address Types table.public
peer_addrThe peer's addressOnly used for directed advertisingN/A
chan_map0
filtThe filter policySee Advertisement Filter Policies table.none
itvl_minunits=0.625msnon: 100ms; und/dir: 30ms
itvl_maxunits=0.625msnon: 150ms; und/dir: 60ms
hdWhether to use high-duty-cycle0/10
durMillisecondsForever

Extended Advertising parameters:

bletiny stringDescriptionNotesDefault
tx_powerMaximum power level at which the advertising packets are to be transmitted-127 - 127 dBm127 (Host has no preference)
primary_phyPHY on which the advertising packets are transmitted on the primary advertising channelnone
secondary_phyPHY on which the advertising packets are transmitted on the secondary advertising channelprimary_phy

Advertising PHY Types

Descriptionbletiny parameter value
Legacy advertisingnone
Extended advertising with 1M PHY1M
Extended advertising with 2M PHY2M
Extended advertising with coded PHYcoded

Advertisement Filter Policies

btshell stringDescriptionNotes
noneNo filtering. No whitelist used.Default
scanProcess all connection requests but only scans from white list.
connProcess all scan request but only connection requests from white list.
bothIgnore all scan and connection requests unless in white list.