From ce3216c159f1c100ec17503a7005093981558ac4 Mon Sep 17 00:00:00 2001 From: Thiemann96 Date: Wed, 18 Mar 2020 23:54:47 +0100 Subject: [PATCH] provider for pinging sensebox --- src/pages/ota-wizard/ota-wizard.html | 29 ++++++++++++++++++---------- src/pages/ota-wizard/ota-wizard.ts | 12 +++++++++++- src/providers/ota-wifi/ota-wifi.ts | 13 ++++++++++++- 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/pages/ota-wizard/ota-wizard.html b/src/pages/ota-wizard/ota-wizard.html index 8b2508e..135b497 100644 --- a/src/pages/ota-wizard/ota-wizard.html +++ b/src/pages/ota-wizard/ota-wizard.html @@ -38,6 +38,11 @@ + + +

OTAWIZ.OTAMODE.TITLE

+
+
@@ -70,7 +75,6 @@ -

OTAWIZ.OTAMODE.TITLE

@@ -81,7 +85,7 @@
  • - @@ -93,21 +97,26 @@ - -

    OTAWIZ.OTAMODE.TITLE

    -

    -
      -
    1. -
    2. -
    3. +
    4. +
    5. +
    +
    + + - + + +
    diff --git a/src/pages/ota-wizard/ota-wizard.ts b/src/pages/ota-wizard/ota-wizard.ts index a69ec95..969d847 100644 --- a/src/pages/ota-wizard/ota-wizard.ts +++ b/src/pages/ota-wizard/ota-wizard.ts @@ -50,6 +50,7 @@ export class OtaWizardPage implements OnInit, OnDestroy { private counts = { compile: 0, connect: 0, upload: 0 } private manual = false; private automatic = false; + private requestSuccessful = false; constructor( private network: Network, private otaWifi: OtaWifiProvider, @@ -141,7 +142,16 @@ export class OtaWizardPage implements OnInit, OnDestroy { } - activateOta(){ + async makeRequest(){ + + try{ + // open modal that shows loading + await this.otaWifi.activateOtaMode(); + this.requestSuccessful = true; + } + catch(err){ + console.log(err) + } // Sends request; upon successful response go to next slide (wifi selection) } diff --git a/src/providers/ota-wifi/ota-wifi.ts b/src/providers/ota-wifi/ota-wifi.ts index a4cc2b5..4642a41 100644 --- a/src/providers/ota-wifi/ota-wifi.ts +++ b/src/providers/ota-wifi/ota-wifi.ts @@ -9,7 +9,7 @@ declare var WifiWizard2: any // corresponding to the initial MCU firmware const SSID_PREFIX = 'sensebox' const SENSEBOX_API = 'http://192.168.1.1' - +const URL_sensebox = 'http://192.168.0.46' /* Interface for uploading a binary to a senseBox MCU. */ @@ -79,6 +79,17 @@ export class OtaWifiProvider { .toPromise() } + async activateOtaMode():Promise{ + return this.http.get(URL_sensebox) + .pipe(timeout(5000),catchError(err=>{ + throw new Error('senseBox not found. Is it running the proper OpenSenseMap Sketch?') + })) + .toPromise() + .then((response:any)=>{ + return response; + }) + } + } export enum WifiStrategy {