1
0
Fork 0
mirror of https://github.com/sensebox/blockly-app synced 2025-12-03 14:47:55 +01:00

also allow upload from browser

This commit is contained in:
Norwin 2018-12-10 17:17:29 +01:00
parent 28d18f096f
commit ff1a017813
4 changed files with 38 additions and 25 deletions

View file

@ -22,7 +22,7 @@
We will help you connect to your senseBox via <b>WiFi</b>. We will help you connect to your senseBox via <b>WiFi</b>.
</p> </p>
</ion-col> </ion-col>
<ion-col col-12 col-md-6> <ion-col col-12 col-md-6>
<p>First, please make sure that your senseBox...</p> <p>First, please make sure that your senseBox...</p>
<ul style="text-align: left"> <ul style="text-align: left">
@ -70,16 +70,20 @@
<!-- wifi selection --> <!-- wifi selection -->
<ion-slide id="wifi-slide"> <ion-slide id="wifi-slide">
<ng-container *ngIf="state.wifiSelection == 'manual'"> <ion-grid>
<h2>Connect to your senseBox</h2> <div id="wifi-manual" *ngIf="state.wifiSelection == 'manual'">
<p> <h2>Connect to your senseBox</h2>
Connect to the WiFi network that your senseBox has openened. <p>
Because we can not do this automatically on your platform, please do this manually. Your senseBox should have opened the a WiFi network.
</p> Because we can not do this automatically on your platform, please connect to it manually.
</ng-container> </p>
<button ion-button large clear icon-end color="primary" (click)="slides.slideNext()">
Continue
<ion-icon name="arrow-forward"></ion-icon>
</button>
</div>
<ion-grid *ngIf="state.wifiSelection != 'manual'"> <ion-row id="wifi-automatic" *ngIf="state.wifiSelection != 'manual'">
<ion-row>
<ion-col col-12 col-md-6> <ion-col col-12 col-md-6>
<ion-icon name="wifi" style="font-size: 160px"></ion-icon> <ion-icon name="wifi" style="font-size: 160px"></ion-icon>
<h2>Select your senseBox</h2> <h2>Select your senseBox</h2>

View file

@ -43,15 +43,18 @@ page-ota-wizard {
display: inline-block; display: inline-block;
} }
// for the ion-list height limitation to work.. #wifi-automatic {
&, div.slide-zoom, ion-grid, ion-row, ion-col:last-child { // for the ion-list height limitation to work..
height: 100%; &, 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;
}
} }
} }

View file

@ -141,6 +141,7 @@ export class OtaWizardPage implements OnInit, OnDestroy {
if (this.otaWifi.strategy == WifiStrategy.Manual) { if (this.otaWifi.strategy == WifiStrategy.Manual) {
this.state.wifiSelection = 'manual' this.state.wifiSelection = 'manual'
this.slides.lockSwipeToNext(false)
} else { } else {
this.state.wifiSelection = 'scanning' this.state.wifiSelection = 'scanning'
try { try {

View file

@ -1,13 +1,14 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core'
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http'
import { Platform } from 'ionic-angular'; import { Platform } from 'ionic-angular'
import { timeout, catchError } from 'rxjs/operators'
// use global var as no @ionic-native/wifiwizard2 package is available yet // 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 // corresponding to the initial MCU firmware
const SSID_PREFIX = 'sensebox'; const SSID_PREFIX = 'sensebox'
const SENSEBOX_API = 'http://192.168.1.1'; const SENSEBOX_API = 'http://192.168.1.1'
/* /*
Interface for uploading a binary to a senseBox MCU. 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) // check if plugin is available (e.g. not in browser builds)
WifiWizard2 WifiWizard2
} catch (err) { } catch (err) {
return WifiStrategy.Unavailable return WifiStrategy.Manual
} }
if ( if (
@ -65,7 +66,11 @@ export class OtaWifiProvider {
// TODO: send checksum? // TODO: send checksum?
return this.http.post(`${SENSEBOX_API}/flash`, binary, { return this.http.post(`${SENSEBOX_API}/flash`, binary, {
responseType: 'text', responseType: 'text',
}).toPromise() })
.pipe(timeout(2500), catchError(err => {
throw new Error('senseBox not found. Is it running in OTA mode?')
}))
.toPromise()
} }
} }