1
0
Fork 0
mirror of https://github.com/sensebox/blockly-app synced 2025-12-03 06:17:54 +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>.
</p>
</ion-col>
<ion-col col-12 col-md-6>
<p>First, please make sure that your senseBox...</p>
<ul style="text-align: left">
@ -70,16 +70,20 @@
<!-- wifi selection -->
<ion-slide id="wifi-slide">
<ng-container *ngIf="state.wifiSelection == 'manual'">
<h2>Connect to your senseBox</h2>
<p>
Connect to the WiFi network that your senseBox has openened.
Because we can not do this automatically on your platform, please do this manually.
</p>
</ng-container>
<ion-grid>
<div id="wifi-manual" *ngIf="state.wifiSelection == 'manual'">
<h2>Connect to your senseBox</h2>
<p>
Your senseBox should have opened the a WiFi network.
Because we can not do this automatically on your platform, please connect to it manually.
</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>
<ion-row id="wifi-automatic" *ngIf="state.wifiSelection != 'manual'">
<ion-col col-12 col-md-6>
<ion-icon name="wifi" style="font-size: 160px"></ion-icon>
<h2>Select your senseBox</h2>

View file

@ -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;
}
}
}

View file

@ -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 {

View file

@ -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()
}
}