-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathHAPBLEAccessoryServer+Advertising.h
148 lines (133 loc) · 5.37 KB
/
HAPBLEAccessoryServer+Advertising.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
138
139
140
141
142
143
144
145
146
147
148
// 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_ACCESSORY_SERVER_ADVERTISING_H
#define HAP_BLE_ACCESSORY_SERVER_ADVERTISING_H
#ifdef __cplusplus
extern "C" {
#endif
#include "HAP+Internal.h"
#if __has_feature(nullability)
#pragma clang assume_nonnull begin
#endif
/**
* BLE: GSN state.
*/
typedef struct {
uint16_t gsn; /**< Global State Number. */
bool didIncrement : 1; /**< Whether GSN has been incremented in the current connect / disconnect cycle. */
} HAPBLEAccessoryServerGSN;
/**
* BLE: Fetches GSN state.
*
* @param keyValueStore Key-value store
* @param[out] gsn GSN.
*
* @return kHAPError_None If successful.
* @return kHAPError_Unknown If an I/O error occurred.
*/
HAP_RESULT_USE_CHECK
HAPError HAPBLEAccessoryServerGetGSN(HAPPlatformKeyValueStoreRef keyValueStore, HAPBLEAccessoryServerGSN* gsn);
/**
* BLE: Get advertisement parameters.
*
* @param server Accessory server.
* @param[out] isActive True if advertisement should be active, False otherwise.
* @param[out] advertisingInterval Advertising interval in milliseconds, if active.
* @param[out] advertisingBytes Advertising data, if active.
* @param maxAdvertisingBytes Capacity of advertising data buffer. Must be at least 31.
* @param[out] numAdvertisingBytes Effective length of advertising data buffer, if active.
* @param[out] scanResponseBytes Scan response data, if active.
* @param maxScanResponseBytes Capacity of scan response data buffer. Should be >= 2.
* @param numScanResponseBytes Effective length of scan response data buffer, or 0, if not applicable, if active.
*
* @return kHAPError_None If successful.
* @return kHAPError_Unknown If an I/O error occurred.
*/
HAP_RESULT_USE_CHECK
HAPError HAPBLEAccessoryServerGetAdvertisingParameters(
HAPAccessoryServerRef* server,
bool* isActive,
uint16_t* advertisingInterval,
void* advertisingBytes,
size_t maxAdvertisingBytes,
size_t* numAdvertisingBytes,
void* scanResponseBytes,
size_t maxScanResponseBytes,
size_t* numScanResponseBytes)
HAP_DIAGNOSE_ERROR(maxAdvertisingBytes < 31, "maxAdvertisingBytes must be at least 31")
HAP_DIAGNOSE_WARNING(maxScanResponseBytes < 2, "maxScanResponseBytes should be at least 2");
/**
* BLE: Informs the accessory server that advertising has started.
*
* @param server Accessory server.
*/
void HAPBLEAccessoryServerDidStartAdvertising(HAPAccessoryServerRef* server);
/**
* BLE: Informs the accessory server that a controller has connected.
*
* @param server Accessory server.
*
* @return kHAPError_None If successful.
* @return kHAPError_InvalidState If a controller is already connected. Only 1 concurrent connection is allowed.
* @return kHAPError_Unknown If an I/O error occurred.
*/
HAP_RESULT_USE_CHECK
HAPError HAPBLEAccessoryServerDidConnect(HAPAccessoryServerRef* server);
/**
* BLE: Informs the accessory server that a controller has disconnected.
*
* @param server Accessory server.
*
* @return kHAPError_None If successful.
* @return kHAPError_InvalidState If no controller is connected.
* @return kHAPError_Unknown If an I/O error occurred.
*/
HAP_RESULT_USE_CHECK
HAPError HAPBLEAccessoryServerDidDisconnect(HAPAccessoryServerRef* server);
/**
* BLE: Informs the accessory server that the value of a characteristic did change.
*
* @param server Accessory server.
* @param characteristic The characteristic whose value has changed.
* @param service The service that contains the characteristic.
* @param accessory The accessory that provides the service.
* @param session The session on which to raise the event.
*
* @return kHAPError_None If successful.
* @return kHAPError_Unknown If an I/O error occurred.
*/
HAP_RESULT_USE_CHECK
HAPError HAPBLEAccessoryServerDidRaiseEvent(
HAPAccessoryServerRef* server,
const HAPCharacteristic* characteristic,
const HAPService* service,
const HAPAccessory* accessory,
HAPSessionRef* _Nullable session);
/**
* BLE: Informs the accessory server that the value of a characteristic which is registered for Bluetooth LE
* indications changed.
*
* @param server Accessory server.
* @param characteristic The characteristic whose value has changed.
* @param service The service that contains the characteristic.
* @param accessory The accessory that provides the service.
*
* @return kHAPError_None If successful.
* @return kHAPError_Unknown If an I/O error occurred.
*/
HAP_RESULT_USE_CHECK
HAPError HAPBLEAccessoryServerDidSendEventNotification(
HAPAccessoryServerRef* server,
const HAPCharacteristic* characteristic,
const HAPService* service,
const HAPAccessory* accessory);
#if __has_feature(nullability)
#pragma clang assume_nonnull end
#endif
#ifdef __cplusplus
}
#endif
#endif