settings-storage.txt 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. BlueZ settings storage
  2. **********************
  3. Purpose
  4. =======
  5. The purpose of this document is to describe the directory structure of
  6. BlueZ settings storage. In effect, this document will serve as the primary,
  7. up to date source of BlueZ storage information.
  8. It is intended as reference for developers. Direct access to the storage
  9. outside from bluetoothd is highly discouraged.
  10. Adapter and remote device info are read form the storage during object
  11. initialization. Write to storage is performed immediately on every value
  12. change.
  13. Default storage directory is /var/lib/bluetooth. This can be adjusted
  14. by the --localstatedir configure switch. Default is --localstatedir=/var.
  15. All files are in ini-file format.
  16. Storage directory structure
  17. ===========================
  18. The storage root directory contains an optional addresses file that's
  19. used for managing adapters that come without a pre-allocated address.
  20. The format of the addresses file is:
  21. [Static]
  22. <manufacturer id> = <array of addresses>
  23. Each adapter with an assigned address has its own subdirectory under the
  24. root, named based on the address, which contains:
  25. - a settings file for the local adapter
  26. - an attributes file containing attributes of supported LE services
  27. - an admin policy file containing current values of admin policies
  28. - a cache directory containing:
  29. - one file per device, named by remote device address, which contains
  30. device name
  31. - one directory per remote device, named by remote device address, which
  32. contains:
  33. - an info file
  34. - an attributes file containing attributes of remote LE services
  35. - a ccc file containing persistent Client Characteristic Configuration
  36. (CCC) descriptor information for GATT characteristics
  37. So the directory structure is:
  38. /var/lib/bluetooth/<adapter address>/
  39. ./settings
  40. ./attributes
  41. ./admin_policy_settings
  42. ./cache/
  43. ./<remote device address>
  44. ./<remote device address>
  45. ...
  46. ./<remote device address>/
  47. ./info
  48. ./attributes
  49. ./ccc
  50. ./<remote device address>/
  51. ./info
  52. ./attributes
  53. ...
  54. Settings file format
  55. ====================
  56. Settings file contains one [General] group with adapter info like:
  57. Alias String Friendly user provided name advertised
  58. for this adapter
  59. This value overwrites the system
  60. name (pretty hostname)
  61. Discoverable Boolean Discoverability of the adapter
  62. PairableTimeout Integer How long to stay in pairable mode
  63. before going back to non-pairable.
  64. The value is in seconds.
  65. 0 = disable timer, i.e. stay
  66. pairable forever
  67. DiscoverableTimeout Integer How long to stay in discoverable mode
  68. before going back to non-discoverable.
  69. The value is in seconds.
  70. 0 = disable timer, i.e. stay
  71. discoverable forever
  72. Sample:
  73. [General]
  74. Name=My PC
  75. Discoverable=false
  76. Pairable=true
  77. DiscoverableTimeout=0
  78. Identity file format
  79. ====================
  80. Identity file contains one [General] group that holds identity information
  81. such as keys and adresses:
  82. IdentityResolvingKey String 128-bit value of the IRK
  83. Sample:
  84. [General]
  85. IdentityResolvingKey=00112233445566778899aabbccddeeff
  86. Attributes file format
  87. ======================
  88. The attributes file lists all attributes supported by the local adapter or
  89. remote device.
  90. Attributes are stored using their handle as group name (decimal format).
  91. Each group contains:
  92. UUID String 128-bit UUID of the attribute
  93. Value String Value of the attribute as hexadecimal encoded
  94. string
  95. EndGroupHandle Integer End group handle in decimal format
  96. Sample:
  97. [1]
  98. UUID=00002800-0000-1000-8000-00805f9b34fb
  99. Value=0018
  100. [4]
  101. UUID=00002803-0000-1000-8000-00805f9b34fb
  102. Value=020600002A
  103. [6]
  104. UUID=00002a00-0000-1000-8000-00805f9b34fb
  105. Value=4578616D706C6520446576696365
  106. Admin Policy file format
  107. ======================
  108. The admin policy file stores the current value of each admin policy.
  109. [General] group contains:
  110. ServiceAllowlist List of List of service UUID allowed by
  111. strings adapter in 128-bits format, separated
  112. by ','. Default is empty.
  113. Sample:
  114. [General]
  115. ServiceAllowlist=
  116. CCC file format
  117. ======================
  118. The ccc file stores the current CCC descriptor values for GATT characteristics
  119. which have notification/indication enabled by the remote device.
  120. Information is stored using CCC attribute handle as group name (in decimal
  121. format).
  122. Each group contains:
  123. Value String CCC descriptor value encoded in
  124. hexadecimal
  125. Cache directory file format
  126. ============================
  127. Each file, named by remote device address, may includes multiple groups
  128. (General, ServiceRecords, Attributes, Endpoints).
  129. In ServiceRecords, SDP records are stored using their handle as key
  130. (hexadecimal format).
  131. In "Attributes" group GATT database is stored using attribute handle as key
  132. (hexadecimal format). Value associated with this handle is serialized form of
  133. all data required to re-create given attribute. ":" is used to separate fields.
  134. In "Endpoints" group A2DP remote endpoints are stored using the seid as key
  135. (hexadecimal format) and ":" is used to separate fields. It may also contain
  136. an entry which key is set to "LastUsed" which represented the last endpoint
  137. used.
  138. [General] group contains:
  139. Name String Remote device friendly name
  140. ShortName String Remote device shortened name
  141. [ServiceRecords] group contains
  142. <0x...> String SDP record as hexadecimal encoded
  143. string
  144. In [Attributes] group value always starts with attribute type, that determines
  145. how to interpret rest of value:
  146. Primary service:
  147. 2800:end_handle:uuid
  148. Secondary service:
  149. 2801:end_handle:uuid
  150. Included service:
  151. 2802:start_handle:end_handle:uuid
  152. Characteristic:
  153. 2803:value_handle:properties:uuid
  154. Descriptor:
  155. value:uuid
  156. uuid
  157. Sample Attributes section:
  158. [Attributes]
  159. 0001=2800:0005:1801
  160. 0002=2803:0003:20:2a05
  161. 0014=2800:001c:1800
  162. 0015=2803:0016:02:2a00
  163. 0017=2803:0018:02:2a01
  164. 0019=2803:001a:02:2aa6
  165. 0028=2800:ffff:0000180d-0000-1000-8000-00805f9b34fb
  166. 0029=2803:002a:10:00002a37-0000-1000-8000-00805f9b34fb
  167. 002b=2803:002c:02:00002a38-0000-1000-8000-00805f9b34fb
  168. 002d=2803:002e:08:00002a39-0000-1000-8000-00805f9b34fb
  169. [Endpoints] group contains:
  170. <xx>:<xx>:<xx>::<xx...> String First field is the endpoint type,
  171. followed by codec type and delay
  172. reporting and its
  173. capabilities as hexadecimal encoded
  174. string.
  175. LastUsed:<xx>:<xx> String LastUsed has two fields which are the
  176. local and remote seids as hexadecimal
  177. encoded string.
  178. Info file format
  179. ================
  180. Info file may includes multiple groups (General, Device ID, Link key and
  181. Long term key) related to a remote device.
  182. [General] group contains:
  183. Name String Remote device friendly name
  184. Alias String Alias name
  185. Class String Device class in hexadecimal,
  186. i.e. 0x000000
  187. Appearance String Device appearance in hexadecimal,
  188. i.e. 0x0000
  189. SupportedTechnologies List of List of technologies supported by
  190. strings device, separated by ";"
  191. Technologies can be BR/EDR or LE
  192. AddressType String An address can be "static" or "public"
  193. Trusted Boolean True if the remote device is trusted
  194. Blocked Boolean True if the remote device is blocked
  195. Services List of List of service UUIDs advertised by
  196. strings remote in 128-bits UUID format,
  197. separated by ";"
  198. [DeviceID] group contains:
  199. Source Integer Assigner of Device ID
  200. Vendor Integer Device vendor
  201. Product Integer Device product
  202. Version Integer Device version
  203. [LinkKey] group contains:
  204. Key String Key in hexadecimal format
  205. Type Integer Type of link key
  206. PINLength Integer Length of PIN
  207. [LongTermKey] group contains:
  208. Key String Long term key in hexadecimal format
  209. Authenticated Boolean True if remote device has been
  210. authenticated
  211. EncSize Integer Encrypted size
  212. EDiv Integer Encrypted diversifier
  213. Rand Integer Randomizer
  214. [SlaveLongTermKey] group contains:
  215. Same as the [LongTermKey] group, except for slave keys.
  216. [ConnectionParameters] group contains:
  217. MinInterval Integer Minimum Connection Interval
  218. MaxInterval Integer Maximum Connection Interval
  219. Latency Integer Connection Latency
  220. Timeout Integer Supervision Timeout
  221. [LocalSignatureKey] and [RemoteSignatureKey] groups contain:
  222. Key String Key in hexadecimal format
  223. Counter Integer Signing counter
  224. Authenticated Boolean True if the key is authenticated
  225. [ServiceChanged]
  226. This section holds information related to Service Changed characteristic
  227. of GATT core service.
  228. CCC_LE Integer CCC value for LE transport
  229. CCC_BR/EDR Integer CCC value for BR/EDR transport