-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathHAPIPAccessory.h
99 lines (84 loc) · 2.67 KB
/
HAPIPAccessory.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
// 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_IP_ACCESSORY_H
#define HAP_IP_ACCESSORY_H
#ifdef __cplusplus
extern "C" {
#endif
#include "HAP+Internal.h"
#if __has_feature(nullability)
#pragma clang assume_nonnull begin
#endif
/**
* Serialization context for incremental attribute database serialization.
*/
typedef struct {
/**
* Serialization state
*/
uint8_t state;
/**
* Generic array enumeration index.
*/
uint8_t index;
/**
* Accessory index. 0 => primaryAccessory, > 0 => bridgedAccessories[accessoryIndex - 1]
*/
uint8_t accessoryIndex;
/**
* Service index.
*/
uint8_t serviceIndex;
/**
* Characteristic index.
*/
uint8_t characteristicIndex;
} HAPIPAccessorySerializationContext;
/**
* Creates a new serialization context.
*
* @param context An serialization context.
*/
void HAPIPAccessoryCreateSerializationContext(HAPIPAccessorySerializationContext* context);
/**
* Returns whether the incremental response serialization for the given serialization context is complete.
*
* @param context Serialization context.
*
* @return Whether the serialization is complete.
*/
HAP_RESULT_USE_CHECK
bool HAPIPAccessorySerializationIsComplete(HAPIPAccessorySerializationContext* context);
/**
* Incrementally serializes a GET /accessories response.
*
* @param context Serialization context to incrementally serialize the response.
* @param server Accessory server.
* @param session IP session descriptor.
* @param[out] bytes Buffer to fill.
* @param minBytes Minimum number of bytes to serialize, until the response is complete.
* @param maxBytes Maximum number of bytes to serialize in a single invocation of this function.
* @param numBytes Number of bytes serialized.
*
* @return kHAPError_None If successful.
* @return kHAPError_OutOfResources If the supplied buffer is not large enough.
*/
HAP_RESULT_USE_CHECK
HAPError HAPIPAccessorySerializeReadResponse(
HAPIPAccessorySerializationContext* context,
HAPAccessoryServerRef* server,
HAPIPSessionDescriptorRef* session,
char* bytes,
size_t minBytes,
size_t maxBytes,
size_t* numBytes);
#if __has_feature(nullability)
#pragma clang assume_nonnull end
#endif
#ifdef __cplusplus
}
#endif
#endif