Table of Contents
1 Version History ________________________________________________________________________ 5
2 Introduction to Bluegiga Bluetooth Smart Software _____________________________________________ 7
2.1 The Bluegiga Bluetooth Smart Stack ___________________________________________________ 7
2.2 The Bluegiga Bluetooth Smart SDK ____________________________________________________ 8
2.3 The BGAPI TM Protocol _____________________________________________________________ 9
2.4 The BGLIB TM Host Library _________________________________________________________ 10
2.5 The BGScript TM Scripting Language _________________________________________________ 11
2.6 The Profile Toolkit TM _____________________________________________________________ 12
3 Introduction to Bluetooth Smart Technology _________________________________________________ 13
3.1 Physical layer ____________________________________________________________________ 13
3.2 Packet format ____________________________________________________________________ 14
3.2.1 Generic packet format _______________________________________________________ 14
3.2.2 Advertisement packet format __________________________________________________ 14
3.2.3 Data packet format _________________________________________________________ 14
3.3 Link layer state machine ____________________________________________________________ 16
3.4 Link layer operations ______________________________________________________________ 17
3.4.1 Passive scanning __________________________________________________________ 17
3.4.2 Active scanning ____________________________________________________________ 18
3.4.3 Connection establishment ____________________________________________________ 18
3.5 Topologies ______________________________________________________________________ 19
3.6 Connections and packet timings ______________________________________________________ 20
3.7 Encryption _______________________________________________________________________ 22
3.8 L2CAP _________________________________________________________________________ 23
3.9 Security Manager _________________________________________________________________ 24
3.9.1 I/O capabilities and Man-in-the-Middle (MITM) protection ___________________________ 24
3.10 Attribute Protocol (ATT) ___________________________________________________________ 25
3.11 Generic Attribute Profile (GATT) ____________________________________________________ 28
3.12 Generic Access Profile (GAP) ______________________________________________________ 31
4 API definition _________________________________________________________________________ 32
4.1 The BGAPI protocol definition _______________________________________________________ 32
4.1.1 Message types ____________________________________________________________ 32
4.1.2 Command Class IDs ________________________________________________________ 34
4.1.3 Packet Exchange __________________________________________________________ 34
4.2 The BGLIB functions definition _______________________________________________________ 38
4.3 The BGScript API definition _________________________________________________________ 39
4.4 Data Types ______________________________________________________________________ 40
5 API Reference ________________________________________________________________________ 41
5.1 Attribute Client ___________________________________________________________________ 42
5.1.1 Commands _______________________________________________________________ 42
5.1.2 Enumerations _____________________________________________________________ 65
5.1.3 Events ___________________________________________________________________ 66
5.2 Attribute Database ________________________________________________________________ 72
5.2.1 Commands _______________________________________________________________ 72
5.2.2 Enumerations _____________________________________________________________ 80
5.2.3 Events ___________________________________________________________________ 82
5.3 Connection ______________________________________________________________________ 85
5.3.1 Commands _______________________________________________________________ 85
5.3.2 Enumerations _____________________________________________________________ 96
5.3.3 Events ___________________________________________________________________ 97
5.4 Generic Access Profile ____________________________________________________________ 101
5.4.1 Commands ______________________________________________________________ 101
5.4.2 Enumerations ____________________________________________________________ 121
5.4.3 Events __________________________________________________________________ 130
5.5 Hardware ______________________________________________________________________ 131
5.5.1 Commands ______________________________________________________________ 131
5.5.2 Events __________________________________________________________________ 160
5.6 Persistent Store _________________________________________________________________ 165
5.6.1 Commands ______________________________________________________________ 165