aboutsummaryrefslogtreecommitdiff
path: root/content/2019-05-11-bci.md
blob: 24e9a30bd3b6ad859cb4364f1e83accc331af447 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
layout: draft
title: BCI
description: Imagine a world where you could go outside and take a leaf from a tree and put it through your personal DNA sequencer and get data like music, videos or computer programs from it.
slug: bci
type: research
date: 2019-05-11
---

**Table of contents**

1. [Intefacing with Bluetooth device](#intefacing-with-bluetooth-device)
   1. [Basic Concepts](#basic-concepts)
      1. [Attributes](#attributes)
      2. [Structure](#structure)
      3. [Services](#services)
      4. [Characteristics](#characteristics)
2. [Generic text for testing CSS styles](#generic-text-for-testing-css-styles)
3. [Resources](#resources)


## Intefacing with Bluetooth device

A Bluetooth device contains a table of data called an Attribute Table which can be accessed by other connected devices in various possible ways. That table of data and the ways in which it can be exploited falls into a technical area of Bluetooth called the Generic Attribute profile or GATT for short and you may see the term GATT in some of the documentation for APIs such as those provided by the Android platform.

The Attribute Table contains something like a series of records of various types. The main types are called Services, Characteristics, and Descriptors. Let’s look at each of these terms in turn.

### Basic Concepts

#### Attributes

Services, Characteristics and Descriptors are all types of Attribute. Hence Generic Attribute Profile, Attribute Table and something called the Attribute Protocol. All attributes have a type which is identified by a UUID (Universally Unique Identifer). Some Attributes are defined by the Bluetooth SIG, the technical standards body for Bluetooth and these have UUIDs which are 16 bits in length. Some Attributes are custom designed for a particular device by the product team and these have 128 bit UUIDs.

#### Structure

Services, Characteristics and Descriptors are organised in a hierarchy with Services at the top and Descriptors at the bottom. Services contain one or more Characteristics. A Characteristic owns zero or more Descriptors because Descriptors are completely optional whereas a Service must contain at least one Characteristic.

#### Services

A Service is a container for logically related Bluetooth data items. Those data items are in fact called Characteristics. A Service can be thought of as the owner of the Characteristics inside it. Often a Service represents a particular feature (e.g. a hardware feature) of a device like the buttons or a particular sensor. An example of a Bluetooth SIG defined Service is the Device Information Service which, as the name suggests, is a container for various items of information about the device such as its manufacturer and serial number.

#### Characteristics

Characteristics are items of data which relate to a particular internal state of the device or perhaps some state of the environment which the device can measure using a sensor. The current battery level is an example of internal state data whereas the ambient temperature could perhaps be measured by a sensor. Sometimes Characteristics represent configuration data such as the frequency at which you want something to be measured. In any of these cases, the way a device can expose such data to other devices to use via Bluetooth is by making them available as a Characteristic. An example of a Bluetooth SIG defined Characteristic is the Serial Number String which you’ll find inside the Device Information service.

Characteristics contain various parts. They have a type, a value, some properties and some permissions.

Type is something already explained above, a UUID value which indicates which particular type of Characteristic an Attribute is. Value is the value of the associated state data item.

Properties define what another device can do with the characteristic over Bluetooth in terms of various defined operations such as READ, WRITE or NOTIFY. Reading a characteristic means transferring its current value from the attribute table to the connected device over Bluetooth. Writing allows the connected device to change that value in the state table. Notifications are a special message type which a device can send to a connected device whenever the value of the associated characteristic changes or perhaps periodically, controlled by a timer. Not all Characteristics support all operations. The Characteristic’s properties tell you which operations are supported.

Sometimes the device will have been programmed to respond in a special way when it processes an operation like reading or writing a value from the attribute table so operations can result in more happening than simply transferring data across the connection. Perhaps changing the value of a Characteristic will result in the device changing the frequency with which it samples readings from the device accelerometer for example.

Permissions are to do with security and further describe the security conditions that must be met before read or write access to the characteristic is to be granted.

## Generic text for testing CSS styles

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus pulvinar finibus ipsum, vitae mattis neque elementum nec. Cras vel lacinia diam, a porttitor nisl. Sed ullamcorper convallis bibendum. Ut id lectus risus. Morbi aliquam eros condimentum volutpat pretium. Praesent malesuada congue eros, vitae mollis erat laoreet nec. Quisque porta tempus turpis a mollis. Nulla at mollis sem, at scelerisque velit. Mauris non ex lectus. Morbi eget erat interdum lacus pretium vehicula vitae ac justo. Quisque vulputate interdum semper. Duis dignissim porta magna, vel faucibus leo pulvinar at. Donec nibh purus, vestibulum vel velit a, ultricies volutpat ipsum.

<img src="/files/bci/spike-waves.png">

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus pulvinar finibus ipsum, vitae mattis neque elementum nec. Cras vel lacinia diam, a porttitor nisl. Sed ullamcorper convallis bibendum. Ut id lectus risus. Morbi aliquam eros condimentum volutpat pretium. Praesent malesuada congue eros, vitae mollis erat laoreet nec. Quisque porta tempus turpis a mollis. Nulla at mollis sem, at scelerisque velit. Mauris non ex lectus. Morbi eget erat interdum lacus pretium vehicula vitae ac justo. Quisque vulputate interdum semper. Duis dignissim porta magna, vel faucibus leo pulvinar at. Donec nibh purus, vestibulum vel velit a, ultricies volutpat ipsum.

<img src="http://satyr.io/1100x300/eee" class="large">

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus pulvinar finibus ipsum, vitae mattis neque elementum nec. Cras vel lacinia diam, a porttitor nisl. Sed ullamcorper convallis bibendum. Ut id lectus risus. Morbi aliquam eros condimentum volutpat pretium. Praesent malesuada congue eros, vitae mollis erat laoreet nec. Quisque porta tempus turpis a mollis. Nulla at mollis sem, at scelerisque velit. Mauris non ex lectus. Morbi eget erat interdum lacus pretium vehicula vitae ac justo. Quisque vulputate interdum semper. Duis dignissim porta magna, vel faucibus leo pulvinar at. Donec nibh purus, vestibulum vel velit a, ultricies volutpat ipsum.


## Resources

- https://www.bluetooth.com/blog/a-developers-guide-to-bluetooth/