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:
parent
28d18f096f
commit
ff1a017813
4 changed files with 38 additions and 25 deletions
|
|
@ -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>
|
||||||
|
<div id="wifi-manual" *ngIf="state.wifiSelection == 'manual'">
|
||||||
<h2>Connect to your senseBox</h2>
|
<h2>Connect to your senseBox</h2>
|
||||||
<p>
|
<p>
|
||||||
Connect to the WiFi network that your senseBox has openened.
|
Your senseBox should have opened the a WiFi network.
|
||||||
Because we can not do this automatically on your platform, please do this manually.
|
Because we can not do this automatically on your platform, please connect to it manually.
|
||||||
</p>
|
</p>
|
||||||
</ng-container>
|
<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>
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ page-ota-wizard {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#wifi-automatic {
|
||||||
// for the ion-list height limitation to work..
|
// for the ion-list height limitation to work..
|
||||||
&, div.slide-zoom, ion-grid, ion-row, ion-col:last-child {
|
&, div.slide-zoom, ion-grid, ion-row, ion-col:last-child {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
@ -52,6 +53,8 @@ page-ota-wizard {
|
||||||
max-height: 55%;
|
max-height: 55%;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue