-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathHAPAccessorySetup.h
119 lines (102 loc) · 3.19 KB
/
HAPAccessorySetup.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
// 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_ACCESSORY_SETUP_H
#define HAP_ACCESSORY_SETUP_H
#ifdef __cplusplus
extern "C" {
#endif
#include "HAP+Internal.h"
#if __has_feature(nullability)
#pragma clang assume_nonnull begin
#endif
/**
* Checks whether a string represents a valid setup code.
*
* @param stringValue Value to check. NULL-terminated.
*
* @return true If the string is a valid setup code.
* @return false Otherwise.
*/
HAP_RESULT_USE_CHECK
bool HAPAccessorySetupIsValidSetupCode(const char* stringValue);
/**
* Generates a random setup code.
*
* @param[out] setupCode Setup code.
*/
void HAPAccessorySetupGenerateRandomSetupCode(HAPSetupCode* setupCode);
/**
* Checks whether a string represents a valid setup ID.
*
* @param stringValue Value to check. NULL-terminated.
*
* @return true If the string is a valid setup ID.
* @return false Otherwise.
*/
HAP_RESULT_USE_CHECK
bool HAPAccessorySetupIsValidSetupID(const char* stringValue);
/**
* Generates a random setup ID.
*
* @param[out] setupID Setup ID.
*/
void HAPAccessorySetupGenerateRandomSetupID(HAPSetupID* setupID);
/**
* Setup payload flags.
*/
typedef struct {
/**
* Accessory is paired with a controller.
* (only for accessories using programmable NFC tags to advertise the setup payload).
*
* If paired, no setup code or setup ID must be encoded.
*/
bool isPaired : 1;
/** Accessory supports HAP over IP transport; */
bool ipSupported : 1;
/** Accessory supports HAP over BLE transport. */
bool bleSupported : 1;
} HAPAccessorySetupSetupPayloadFlags;
/**
* Generates the setup payload for a given setup code and setup ID.
*
* @param[out] setupPayload Setup payload.
* @param setupCode Setup code.
* @param setupID Setup ID.
* @param flags Setup payload flags.
* @param category Accessory category.
*/
void HAPAccessorySetupGetSetupPayload(
HAPSetupPayload* setupPayload,
const HAPSetupCode* _Nullable setupCode,
const HAPSetupID* _Nullable setupID,
HAPAccessorySetupSetupPayloadFlags flags,
HAPAccessoryCategory category);
/**
* Setup hash.
*/
typedef struct {
uint8_t bytes[4]; /**< Value. */
} HAPAccessorySetupSetupHash;
HAP_STATIC_ASSERT(sizeof(HAPAccessorySetupSetupHash) == 4, HAPAccessorySetupSetupHash);
/**
* Derives the setup hash for a given setup ID and Device ID.
*
* @param[out] setupHash Setup hash.
* @param setupID Setup ID.
* @param deviceIDString Device ID.
*/
void HAPAccessorySetupGetSetupHash(
HAPAccessorySetupSetupHash* setupHash,
const HAPSetupID* setupID,
const HAPDeviceIDString* deviceIDString);
#if __has_feature(nullability)
#pragma clang assume_nonnull end
#endif
#ifdef __cplusplus
}
#endif
#endif