From ff1a01781336465b0a1714c0ad1e1bd96564ebff Mon Sep 17 00:00:00 2001
From: Norwin Roosen
Date: Mon, 10 Dec 2018 17:17:29 +0100
Subject: [PATCH] also allow upload from browser
---
src/pages/ota-wizard/ota-wizard.html | 24 ++++++++++++++----------
src/pages/ota-wizard/ota-wizard.scss | 17 ++++++++++-------
src/pages/ota-wizard/ota-wizard.ts | 1 +
src/providers/ota-wifi/ota-wifi.ts | 21 +++++++++++++--------
4 files changed, 38 insertions(+), 25 deletions(-)
diff --git a/src/pages/ota-wizard/ota-wizard.html b/src/pages/ota-wizard/ota-wizard.html
index 5f68260..3da3a32 100644
--- a/src/pages/ota-wizard/ota-wizard.html
+++ b/src/pages/ota-wizard/ota-wizard.html
@@ -22,7 +22,7 @@
We will help you connect to your senseBox via WiFi.
-
+
First, please make sure that your senseBox...
@@ -70,16 +70,20 @@
-
- Connect to your senseBox
-
- Connect to the WiFi network that your senseBox has openened.
- Because we can not do this automatically on your platform, please do this manually.
-
-
+
+
+
Connect to your senseBox
+
+ Your senseBox should have opened the a WiFi network.
+ Because we can not do this automatically on your platform, please connect to it manually.
+
+
+
-
-
+
Select your senseBox
diff --git a/src/pages/ota-wizard/ota-wizard.scss b/src/pages/ota-wizard/ota-wizard.scss
index e5cfbe7..81c3006 100644
--- a/src/pages/ota-wizard/ota-wizard.scss
+++ b/src/pages/ota-wizard/ota-wizard.scss
@@ -43,15 +43,18 @@ page-ota-wizard {
display: inline-block;
}
- // for the ion-list height limitation to work..
- &, div.slide-zoom, ion-grid, ion-row, ion-col:last-child {
- height: 100%;
+ #wifi-automatic {
+ // for the ion-list height limitation to work..
+ &, div.slide-zoom, ion-grid, ion-row, ion-col:last-child {
+ height: 100%;
+ }
+
+ #wifi-list {
+ max-height: 55%;
+ overflow-y: scroll;
+ }
}
- #wifi-list {
- max-height: 55%;
- overflow-y: scroll;
- }
}
}
diff --git a/src/pages/ota-wizard/ota-wizard.ts b/src/pages/ota-wizard/ota-wizard.ts
index 2ab4087..831aaf9 100644
--- a/src/pages/ota-wizard/ota-wizard.ts
+++ b/src/pages/ota-wizard/ota-wizard.ts
@@ -141,6 +141,7 @@ export class OtaWizardPage implements OnInit, OnDestroy {
if (this.otaWifi.strategy == WifiStrategy.Manual) {
this.state.wifiSelection = 'manual'
+ this.slides.lockSwipeToNext(false)
} else {
this.state.wifiSelection = 'scanning'
try {
diff --git a/src/providers/ota-wifi/ota-wifi.ts b/src/providers/ota-wifi/ota-wifi.ts
index 0ffcf52..21dbbdb 100644
--- a/src/providers/ota-wifi/ota-wifi.ts
+++ b/src/providers/ota-wifi/ota-wifi.ts
@@ -1,13 +1,14 @@
-import { Injectable } from '@angular/core';
-import { HttpClient } from '@angular/common/http';
-import { Platform } from 'ionic-angular';
+import { Injectable } from '@angular/core'
+import { HttpClient } from '@angular/common/http'
+import { Platform } from 'ionic-angular'
+import { timeout, catchError } from 'rxjs/operators'
// use global var as no @ionic-native/wifiwizard2 package is available yet
-declare var WifiWizard2: any;
+declare var WifiWizard2: any
// corresponding to the initial MCU firmware
-const SSID_PREFIX = 'sensebox';
-const SENSEBOX_API = 'http://192.168.1.1';
+const SSID_PREFIX = 'sensebox'
+const SENSEBOX_API = 'http://192.168.1.1'
/*
Interface for uploading a binary to a senseBox MCU.
@@ -25,7 +26,7 @@ export class OtaWifiProvider {
// check if plugin is available (e.g. not in browser builds)
WifiWizard2
} catch (err) {
- return WifiStrategy.Unavailable
+ return WifiStrategy.Manual
}
if (
@@ -65,7 +66,11 @@ export class OtaWifiProvider {
// TODO: send checksum?
return this.http.post(`${SENSEBOX_API}/flash`, binary, {
responseType: 'text',
- }).toPromise()
+ })
+ .pipe(timeout(2500), catchError(err => {
+ throw new Error('senseBox not found. Is it running in OTA mode?')
+ }))
+ .toPromise()
}
}