-
Notifications
You must be signed in to change notification settings - Fork 3
/
ios-sdk-api-reference-070.html
445 lines (305 loc) · 19.4 KB
/
ios-sdk-api-reference-070.html
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css?2" media="screen">
<link rel="stylesheet" type="text/css" href="stylesheets/github-dark.css" media="screen">
<link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<title>Empatica iOS SDK API Reference</title>
<meta name="description" content="Develop your mobile application using the Empatica SDK for iOS.">
<!-- Favicon -->
<link rel="icon" href="//static-content1.empatica.com/YaJqf/img/favicon.png" type="image/png">
<link rel="apple-touch-icon" href="//static-content1.empatica.com/YaJqf/img/favicon.png">
<link href="//static-content1.empatica.com/YaJqf/img/favicon.png" rel="shortcut icon" type="image/x-icon">
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-25632719-2', 'auto');
ga('require', 'linkid', 'linkid.js');
ga('require', 'displayfeatures');
ga('send', 'pageview');
</script>
</head>
</head>
<body>
<div id="container">
<div class="inner">
<header>
<p><a href="/">E4 for Developers</a> > EmpaLink iOS SDK • API Reference</p>
<h1>EmpaLink iOS SDK</h1>
<h2>API Reference</h2>
</header>
<section id="main_content">
<p>EmpaLink is a library that allows to:</p>
<ul>
<li>Connect to and manage one or more Empatica E4 devices via Bluetooth Low Energy (BLE)</li>
<li>Receive realtime raw data from the connected devices, such as Galvanic Skin Response (GSR), Blood Volume Pulse (BVP), and accelerometers</li>
<li>Receive computed data derived from raw data, such as interbeat intervals (IBI)</li>
</ul>
<p><a href="#EmpaticaAPI">EmpaticaAPI</a> is the main singleton class that handles API authentication and devices discovery. <a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a> is the class that handles the connection the communication with a single E4 device.</p>
<h2><a class="paddedLink" id="EmpaticaAPI"></a> EmpaticaAPI Class</h2>
<p><strong>Authentication</strong></p>
<p>
<a href="#authenticateWithAPIKey:completionHandler:">+ authenticateWithAPIKey:completionHandler:</a><br/>
</p>
<p><strong>Device discovery</strong></p>
<p>
<a href="#discoverDevicesWithDelegate:">+ discoverDevicesWithDelegate:</a><br/>
</p>
<p><strong>Background communication handling</strong></p>
<p>
<a href="#prepareForBackground">+ prepareForBackground</a><br/>
<a href="#prepareForResume">+ prepareForResume</a><br/>
</p>
<p><strong>EmpaticaDelegate</strong></p>
<p>
<a href="#didUpdateBLEStatus:">- didUpdateBLEStatus:</a><br/>
<a href="#didDiscoverDevices:">- didDiscoverDevices:</a><br/>
<a href="#BLEStatus">BLEStatus</a><br/>
</p>
<h2>Class Methods</h2>
<h3><a class="paddedLink" id="authenticateWithAPIKey:completionHandler:"></a> authenticateWithAPIKey:completionHandler:</h3>
<p>Authenticate the user with the given API key.<br />
+ (void)authenticateWithAPIKey:(NSString *)key completionHandler:(void (^)(BOOL success, NSString *description))handler;</p>
<h4>Discussion</h4>
<p><strong> It is mandatory to call this method before using the EmpaLink API. </strong> If the key is not set or it results invalid, the connection to an E4 device will not be available and an exception will be raised at discovery time. It is recommended to call the method in the app delegate. The completion handler allows you to understand if authentication succeeded (and you can start invoking the API methods) or failed (the <code>description</code> argument will help you understand why).</p>
<pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[EmpaticaAPI authenticateWithAPIKey:@"HERE_GOES_YOUR_API_KEY" completionHandler:^(BOOL success, NSString *description) {
// Handle success/failure
}];
return YES;
}
</code></pre>
<h3><a class="paddedLink" id="discoverDevicesWithDelegate:"></a> discoverDevicesWithDelegate:</h3>
<p>Ask the BLE manager to scan for Empatica E4 devices.<br/>
+ (void)discoverDevicesWithDelegate:(id<EmpaticaDelegate>) <em>empaticaDelegate</em></p>
<h4>Parameters</h4>
<p><em>empaticaDelegate</em><br/>
The object implementing EmpaticaDelegate that will receive notifications about discovered devices and BLE manager status.</p>
<h5>Discussion</h5>
<p>During the scan, the BLE status is set to <a href="#BLEStatus">kBLEStatusScanning</a>.<br/>
After a successful scan, the BLE status is set to <a href="#BLEStatus">kBLEStatusReady</a> and the list of peripherals is notified to the empaticaDelegate with a call to <a href="#didDiscoverDevices::">didDiscoverDevices:</a>. If no devices are available, <a href="#didDiscoverDevices::">didDiscoverDevices:</a> will be called with an empty array of devices.<br/>
</p>
<h3><a class="paddedLink" id="prepareForBackground"></a> prepareForBackground</h3>
<p>Ask the BLE manager to optimize the transmission for background activity.<br/>
+ (void)prepareForBackground</p>
<h4>Discussion</h4>
<p><strong>It is mandatory to implement this method in the app delegate.</strong> If not implemented, an exception will be raised at discovery time.</p>
<pre><code>- (void)applicationDidEnterBackground:(UIApplication *)application {
[[EmpaticaAPI sharedInstance] prepareForBackground];
}
</code></pre>
<h3><a class="paddedLink" id="prepareForResume"></a> prepareForResume</h3>
<p>Ask the BLE manager to resume the normal transmission for foreground activity.<br/>
+ (void) prepareForResume</p>
<h4>Discussion</h4>
<p><strong>It is mandatory to implement this method in the app delegate.</strong> If not implemented, an exception will be raised at discovery time.</p>
<pre><code>- (void)applicationDidBecomeActive:(UIApplication *)application {
[[EmpaticaAPI sharedInstance] prepareForResume];
}
</code></pre>
<h2><a class="paddedLink" id="EmpaticaDelegate"></a> EmpaticaDelegate Protocol</h2>
<h3><a class="paddedLink" id="didDiscoverDevices:"></a>didDiscoverDevices:</h3>
<p>- (void) didDiscoverDevices:(NSArray*)<em>devices</em></p>
<h4>Parameters</h4>
<p><em>devices</em><br/>
The list of discovered devices.
<br/>
</p>
<h3><a class="paddedLink" id="didUpdateBLEStatus:"></a> didUpdateBLEStatus:</h3>
<p> Notify when the <em>status</em> property of the BLE manager changes.
</p>
<p>- (void)didUpdateBLEStatus:(<a href="#BLEStatus">BLEStatus</a>)<em>status</em></p>
<h4>Parameters</h4>
<p><em>status</em><br/>
The current status of the BLE manager
<br/></p>
<h3><a class="paddedLink" id="BLEStatus"></a> BLEStatus</h3>
<p>Defines the possible status of the BLE manager.</p>
<pre><code>typedef enum {
kBLEStatusNotAvailable,
kBLEStatusReady,
kBLEStatusScanning
} BLEStatus;
</code></pre>
<h4>Constants</h4>
<p><em>kBLEStatusNotAvailable</em><br/>
The iOS device does not support Bluetooth LE, or the Bluetooth LE module is not active.<br/>
<em>kBLEStatusReady</em><br/>
The BLE central manager is ready to scan for devices.<br/>
<em>kBLEStatusScanning</em><br/>
The BLE central manager is scanning for E4 devices.<br/>
<h2><a class="paddedLink" id="EmpaticaDeviceManager"></a> EmpaticaDeviceManager Class</h2>
<p><strong>Device Connection</strong></p>
<p>
<a href="#connectWithDeviceDelegate:">- connectWithDeviceDelegate:</a><br/>
<a href="#connectWithDeviceDelegate:andConnectionOptions:">- connectWithDeviceDelegate:andConnectionOptions:</a><br/>
</p>
<p><strong>Device Disconnection</strong></p>
<p>
<a href="#disconnect">- disconnect</a><br/>
</p>
<p><strong>EmpaticaDeviceDelegate</strong></p>
<p>
<a href="#didReceiveTagAtTimestamp:">- didReceiveTagAtTimestamp:fromDevice:</a><br/>
<a href="#didReceiveIBI:withTimestamp:">- didReceiveIBI:withTimestamp:fromDevice:</a><br/>
<a href="#didReceiveGSR:withTimestamp:">- didReceiveGSR:withTimestamp:fromDevice:</a><br/>
<a href="#didReceiveBVP:withTimestamp:">- didReceiveBVP:withTimestamp:fromDevice:</a><br/>
<a href="#didReceiveTemperature:withTimestamp:">- didReceiveTemperature:withTimestamp:fromDevice:</a><br/>
<a href="#didReceiveAccelerationX:y:z:withTimestamp:">- didReceiveAccelerationX:y:z:withTimestamp:fromDevice:</a><br/>
<a href="#didReceiveBatteryLevel:withTimestamp:">- didReceiveBatteryLevel:withTimestamp:fromDevice:</a><br/>
<a href="#didUpdateDeviceStatus:">- didUpdateDeviceStatus:forDevice:</a><br/>
<a href="#DeviceStatus">DeviceStatus</a><br/></p>
<h2>Instance Methods</h2>
<h3><a class="paddedLink" id="connectWithDeviceDelegate:"></a> connectWithDeviceDelegate:</h3>
<p>Ask the device manager to estabilish a connection to the corresponding E4 device.<br/>
- (void) connectWithDeviceDelegate:(id<EmpaticaDeviceDelegate>)<em>deviceDelegate</em>;
</p>
<h4>Parameters</h4>
<p><em>deviceDelegate</em><br/>
The object implementing <a href="#EmpaticaDeviceDelegate">EmpaticaDeviceDelegate</a> that will receive data from the connected device and notifications about the connection status of the device.</p>
<h4>Discussion</h4>
<p>During the connection attempt, the device manager status is set to <a href="#DeviceStatus">kDeviceStatusConnecting</a>. <br/>
After a successful connection, the device manager status is set to <a href="#DeviceStatus">kDeviceStatusConnected</a>. <br/>
If the connection fails, the device manager status is set to <a href="#DeviceStatus">kDeviceStatusDisconnected</a>. <br/>
<p>When connecting to multiple devices, it is recommended to instantiate, for each device, one object implementing the <a href="#EmpaticaDeviceDelegate">EmpaticaDeviceDelegate</a> protocol.</p>
<br/>
</p>
<h3><a class="paddedLink" id="connectWithDeviceDelegate:andConnectionOptions:"></a> connectWithDeviceDelegate:andConnectionOptions:</h3>
<p>This method is reserved for future implementation.</p>
</p>
<h3><a class="paddedLink" id="disconnect"></a> disconnect</h3>
<p>Ask the device manager to disconnect to the currently connected device. It has no effect if no device is connected.<br/>
- (void) disconnect</p>
<h4>Discussion</h4>
<p>After a successful disconnection, the device manager status is set to <a href="#DeviceStatus">kDeviceStatusDisconnected</a>.<br/>
</p>
<h2><a class="paddedLink" id="EmpaticaDeviceDelegate"></a> EmpaticaDeviceDelegate Protocol</h2>
<h3><a class="paddedLink" id="didReceiveTagAtTimestamp:"></a> didReceiveTagAtTimestamp:fromDevice:</h3>
<p>Receives a Tag notification when the button on the E4 is pressed at a given timestamp.</p>
<p>-(void)didReceiveTagAtTimestamp:(double) <em>timestamp</em> fromDevice:(<a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a>*) <em>device</em></p>
<h4>Parameters</h4>
<p><em>ibi</em><br/>
The timestamp of the button press in seconds defined as time interval between the button press and the reference date, 1 January 1970, GMT.
<em>device</em><br/>
The device of type <a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a> that acquired the sample.<br /></p>
<h4>Discussion</h4>
<p>Tags are available with latest version of E4 firmware.
<br/>
</p>
<h3><a class="paddedLink" id="didReceiveIBI:withTimestamp:"></a> didReceiveIBI:withTimestamp:fromDevice:</h3>
<p>Receives an Inter Beat Interval (IBI) sample detected at the given timestamp.</p>
<p>-(void)didReceiveIBI:(float) <em>ibi</em> withTimestamp:(double) <em>timestamp</em> fromDevice:(<a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a>*) <em>device</em></p>
<h5>Parameters</h5>
<p><em>ibi</em><br/>
The value of the IBI sample. The value is the distance from the previous detected heartbeat in seconds.<br/>
<em>timestamp</em><br/>
The timestamp for the IBI sample in seconds defined as time interval between the sample received and the reference date, 1 January 1970, GMT.
<em>device</em><br/>
The device of type <a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a> that acquired the sample.<br /></p>
<h4>Discussion</h4>
<p>IBIs are calculated in real time, using the latest samples of raw data from the optical sensor. An algorithm filters out data affected by movements. After an initialization period of about 20 seconds, IBIs are sent as soon as heart beats are detected.
<br/>
</p>
<h3><a class="paddedLink" id="didReceiveGSR:withTimestamp:"></a> didReceiveGSR:withTimestamp:fromDevice:</h3>
<p>Receives a GSR sample acquired at the given timestamp.</p>
<p>- (void) didReceiveGSR:(float) <em>gsr</em> withTimestamp:(double) <em>timestamp</em> fromDevice:(<a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a>*) <em>device</em></p>
<h5>Parameters</h5>
<p><em>gsr</em><br/>
The value of the GSR sample. The value is expressed in microsiemens.<br/>
<em>timestamp</em><br/>
The timestamp for the GSR sample in seconds defined as time interval between the sample received and the reference date, 1 January 1970, GMT.
<em>device</em><br/>
The device of type <a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a> that acquired the sample.<br /></p>
<h3><a class="paddedLink" id="didReceiveTemperature:withTimestamp:"></a> didReceiveTemperature:withTimestamp:fromDevice:</h3>
<p>Receives an temperature value acquired at the given timestamp.</p>
<p>- (void) didReceiveTemperature:(float) <em>temp</em> withTimestamp:(double) <em>timestamp</em> fromDevice:(<a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a>*) <em>device</em></p>
<h5>Parameters</h5>
<p><em>temp</em><br/>
The value of the temperature sample expressed in Celsius degree. The value is derived from the optical temperature sensor placed on the wrist.<br/>
<em>timestamp</em><br/>
The timestamp for the temperature sample in seconds defined as time interval between the sample received and the reference date, 1 January 1970, GMT.
<em>device</em><br/>
The device of type <a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a> that acquired the sample.<br /></p>
<h3><a class="paddedLink" id="didReceiveBVP:withTimestamp:"></a> didReceiveBVP:withTimestamp:fromDevice:</h3>
<p>Receives an IBI value acquired at the given timestamp.</p>
<p>- (void) didReceiveBVP:(float) <em>bvp</em> withTimestamp:(double) <em>timestamp</em> fromDevice:(<a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a>*) <em>device</em></p>
<h5>Parameters</h5>
<p><em>bvp</em><br/>
The value of the BVP sample. The value is derived from the light absorbance of the arterial blood. The raw signal is filtered to remove movement artifacts. <br/>
<em>timestamp</em><br/>
The timestamp for the BVP sample in seconds defined as time interval between the sample received and the reference date, 1 January 1970, GMT.
<em>device</em><br/>
The device of type <a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a> that acquired the sample.<br /></p>
<h3><a class="paddedLink" id="didReceiveAccelerationX:y:z:withTimestamp:"></a> didReceiveAccelerationX:y:z:withTimestamp:fromDevice:</h3>
<p>Receives an acceleration sample acquired at the given timestamp.</p>
<p>- (void) didReceiveAccelerationX:(char)<em>x</em> y:(char)<em>y</em> z:(char)<em>z</em> withTimestamp:(double)<em>timestamp</em> fromDevice:(<a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a>*) <em>device</em></p>
<h5>Parameters</h5>
<p><em>x</em><br/>
The acceleration value for x axis. The x axes is defined by the vector whose starting point is set to the center of the device and whose direction points towards the USB slot.<br/>
<em>y</em><br/>
The acceleration value for y axis. The y axes is defined by the vector whose starting point is set to the center of the device and whose direction points towards the shorter strap.<br/>
<em>z</em><br/>
The acceleration value for z axis. The x axes is defined by the vector whose starting point is set to the center of the device and whose direction points towards the bottom of the device.<br/>
<em>timestamp</em><br/>ƒ
The timestamp for the acceleration sample in seconds defined as time interval between the sample received and the reference date, 1 January 1970, GMT.
<em>device</em><br/>
The device of type <a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a> that acquired the sample.<br /></p>
<h4>Discussion</h4>
<p>The values of acceleration include the gravitational acceleration on each of the 3 axis. Accelerometer sensitivity is +-2g and values goes from -127 to +128 where -127 correspond to an acceleration of -2g and +128 correspond of an acceleration of to +2g.</p>
<h3><a class="paddedLink" id="didReceiveBatteryLevel:withTimestamp:"></a> didReceiveBatteryLevel:withTimestamp:fromDevice:</h3>
<p>- (void)didReceiveBatteryLevel :(float)<em>level</em> withTimestamp:(double)<em>timestamp</em> fromDevice:(<a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a>*) <em>device</em></p>
Notify when the <em>batteryLevel</em> property of the connected device changes.
<h5>Parameters</h5>
<p><em>level</em><br/>
The battery level of the device. Values: [0.0 - 1.0]<br/>
<em>timestamp</em><br/>
The timestamp for the battery sample in seconds defined as time interval between the sample received and the reference date, 1 January 1970, GMT.
<em>device</em><br/>
The device of type <a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a> that acquired the sample.<br /></p>
<h3><a class="paddedLink" id="didUpdateDeviceStatus:"></a> didUpdateDeviceStatus:forDevice:</h3>
<p> Notify when the <em>status</em> property of the connected device changes.
</p>
<p>- (void)didUpdateDeviceStatus:(<a href="#deviceStatus">DeviceStatus</a>)<em>status</em> forDevice:(<a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a>*) <em>device</em></p>
<h5>Parameters</h5>
<p><em>status</em><br/>
The current status of the device
<em>device</em><br/>
The device of type <a href="#EmpaticaDeviceManager">EmpaticaDeviceManager</a> that updated its status.<br /></p>
<h3><a class="paddedLink" id="DeviceStatus"></a> DeviceStatus</h3>
<p>Defines the possible status of the E4 device</p>
<pre><code>typedef enum {
kDeviceStatusDisconnected,
kDeviceStatusConnecting,
kDeviceStatusConnected,
kDeviceStatusDisconnecting
} DeviceStatus;
</code></pre>
<h4>Constants</h4>
<p><em>kDeviceStatusDisconnected</em><br/>
The E4 device is not connected.<br/>
<em>kDeviceStatusConnecting</em><br/>
A connection with the E4 device is in progress<br/>
<em>kDeviceStatusConnected</em><br/>
The E4 device is connected.<br/>
<em>kDeviceStatusDisconnecting</em><br/>
A disconnection with the E4 device is in progress.<br/>
</section>
<footer>
<p>Having trouble with Empatica developer`s software? <a href="mailto:[email protected]">Contact support</a> and we’ll help you sort it out.</p>
</footer>
</div>
</div>
</body>
</html>