mirror of
https://github.com/sensebox/blockly-app
synced 2025-06-08 10:05:50 +02:00
changed ota app according to new osem sketch
This commit is contained in:
parent
5801e7a4d5
commit
0e3f43e2ec
3 changed files with 13 additions and 51 deletions
|
@ -103,16 +103,10 @@
|
|||
</ion-col>
|
||||
<ion-col col-12 col-md-6>
|
||||
<!-- @TODO: diagram! -->
|
||||
<button *ngIf="requestSuccessful;else request" ion-button large clear icon-end color="primary" (click)="slides.slideNext()">
|
||||
<button ion-button large clear icon-end color="primary" (click)="slides.slideNext()">
|
||||
{{ 'OTAWIZ.BTN_NEXT' | translate }}
|
||||
<ion-icon name="arrow-forward"></ion-icon>
|
||||
</button>
|
||||
<ng-template #request>
|
||||
<button ion-button large clear icon-end color="primary" (click)="makeRequest()">
|
||||
{{ 'OTAWIZ.BTN_REQUEST' | translate }}
|
||||
<ion-icon name="arrow-forward"></ion-icon>
|
||||
</button>
|
||||
</ng-template>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
|
@ -142,7 +136,7 @@
|
|||
</ng-container>
|
||||
</ion-slide>
|
||||
<!-- wifi selection -->
|
||||
<ion-slide id="wifi-slide">
|
||||
<ion-slide id="wifi-slide" *ngIf="!slideIsHidden(slideWifi)">
|
||||
<ion-grid>
|
||||
<div id="wifi-manual" *ngIf="state.wifiSelection == 'manual'">
|
||||
<ion-row align-items-center>
|
||||
|
|
|
@ -20,6 +20,7 @@ import { OtaWifiProvider, WifiStrategy } from '../../providers/ota-wifi/ota-wifi
|
|||
import { CompilerProvider } from '../../providers/compiler/compiler';
|
||||
import { LoggingProvider } from '../../providers/logging/logging';
|
||||
import {ErrorPage} from '../../pages/error/error'
|
||||
import { isUndefined } from 'ionic-angular/umd/util/util';
|
||||
@IonicPage()
|
||||
@Component({
|
||||
selector: 'page-ota-wizard',
|
||||
|
@ -52,7 +53,7 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
|||
private counts = { compile: 0, connect: 0, upload: 0 }
|
||||
private manual = false;
|
||||
private automatic = false;
|
||||
private requestSuccessful = false;
|
||||
private wifiSlideHidden = false;
|
||||
constructor(
|
||||
private network: Network,
|
||||
private otaWifi: OtaWifiProvider,
|
||||
|
@ -134,16 +135,18 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
|||
}
|
||||
}
|
||||
showAutomatic() {
|
||||
this.slides.lockSwipeToNext(false);
|
||||
this.wifiSlideHidden = true;
|
||||
this.automatic = true;
|
||||
this.manual = false;
|
||||
this.slides.lockSwipeToNext(false);
|
||||
this.slides.slideNext()
|
||||
}
|
||||
|
||||
showManual() {
|
||||
this.slides.lockSwipeToNext(false);
|
||||
this.wifiSlideHidden = false;
|
||||
this.manual = true;
|
||||
this.automatic = false;
|
||||
this.slides.lockSwipeToNext(false);
|
||||
this.slides.slideNext()
|
||||
|
||||
}
|
||||
|
@ -153,32 +156,10 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
|||
let modal = this.modalCtrl.create(ErrorPage,message);
|
||||
|
||||
modal.onDidDismiss(()=>{
|
||||
|
||||
})
|
||||
|
||||
modal.present();
|
||||
}
|
||||
|
||||
async makeRequest() {
|
||||
const loading = await this.loadingController.create({
|
||||
content: 'Pinging senseBox...'
|
||||
});
|
||||
try {
|
||||
// open modal that shows loading
|
||||
|
||||
loading.present();
|
||||
await this.otaWifi.activateOtaMode();
|
||||
this.requestSuccessful = true;
|
||||
}
|
||||
catch (err) {
|
||||
this.slides.lockSwipeToNext(true);
|
||||
this.showModal(err);
|
||||
console.log(err)
|
||||
}
|
||||
loading.dismiss();
|
||||
// Sends request; upon successful response go to next slide (wifi selection)
|
||||
|
||||
}
|
||||
// call logic for each slide
|
||||
onSlideChange() {
|
||||
this.slideHistory.push(OtaSlides[this.currentSlide])
|
||||
|
@ -187,20 +168,16 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
|||
case OtaSlides.Intro:
|
||||
this.slides.lockSwipeToNext(false);
|
||||
case OtaSlides.Intro2:
|
||||
this.slides.lockSwipeToNext(true);
|
||||
break
|
||||
case OtaSlides.Intro3:
|
||||
if(this.automatic){
|
||||
this.slides.lockSwipeToNext(true);
|
||||
}
|
||||
if(this.manual){
|
||||
this.slides.lockSwipeToNext(false);
|
||||
}
|
||||
break
|
||||
case OtaSlides.Compilation:
|
||||
this.handleCompilation()
|
||||
break
|
||||
|
||||
case OtaSlides.WifiSelection:
|
||||
if(this.automatic) this.slides.slideNext()
|
||||
this.handleWifiSelection()
|
||||
break
|
||||
|
||||
|
@ -290,6 +267,7 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
|||
this.counts.upload++
|
||||
this.state.upload = 'uploading'
|
||||
try {
|
||||
|
||||
const res = await this.otaWifi.uploadFirmware(this.compiledSketch)
|
||||
this.log.debug(JSON.stringify(res, null, 2))
|
||||
|
||||
|
|
|
@ -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'
|
||||
const URL_sensebox = 'http://10.0.1.12'
|
||||
/*
|
||||
Interface for uploading a binary to a senseBox MCU.
|
||||
*/
|
||||
|
@ -70,7 +70,7 @@ export class OtaWifiProvider {
|
|||
|
||||
async uploadFirmware (binary: ArrayBuffer): Promise<any> {
|
||||
// TODO: send checksum?
|
||||
return this.http.post(`${SENSEBOX_API}/sketch`, binary, {
|
||||
return this.http.post(`${URL_sensebox}/sketch`, binary, {
|
||||
responseType: 'text',
|
||||
})
|
||||
.pipe(timeout(5000), catchError(err => {
|
||||
|
@ -79,16 +79,6 @@ export class OtaWifiProvider {
|
|||
.toPromise()
|
||||
}
|
||||
|
||||
async activateOtaMode():Promise<any>{
|
||||
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;
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue