1
1
# Optimising application for throughput and power consumption
2
2
3
- BLE devices are usually battery powered so performance might mean different things in different applications. You have
4
- to decide what is more important in yours - minimising power consumption on one or both sides of the communication or
5
- maximising throughput and/or latency. Some optimisation steps can in fact achieve both.
3
+ BLE (Bluetooth Low Energy) devices are usually battery powered so performance might mean different things in different
4
+ applications. You will need to decide what is more important in your application - minimising power consumption on one
5
+ or both sides of the communication or maximising throughput and/or latency. Some optimisation steps can in fact achieve
6
+ both.
6
7
7
8
This guide will discuss some trade-offs that should be considered and best practices that improve performance on all
8
9
fronts.
9
10
10
- ## Power consumtpion
11
+ ## Power consumption
11
12
12
13
Any radio activity will consume power. Depending on what the stack is doing you have to power the radio even when no
13
14
data is being sent. It is important to understand when radio is active.
14
15
15
16
### Connections
16
17
17
- The most intuitive power consumption rate to understand is when using connections. Each take turns sending and receiving
18
- packets at set interval.
18
+ The most intuitive power consumption rate to understand is when using connections. Each device will take turns sending
19
+ and receiving at set interval.
19
20
20
21
21
22
CENTRAL
@@ -37,22 +38,25 @@ packets at set interval.
37
38
38
39
39
40
To maintain a connection, regardless if there is data transfer to be transferred, the central needs to transmit and
40
- receive once very connection interval.
41
+ receive once every connection interval.
41
42
42
- The peripheral needs to receive and may transmit data if it has any. It may skip a number of these connection events
43
- set by ` slaveLatency ` . If it has no data to transmit empty packets are sent.
43
+ The peripheral needs to acknowledge connection events to the central. Data ready to be transmitted is sent in the
44
+ acknowledgement. To save power, if the peripheral has no data to transmit it may skip up to ` slaveLatency ` connection
45
+ events.
44
46
45
47
More power is consumed if there is data to be exchanged. The exchange can continue until the next connection event would
46
48
take place.
47
49
48
- It's worth considering if keeping the connection active is worth it. Connection in BLE is extremely fast and if you plan
49
- to only send a quick burst of data every minute it is better to connect and disconnect each time.
50
+ It's worth considering if keeping the connection active is worth it. Connection in BLE has little overhead and there are
51
+ some cases when it is better to connect and disconnect each time you want to send a burst of data if for example you
52
+ want to conserve power on one of the devices. This way only one side will have to run advertising/scanning all the time
53
+ while the power limited device can turn the transmitter on only when it needs to.
50
54
51
55
The cost of the connection is proportionate to the negotiable connection interval. This can be set during ` connect ` or
52
56
later through ` updateConnectionParameters ` . The lower the interval the more often radio is active. This is especially
53
57
important for the peripheral which needs to enable the radio to receive packets.
54
58
55
- This can be further helped through setting a high ` slaveLatency ` parameter. This allows the peripheral to skip
59
+ This can be further helped by setting a high ` slaveLatency ` parameter. This allows the peripheral to skip
56
60
connection events and save power not just by not sending any packets but by not even listening. This is not free for
57
61
central as it increases latency of data transmission from central to peripheral. Central may have to attempt sending
58
62
data multiple times before the peripheral accepts the transmission. The peripheral may send data at any connection event
@@ -62,6 +66,7 @@ as the central must listen after every transmission.
62
66
63
67
Power draw during advertising affected by:
64
68
- the advertising interval - lower interval uses more power,
69
+ - use of Coded PHY which uses more power for extended effective range,
65
70
- amount of data sent,
66
71
- number of channels used - each advertising event is sent by default to three channels which you can limit to 2 or 1,
67
72
- whether extended advertising is used - this will send additional packets on regular channels,
@@ -116,9 +121,9 @@ will only have to turn on the radio when the expected packet is due.
116
121
### Modulation schemes
117
122
118
123
Depending on controller support different modulation schemes are available in BLE through ` setPreferredPhys() ` and
119
- ` setPhy() ` . While the coded PHY will increase reliability in noisy environments and increase range 2M PHY will increase
120
- the throughput saving power ber bit. If both devices support it and the signal quality is good then this is recommended
121
- to be enabled.
124
+ ` setPhy() ` . While the coded PHY will increase reliability in noisy environments and increase range at the cost of
125
+ power consumption, 2M PHY will increase the throughput saving power ber bit. If both devices support it and the signal
126
+ quality is good then this is recommended to be enabled.
122
127
123
128
### Data length and ATT_MTU
124
129
@@ -144,7 +149,10 @@ retransmissions (this is only related to data length, ATT_MTU does not affect th
144
149
### ATT protocol
145
150
146
151
GATT client writes and GATT server updates come in two versions - with and without confirmation. Requiring confirmations
147
- limits the throughput severely so to maximise throughput you can move reliability up from the stack to your application.
152
+ limits the throughput severely so to maximise throughput you can move reliability up from the stack to your application.
153
+ Without confirmations more than a single Peripheral <=> Central data exchange can be made per connection. With
154
+ confirmations, the connection event ends when the peripheral replies as it needs to prepare the acknowledgement which
155
+ will be sent possibly in the next event.
148
156
149
157
### Packet timings
150
158
@@ -153,8 +161,9 @@ Advertising at maximum frequency and scanning continuously will speed up connect
153
161
will minimise latency and maximise number of connection events.
154
162
155
163
One key thing to consider when setting the connection interval low is that you are creating a boundary between which a
156
- sequence of packets must fit. This means that the last transfer must end before the next connection event starts. This
157
- dead time may become significant if the connection interval is short and packet length is long.
164
+ sequence of packets must fit. This means that the last transfer must end before the next connection event starts
165
+ (plus 150us of inter packet space). This dead time may become significant if the connection interval is short and packet
166
+ length is long.
158
167
159
168
The connection interval shouldn't be shorter than what your data requires in terms of latency.
160
169
0 commit comments