From a34dd00048d2abb8b3bec4948d1e1109ff85590e Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 29 Jan 2024 14:44:42 -0500 Subject: [PATCH 1/2] Add QR code scanner to external bus --- src/external_app/external_messaging.ts | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/external_app/external_messaging.ts b/src/external_app/external_messaging.ts index 3021aba742d7..bc5c05982c77 100644 --- a/src/external_app/external_messaging.ts +++ b/src/external_app/external_messaging.ts @@ -35,6 +35,13 @@ interface EMOutgoingMessageConfigGet extends EMMessage { type: "config/get"; } +interface EMOutgoingMessageScanQRCode extends EMMessage { + type: "qr_code/scan"; + title: string; + description: string; + alternative_option_label?: string; +} + interface EMOutgoingMessageMatterCommission extends EMMessage { type: "matter/commission"; } @@ -48,6 +55,13 @@ type EMOutgoingMessageWithAnswer = { request: EMOutgoingMessageConfigGet; response: ExternalConfig; }; + "qr_code/scan": { + request: EMOutgoingMessageScanQRCode; + response: + | EMIncomingMessageQRCodeResponseCanceled + | EMIncomingMessageQRCodeResponseAlternativeOptions + | EMIncomingMessageQRCodeResponseScanResult; + }; }; interface EMOutgoingMessageExoplayerPlayHLS extends EMMessage { @@ -158,6 +172,19 @@ interface EMIncomingMessageShowAutomationEditor { }; } +export interface EMIncomingMessageQRCodeResponseCanceled { + action: "canceled"; +} + +export interface EMIncomingMessageQRCodeResponseAlternativeOptions { + action: "alternative_options"; +} + +export interface EMIncomingMessageQRCodeResponseScanResult { + action: "scan_result"; + result: string; +} + export type EMIncomingMessageCommands = | EMIncomingMessageRestart | EMIncomingMessageShowNotifications @@ -180,6 +207,7 @@ export interface ExternalConfig { canCommissionMatter: boolean; canImportThreadCredentials: boolean; hasAssist: boolean; + hasQRScanner: boolean; } export class ExternalMessaging { From 9788f9bb450fa4bb43699cd961b854e4ce8371df Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 30 Jan 2024 21:33:01 -0500 Subject: [PATCH 2/2] Make `hasQRScanner` a version number --- src/external_app/external_messaging.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/external_app/external_messaging.ts b/src/external_app/external_messaging.ts index bc5c05982c77..8c346738b79a 100644 --- a/src/external_app/external_messaging.ts +++ b/src/external_app/external_messaging.ts @@ -207,7 +207,7 @@ export interface ExternalConfig { canCommissionMatter: boolean; canImportThreadCredentials: boolean; hasAssist: boolean; - hasQRScanner: boolean; + hasQRScanner: number; } export class ExternalMessaging {