import { ConnectableRaftType, RaftConnectionMethod, RaftConnectOptions, RaftTypeE } from "../../types/raft"; import WebAppCommunicator from "../../wrapper-app/communicators/WebAppCommunicator"; import RAFT from "../RAFTs/RAFT"; import Marty from "../RAFTs/Marty/Marty"; import Cog from "../RAFTs/Cog/Cog"; import { FOUND_RAFT_ON_DISCOVERY_RESPONSE } from "../../types/phone-app-communicator"; import { ColourSensorCalibrationStage } from "../../types/colour-sensor-calibration"; import { RaftObserver } from "../RAFTs/RaftObserver"; import { RaftInfoEvents } from "../../types/events/raft-info"; import { RaftConnEvent, RaftUpdateEvent, RaftPublishEvent, RaftWifiScanResults, RaftWifiConnStatus, RaftOKFail } from "@robdobsn/raftjs"; import { ConnectedRaftItem } from "../../store/SelectedRaftContext"; import Toaster from "../../utils/Toaster"; import AnalyticsFacade from "@robotical/appv2-analytics-gatherer"; import { CarouselNavigatorManager } from "../../utils/CarouselNavigatorManager"; import { CustomBluetoothItem, UserDeviceInfo } from "../../types/userDeviceInfo"; import { UserRoleContextTypes } from "../../store/user-role-context"; type ConnectResultDisposition = "commit" | "release" | "ignore"; export default class ApplicationManager { selectedLocale: string; AnalyticsFacade: typeof AnalyticsFacade; analyticsSessionId: string | undefined; private _observers; static wrapperAppCommunicator: WebAppCommunicator; connectedRafts: { [key: string]: RAFT; }; private _connectPromise; private _connectAttemptSequence; private _activeConnectAttemptId; private _disconnectPromises; private _pendingWifiLocators; connectedRaftsContext: ConnectedRaftItem[]; returnToMainApp: () => void; carouselNavigatorManager: CarouselNavigatorManager; deviceInfo: UserDeviceInfo | undefined; userRoleCtx: UserRoleContextTypes | null; lastUUIDsUsed: string[] | null; setUserRoleCtx(userRoleCtx: UserRoleContextTypes): void; private _router; setRouter(router: any): void; navigateTo(path: string): void; setSelectedLocale(locale: string): void; getSelectedLocale(): string; ricSelectedCb: ((raft: RAFT) => void) | null; toaster: typeof Toaster; showBackHomeButton: () => void; hideBackHomeButton: () => void; connectedRaftContextMethods: { addConnectedRaft: (connectedRaft: ConnectedRaftItem) => void; removeConnectedRaft: (connectedRaftId: string) => void; setSelectedRaft: (connectedRaftId: string) => void; getSelectedRaft: () => { raftSummary: ConnectedRaftItem | undefined; raftEntity: RAFT | undefined; }; nameUpdated: () => void; }; isPhoneApp: () => boolean; constructor(); getDeviceInfo(): Promise; ensureWifiConnectionSupported(): Promise; updateRaftNameInAllStates(raftId: string, name: string): Promise; private getConnectedRaftName; /** * Whether this exact RAFT object still owns its ID and is not already in * the asynchronous disconnect pipeline. */ isRaftActive(raft: RAFT): boolean; private addConnectedRaftToContext; private publishLocalVerifiedConnection; private confirmQrVerifiedConnection; private getWifiManager; pauseWifiConnection(raftId: string, pause: boolean): Promise; getCachedWifiStatus(raftId: string): RaftWifiConnStatus | undefined; wifiConnect(raftId: string, ssid: string, password: string): Promise; wifiDisconnect(raftId: string): Promise; getWiFiConnStatus(raftId: string): Promise; getWifiScanResults(raftId: string): Promise; private getMartyWifiManager; pauseWifiConnectionMarty(raftId: string, pause: boolean): Promise; getCachedWifiStatusMarty(raftId: string): RaftWifiConnStatus | undefined; wifiConnectMarty(raftId: string, ssid: string, password: string): Promise; wifiDisconnectMarty(raftId: string): Promise; getWiFiConnStatusMarty(raftId: string): Promise; getWifiScanResultsMarty(raftId: string): Promise; calibrateMarty(martyId: string, cmd: string, joints: string): Promise; calibrateColourSensorsMarty(raftId: string, stage: ColourSensorCalibrationStage): Promise; resetColourSensorOffsetsMarty(raftId: string): Promise; getCommsStatsMarty(martyId: string): Promise<{ msgRxRate: number; msgRoundtripWorstMs: number; msgRoundtripLastMs: number; msgRoundtripBestMs: number; msgRetries: number; }>; getConnectedColourSensorsMarty(martyId: string): Promise; getConnectedAddOnsMarty(martyId: string): Promise; getAddOnConfigsMarty(martyId: string): Promise; identifyAddOnMarty(martyId: string, addOnSN: string): Promise; setAddOnConfigMarty(martyId: string, addOnSN: string, config: any): Promise; deleteAddOnMarty(martyId: string, addOnSN: string): Promise; createNewCog(id: string): Cog; createNewMarty(id: string): Marty; connectGenericMarty(afterRaftConnectedCb: (raft: RAFT) => void, options?: RaftConnectOptions): Promise; connectGenericCog(afterRaftConnectedCb: (raft: RAFT) => void, options?: RaftConnectOptions): Promise; /** * Generic Connect method * This method is called from various environments (connection button, blocksjr, blocks etc.) * Known issue: connecting to a raft from within a platform won't add the newly connected raft to the connectedRafts hook */ connectGeneric(afterRaftConnectedCb: (raft: RAFT) => void, uuids?: string[], shouldShowQrModal?: boolean, options?: RaftConnectOptions): Promise; private _clearConnectPromise; private _dismissConnectAttempt; private _isConnectAttemptActive; private _getConnectResultDisposition; private _createConnectingModal; private _resolveConnectOptions; private _connectGeneric; private _connectWithResolvedOptions; /** * Disconnect from RAFT generic * This method is called from various environments (connection button, blocksjr, blocks etc.) */ disconnectGeneric(raft: RAFT, afterRaftDisconnectedCb?: () => void, skipConfirmation?: boolean): Promise; /** * Selects a RAFT in Phone's verification modal */ selectRaft(ricToConnectTo: FOUND_RAFT_ON_DISCOVERY_RESPONSE['foundRIC'], method: RaftConnectionMethod): Promise; connectToRIC(method: RaftConnectionMethod, uuids: string[], withoutVerification?: boolean, getResultDisposition?: () => ConnectResultDisposition, locator?: string, expectedRaftType?: ConnectableRaftType): Promise; /** * Warranty Service bluetooth scan for device * It scans for a device and gets the device object * Then it checks if the device is already in the given devices array having CustomBluetoothItem[] type * if not, it gets its serial number and adds it to the devices array * @returns {Promise} */ scanForPotentialWarrantyDevice(existingDevices: CustomBluetoothItem[]): Promise; /** * Toggles the Sensors Dashboard modal */ toggleSensorsDashboard(): void; /** * Disconnect from RAFT */ disconnectFromRaft(raftId: string): Promise; /** * Finalizes a RAFT which has already emitted its terminal disconnect event. * Passing the source RAFT prevents a late event from deleting a replacement * connection which happens to have the same serial/ID. */ removeRaft(raftId: string, disconnectedRaft?: RAFT): Promise; private _disconnectRaft; private _removeRaftIfCurrent; /** * Start looking for rics to connect to * This is used from the Phone App only */ startDiscovery(ricSelectedCb: (raft: RAFT) => void, uuids: string[], expectedRaftType?: ConnectableRaftType): Promise; /** * Start discovery without verification * This is used from the Phone App only, when the user wants to connect to a RAFT with qr code */ startDiscoveryWithoutVerification(uuids: string[], afterRaftConnectedCb: (raft: RAFT) => void): Promise; /** * Stοp discovery * When the user cancels the discovery process without having first connected to a robot */ stopDiscovery(): Promise; /** * Stop verifying raft */ stopVerifyingRaft(raftId: string, isCorrectRIC: boolean): Promise; /** * Publishing events to observers * It could be either events we get from RAFT, or custom events related to the app */ publish(eventType: string, eventEnum: RaftConnEvent | RaftUpdateEvent | RaftPublishEvent | RaftInfoEvents, eventName: string, eventData: any): void; subscribe(observer: RaftObserver, topics: Array): void; unsubscribe(observer: RaftObserver): void; receivedRICEvent(raftId: string, eventType: any, eventEnum: any, eventName: any, eventData: any): void; /** * Save the file on the device */ saveFileOnDevice(fileName: string, base64: string): void | Promise; /** * Save the file on the device's local storage */ saveFileOnDeviceLocalStorage(dirname: string, fileName: string, base64: string): void | Promise; /** * Load the file from the device's local storage */ loadFileFromDeviceLocalStorage(dirname: string, fileName: string): void | Promise; /** * Delete the file from the device's local storage */ deleteFileFromDeviceLocalStorage(dirname: string, fileName: string): void | Promise; /** * List the files from the device's local storage */ listFilesFromDeviceLocalStorage(dirname: string): Promise; /** * Injects JS code to the phone app * This is used to call native functions from the web app */ injectJS(jsCode: string): Promise; getTheCurrentlySelectedDeviceOrFirstOfItsKind(deviceType: RaftTypeE): RAFT | undefined; } export {};