Skip to content

Commit

Permalink
Project import generated by Copybara.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 342369283
Change-Id: I1facd3a22d643edf4d1adce36c43ae37a07f4f32
  • Loading branch information
Local Home SDK team authored and vibgy committed Nov 14, 2020
1 parent cb99471 commit 0ff2f07
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 16 deletions.
2 changes: 0 additions & 2 deletions cloud.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ declare namespace smarthome {
* containing a list of device IDs to report state.
*
* See [[QueryHandler]] for more details.
* @hidden
*/
export type QueryRequest = CloudRequest<QueryRequestPayload>;

Expand Down Expand Up @@ -192,7 +191,6 @@ declare namespace smarthome {
/**
* Callback registered with the [[App]] via [[App.onQuery()]] to process
* requests for current device state.
* @hidden
*/
export interface QueryHandler extends
IntentHandler<QueryRequest, QueryResponse> {}
Expand Down
38 changes: 37 additions & 1 deletion cmd.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,16 @@ declare namespace smarthome {
/** HTTP response body */
body: unknown;
}

/** @hidden */
interface Template {}

/** @hidden Supported Cipher Suites */
type CipherSuites = 'EC-JPAKE';

/** @hidden */
interface TcpOptions {
/** @hidden @deprecated True to enable TLS for this request */
/** @hidden True to enable TLS for this request */
isSecure?: boolean;
/** Port number on the target device */
port: number;
Expand All @@ -74,6 +81,10 @@ declare namespace smarthome {
hostname?: string;
/** For read requests, number of expected bytes */
bytesToRead?: number;
/** @hidden Cipher suite to be used for TLS */
cipher?: CipherSuites;
/** @hidden Short code needed with EC-JPAKE */
shortCode?: string;
}
/** Content of a TCP response */
interface TcpResponse {
Expand Down Expand Up @@ -109,6 +120,8 @@ declare namespace smarthome {
interface Command extends CommandBase {
/** Payload sent to the target device */
data: string;
/** @hidden Experimental feature, to apply template parameters to data */
template?: Template;
}

interface HttpRequestData extends Command, HttpOptions {}
Expand Down Expand Up @@ -279,4 +292,27 @@ declare namespace smarthome {
debugString?: string;
}
}

/**
* Options for [[DeviceManager.send]] API.
* Use `send(command, {commandTimeout: 1000});` to wait for the platform to
* respond with success or timeout after 1000ms.
* Use `send(command, {retries: 2, delayInMilliseconds: 20});` to retry a
* command 2 times with 20ms delay between each retry.
*/
export interface SendOptions {
/**
* Waits for command response for upto `commandTimeout` ms but no less than
* 1000ms. Usage outside execute handler is not recommended. In addition, it
* should be used only when platform provided timeouts are not enough.
*/
commandTimeout?: number;
/**
* Retries the command upto `retries` times upto 3 times. `commandTimeout`
* applies to each command. Each retry will also get the timeout.
*/
retries?: number;
/** Delay in ms between each retry. Default is no-delay between commands. */
delayInMilliseconds?: number;
}
}
44 changes: 36 additions & 8 deletions execution-only.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
*/
declare namespace smarthome {
export namespace IntentFlow {
/** @hidden */
interface ScanData {
/** Contains data if this result came from an mDNS scan. */
mdnsScanData?: MdnsScanData;
/** Contains data if this result came from a UDP scan. */
udpScanData?: UdpScanData;
/** Contains data if this result came from a UPnP scan. */
upnpScanData?: UpnpScanData;
}

/**
* Results provided from a device scan on the local network.
* @hidden
Expand Down Expand Up @@ -53,6 +63,11 @@ declare namespace smarthome {
* local fulfillment. For more details, see the [[IdentifyHandler]].
*/
IDENTIFY = 'action.devices.IDENTIFY',
/**
* Fetch the state of the device.
* For more details, see the [[QueryHandler]].
*/
QUERY = 'action.devices.QUERY',
/**
* Report additional devices connected through a local proxy or hub.
* For more details, see the [[ReachableDevicesHandler]].
Expand Down Expand Up @@ -81,15 +96,15 @@ declare namespace smarthome {
}

/** Generic Intent request. Used in API signatures that accept any intent. */
export type IntentRequest = IntentFlow.ExecuteRequest|
IntentFlow.IdentifyRequest|
IntentFlow.ReachableDevicesRequest;
export type IntentRequest =
IntentFlow.ExecuteRequest|IntentFlow.IdentifyRequest|
IntentFlow.QueryRequest|IntentFlow.ReachableDevicesRequest;


/** Generic Intent response. Used in API signatures that accept any intent. */
export type IntentResponse = IntentFlow.ExecuteResponse|
IntentFlow.IdentifyResponse|
IntentFlow.ReachableDevicesResponse;
export type IntentResponse =
IntentFlow.ExecuteResponse|IntentFlow.IdentifyResponse|
IntentFlow.QueryResponse|IntentFlow.ReachableDevicesResponse;

/**
* This class provides access to the devices managed by the local home
Expand Down Expand Up @@ -119,24 +134,32 @@ declare namespace smarthome {
* See also [[HttpRequestData]], [[TcpRequestData]], [[UdpRequestData]]
*
* @param command Command to communicate with the device.
* @param sendOptions Options for `send` API. See [[SendOptions]].
* @return Promise that resolves to [[DataFlow.CommandSuccess]]
*/
send(command: DataFlow.CommandRequest): Promise<DataFlow.CommandSuccess>;
send(command: DataFlow.CommandRequest, sendOptions?: SendOptions):
Promise<DataFlow.CommandSuccess>;
/**
* `markPending` is called by the app when app is done handling an intent,
* but the actual operation (usually EXECUTE command) is still not done.
* This enables Google Home to respond back to the user in a timely fashion.
* This may be useful for somewhat long running operations. Returns a
* promise.
* @param request Original intent request that should be marked pending.
* @param response Pending response to the intent request.
*/
markPending(request: IntentRequest): Promise<void>;
markPending(request: IntentRequest, response?: IntentResponse):
Promise<void>;
/**
* `getProxyInfo` is called by app to get information about the hub / bridge
* controlling this end-device.
* @param id Device ID of end device that is being controlled by the hub.
*/
getProxyInfo(id: string): ProxyInfo;
/**
* Returns the list of registered devices.
*/
getRegisteredDevices(): IntentFlow.RegisteredDevice[];
}

/**
Expand Down Expand Up @@ -178,6 +201,11 @@ declare namespace smarthome {
* @param handler The handler that handles IDENTIFY intent.
*/
onIdentify(handler: IntentFlow.IdentifyHandler): this;
/**
* `onQuery` is called by app to attach the handler for QUERY intent.
* @param handler The handler that handles QUERY intent.
*/
onQuery(handler: IntentFlow.QueryHandler): this;
/**
* `onReachableDevices` is called by app to attach the handler for
* REACHABLE_DEVICES intent.
Expand Down
11 changes: 6 additions & 5 deletions generic.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ declare namespace smarthome {
/** True if this device publishes state updates in real time */
willReportState: boolean;
}
/**
* @hidden
*/
interface DeviceMap {
/** @hidden */
interface RegisteredDevice {
id: string;
customData?: unknown;
radioType?: Constants.RadioType;
scanData?: IntentFlow.ScanData;
}
/**
* @hidden Generic intent request interface.
Expand Down Expand Up @@ -150,7 +150,8 @@ declare namespace smarthome {
interface RequestInterface<D, T = {}> {
requestId: string;
inputs: Array<Input<D, T>>;
devices: DeviceMap[];
/** @deprecated use [[DeviceManager.getRegisteredDevices]] */
devices: RegisteredDevice[];
}
/**
* @hidden Generic intent response interface.
Expand Down
19 changes: 19 additions & 0 deletions intentflow.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ declare namespace smarthome {
* @preferred
*/
export namespace IntentFlow {
/**
* Describes the type of scannable code printed on the device, will be used
* by the GHA to know how to decode the scanned code.
* @hidden
*/
type ScanMode = 'QR_CODE'|'BAR_CODE'|'ALPHA_NUMERIC_CODE';

// Placeholder interface. Actual implementation depends on integration.
interface DeviceScanData {}

Expand Down Expand Up @@ -131,6 +138,18 @@ declare namespace smarthome {
* @hidden
*/
canBeUnprovisionedOverProxy?: boolean;

/**
* Describes the type of scannable code printed on the device.
* @hidden
*/
scanMode?: ScanMode;
/**
* If true, the platform will periodically send QUERY intents for the
* expecting JS to report state.
* @hidden
*/
willReportStateViaPoll?: boolean;
};
}

Expand Down
2 changes: 2 additions & 0 deletions scan-data.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,7 @@ declare namespace smarthome {
*/
port: number;
}
/** @hidden Placeholder. Actual implementation depends on integration. */
interface ScanData {}
}
}

0 comments on commit 0ff2f07

Please sign in to comment.