-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathscan-data.d.ts
146 lines (143 loc) · 5.01 KB
/
scan-data.d.ts
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
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Minimum TypeScript Version: 3.0
/** Declares interface to represent scan data that gets send in IDENTIFY. */
declare namespace smarthome {
namespace IntentFlow {
interface BleScanData {
name: string;
flags: string;
serviceUuids: string[];
manufacturerData: Map<string, string>;
typeToData: Array<Map<string, string>>;
macAddress?: string;
}
/**
* Data payload returned with an mDNS scan result.
* For mDNS discovery, the scan data contains fields from the SRV and TXT
* records advertised by the local device via
* [DNS-Based Service Discovery
* (DNS-SD)](https://tools.ietf.org/html/rfc6763).
*
* ```typescript
* const identifyHandler = (request: IntentFlow.IdentifyRequest):
* Promise<IntentFlow.IdentifyResponse> => {
*
* // Obtain scan data from protocol defined in your scan config
* const device = request.inputs[0].payload.device;
* const scanData = device.mdnsScanData;
*
* // TXT key/value pairs for this device
* // Extract application-specific parameters
* const localDeviceId = scanData.txt.myParameter;
* ...
* };
* ```
*
*/
interface MdnsScanData {
/** Fully qualified name of the discovered service. */
serviceName: string;
/** Instance name of the service. */
name: string;
/** Type of the service. */
type: string;
/** Protocol used by the service. Typically either `tcp` or `udp`. */
protocol: string;
/** Raw additional TXT data advertised by the service. */
data: string[];
/** Key/value pairs advertised in the TXT data of the service. */
txt: {[key: string]: string};
}
/**
* Data payload returned with a UDP scan result.
* For UDP discovery, the scan data contains the hex-encoded packet
* provided by the local device in response to the UDP discovery broadcast.
*
* ```typescript
* const identifyHandler = (request: IntentFlow.IdentifyRequest):
* Promise<IntentFlow.IdentifyResponse> => {
*
* // Obtain scan data from protocol defined in your scan config
* const device = request.inputs[0].payload.device;
* const scanData = device.udpScanData;
*
* // data field is the hex-encoded UDP response packet
* const localDeviceId = Buffer.from(scanData.data, 'hex');
* ...
* };
* ```
*
*/
interface UdpScanData {
/** Hex-encoded response packet received from the device. */
data: string;
}
/**
* Data payload returned with a UPnP scan result. For UPnP discovery,
* the platform initiates an `M-SEARCH` request according to
* [Simple Service Discovery Protocol
* (SSDP)](https://en.wikipedia.org/wiki/Simple_Service_Discovery_Protocol)
* and returns devices or services matching your scan configuration.
* The scan data contains the search response from the local device.
*
* ```typescript
* const identifyHandler = (request: IntentFlow.IdentifyRequest):
* Promise<IntentFlow.IdentifyResponse> => {
*
* // Obtain scan data from protocol defined in your scan config
* const device = request.inputs[0].payload.device;
* const scanData = device.upnpScanData;
*
* // UUID advertised by the device over UPnP
* const localDeviceId = scanData.deviceId;
*
* // Path to the UPnP device description
* const deviceDescription = scanData.location;
* ...
* };
* ```
*
*/
interface UpnpScanData {
/**
* Path component of the URL returned in the `LOCATION` header.
*/
location: string;
/**
* UUID provided in the `USN` field of the search response.
*/
deviceId: string;
/**
* Device type provided in the `ST` field of the search response.
* Present only if the search request includes a device type.
*/
deviceType?: string;
/**
* Service type provided in the `ST` field of the search response.
* Present only if the search request includes a service type.
*/
serviceType?: string;
/**
* Port component of the URL returned in the `LOCATION` header.
*/
port: number;
}
/** @hidden Placeholder. Actual implementation depends on integration. */
interface ScanData {}
}
}