src/app/www/js/functions.js
/**
     * Sends the bluetooth password and waits for the response as an event.
     * @returns {Promise.<any>}
     */
Sends the bluetooth password and waits for the response as an event.
@returns {Promise.}
Sends the bluetooth password and waits for the response as an event . @returns { Promise . }
async sendPassword() {
        return new Promise((resolve, reject) => {
            eventSource.addEventListener("bt-right-pwd", () => {
                toast.show("Successfully logged in bluetooth serial!", Toast.Mode.SUCCESS);
                eventSource.removeEventListener("bt-wrong-pwd");
                resolve();
            }, { once: true });
            eventSource.addEventListener("bt-wrong-pwd", () => {
                toast.show("Wrong bluetooth password!", Toast.Mode.ERROR);
                eventSource.removeEventListener("bt-right-pwd");
                reject();
            }, { once: true });
            navigator.notification.prompt(
                "Please enter the bluetooth password.",
                (results) => {
                    this.bluetoothSend('\0');
                    this.bluetoothSend(results.input1);
                    this.bluetoothSend('\0');
                },
                "Bluetooth Password",
                ["Enter"],
                "moe moe kyun",
            );
        });
    }
async sendPassword ( ) { return new Promise ( ( resolve , reject ) => { eventSource . addEventListener ( "bt-right-pwd" , ( ) => { toast . show ( "Successfully logged in bluetooth serial!" , Toast . Mode . SUCCESS ) ; eventSource . removeEventListener ( "bt-wrong-pwd" ) ; resolve ( ) ; } , { once : true } ) ; eventSource . addEventListener ( "bt-wrong-pwd" , ( ) => { toast . show ( "Wrong bluetooth password!" , Toast . Mode . ERROR ) ; eventSource . removeEventListener ( "bt-right-pwd" ) ; reject ( ) ; } , { once : true } ) ; navigator . notification . prompt ( "Please enter the bluetooth password." , ( results ) => { this . bluetoothSend ( '\0' ) ; this . bluetoothSend ( results . input1 ) ; this . bluetoothSend ( '\0' ) ; } , "Bluetooth Password" , [ "Enter" ] , "moe moe kyun" , ) ; } ) ; }
Sends the bluetooth password and waits for the response as an event.
Sends the bluetooth password and waits for the response as an event .