-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathHAPBLESession.h
137 lines (120 loc) · 4.46 KB
/
HAPBLESession.h
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
// Copyright (c) 2015-2019 The HomeKit ADK Contributors
//
// Licensed under the Apache License, Version 2.0 (the “License”);
// you may not use this file except in compliance with the License.
// See [CONTRIBUTORS.md] for the list of HomeKit ADK project authors.
#ifndef HAP_BLE_SESSION_H
#define HAP_BLE_SESSION_H
#ifdef __cplusplus
extern "C" {
#endif
#include "HAP+Internal.h"
#if __has_feature(nullability)
#pragma clang assume_nonnull begin
#endif
/**
* Initialize BLE specific part of a session.
*
* @param server Accessory server.
* @param session Session of which the BLE specific part shall be initialized.
*/
void HAPBLESessionCreate(HAPAccessoryServerRef* server, HAPSessionRef* session);
/**
* Deinitializes BLE specific part of a session.
*
* @param bleSession BLE session.
*/
void HAPBLESessionRelease(HAPBLESession* bleSession);
/**
* Invalidates a BLE session.
*
* @param server Accessory server.
* @param bleSession BLE Session.
* @param terminateLink Whether or not the underlying connection should also be terminated.
*/
void HAPBLESessionInvalidate(HAPAccessoryServerRef* server, HAPBLESession* bleSession, bool terminateLink);
/**
* Returns whether the session is terminal soon and no new transactions should be started.
* This is to prevent ambiguities whether HAP-BLE transactions have been completed successfully, as the
* HAP specification does not define at which stage a transaction actually executes.
*
* - If this function is called in response to a GATT request, it is safe to disconnect immediately.
* Otherwise, recently written data may still be transmitting and one should wait until
* #HAPBLESessionIsSafeToDisconnect returns true.
*
* @param bleSession BLE session.
*
* @return true If session is terminal soon.
* @return false Otherwise.
*/
HAP_RESULT_USE_CHECK
bool HAPBLESessionIsTerminalSoon(const HAPBLESession* bleSession);
/**
* Returns whether the session is terminal and must be disconnected.
*
* - If this function is called in response to a GATT request, it is safe to disconnect immediately.
* Otherwise, recently written data may still be transmitting and one should wait until
* #HAPBLESessionIsSafeToDisconnect returns true.
*
* @param bleSession BLE session.
*
* @return true If session is terminal.
* @return false Otherwise.
*/
HAP_RESULT_USE_CHECK
bool HAPBLESessionIsTerminal(const HAPBLESession* bleSession);
/**
* Returns whether it is safe to disconnect the Bluetooth link.
*
* @param bleSession BLE session.
*
* @return true If it is safe to disconnect the Bluetooth link.
* @return false Otherwise. Data may still being sent.
*/
HAP_RESULT_USE_CHECK
bool HAPBLESessionIsSafeToDisconnect(const HAPBLESession* bleSession);
/**
* Handles a sent GATT response.
*
* @param server Accessory server.
* @param session Session.
*/
void HAPBLESessionDidSendGATTResponse(HAPAccessoryServerRef* server, HAPSessionRef* session);
/**
* Handles a started HAP-BLE procedure.
*
* @param server Accessory server.
* @param session Session.
*/
void HAPBLESessionDidStartBLEProcedure(HAPAccessoryServerRef* server, HAPSessionRef* session);
/**
* Handles a started pairing procedure (Pair Verify / Add Pairing / Remove Pairing / List Pairing).
* Pair Setup is not listed on purpose.
*
* @param server Accessory server.
* @param session Session.
* @param pairingProcedureType Pairing procedure type.
*/
void HAPBLESessionDidStartPairingProcedure(
HAPAccessoryServerRef* server,
HAPSessionRef* session,
HAPPairingProcedureType pairingProcedureType);
/**
* Handles a completed pairing procedure (Pair Verify / Add Pairing / Remove Pairing / List Pairing).
* Pair Setup is not listed on purpose.
*
* @param server Accessory server.
* @param session Session.
* @param pairingProcedureType Pairing procedure type.
*/
void HAPBLESessionDidCompletePairingProcedure(
HAPAccessoryServerRef* server,
HAPSessionRef* session,
HAPPairingProcedureType pairingProcedureType);
#if __has_feature(nullability)
#pragma clang assume_nonnull end
#endif
#ifdef __cplusplus
}
#endif
#endif