mirror of
https://github.com/sensebox/blockly-app
synced 2025-06-09 03:05:51 +02:00
provider for pinging sensebox
This commit is contained in:
parent
f5b06f3fe4
commit
ce3216c159
3 changed files with 42 additions and 12 deletions
|
@ -38,6 +38,11 @@
|
||||||
<!-- OTA Mode guide-->
|
<!-- OTA Mode guide-->
|
||||||
<ion-slide>
|
<ion-slide>
|
||||||
<ion-grid>
|
<ion-grid>
|
||||||
|
<ion-row align-items-center>
|
||||||
|
<ion-col col-12>
|
||||||
|
<h2 translate>OTAWIZ.OTAMODE.TITLE</h2>
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
<ion-row align-items-center>
|
<ion-row align-items-center>
|
||||||
<ion-col col-12 col-md-6>
|
<ion-col col-12 col-md-6>
|
||||||
<ion-card (click)="showAutomatic()">
|
<ion-card (click)="showAutomatic()">
|
||||||
|
@ -70,7 +75,6 @@
|
||||||
<ion-grid>
|
<ion-grid>
|
||||||
<ion-row align-items-center>
|
<ion-row align-items-center>
|
||||||
<ion-col col-12 col-md-6>
|
<ion-col col-12 col-md-6>
|
||||||
<h2 translate>OTAWIZ.OTAMODE.TITLE</h2>
|
|
||||||
<img class="tutorial_gif" src="../../assets/imgs/ota_modus.gif" />
|
<img class="tutorial_gif" src="../../assets/imgs/ota_modus.gif" />
|
||||||
<p [innerHTML]="'OTAWIZ.OTAMODE.TEXT' | translate"></p>
|
<p [innerHTML]="'OTAWIZ.OTAMODE.TEXT' | translate"></p>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
|
@ -94,20 +98,25 @@
|
||||||
<ion-grid>
|
<ion-grid>
|
||||||
<ion-row align-items-center>
|
<ion-row align-items-center>
|
||||||
<ion-col col-12 col-md-6>
|
<ion-col col-12 col-md-6>
|
||||||
<h2 translate>OTAWIZ.OTAMODE.TITLE</h2>
|
<ol style="text-align: left">
|
||||||
<p [innerHTML]="'OTAWIZ.OTAMODE.TEXT' | translate"></p>
|
<li [innerHTML]="'OTAWIZ.OTAMODE.AUTOMATIC.STEP1' | translate"></li>
|
||||||
|
<li [innerHTML]="'OTAWIZ.OTAMODE.AUTOMATIC.STEP2' | translate"></li>
|
||||||
|
<li [innerHTML]="'OTAWIZ.OTAMODE.AUTOMATIC.STEP3' | translate"></li>
|
||||||
|
</ol>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
<ion-col col-12 col-md-6>
|
<ion-col col-12 col-md-6>
|
||||||
<ol style="text-align: left">
|
|
||||||
<li [innerHTML]="'OTAWIZ.OTAMODE.STEP1' | translate"></li>
|
|
||||||
<li [innerHTML]="'OTAWIZ.OTAMODE.STEP2' | translate"></li>
|
|
||||||
<li [innerHTML]="'OTAWIZ.OTAMODE.STEP3' | translate"></li>
|
|
||||||
</ol>
|
|
||||||
<!-- @TODO: diagram! -->
|
<!-- @TODO: diagram! -->
|
||||||
<button ion-button large clear icon-end color="primary" (click)="slides.slideNext()">
|
<button *ngIf="requestSuccessful;else request" ion-button large clear icon-end color="primary" (click)="slides.slideNext()">
|
||||||
{{ 'OTAWIZ.BTN_NEXT' | translate }}
|
{{ 'OTAWIZ.BTN_NEXT' | translate }}
|
||||||
<ion-icon name="arrow-forward"></ion-icon>
|
<ion-icon name="arrow-forward"></ion-icon>
|
||||||
</button>
|
</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-col>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
</ion-grid>
|
</ion-grid>
|
||||||
|
|
|
@ -50,6 +50,7 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
||||||
private counts = { compile: 0, connect: 0, upload: 0 }
|
private counts = { compile: 0, connect: 0, upload: 0 }
|
||||||
private manual = false;
|
private manual = false;
|
||||||
private automatic = false;
|
private automatic = false;
|
||||||
|
private requestSuccessful = false;
|
||||||
constructor(
|
constructor(
|
||||||
private network: Network,
|
private network: Network,
|
||||||
private otaWifi: OtaWifiProvider,
|
private otaWifi: OtaWifiProvider,
|
||||||
|
@ -141,7 +142,16 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
activateOta(){
|
async makeRequest(){
|
||||||
|
|
||||||
|
try{
|
||||||
|
// open modal that shows loading
|
||||||
|
await this.otaWifi.activateOtaMode();
|
||||||
|
this.requestSuccessful = true;
|
||||||
|
}
|
||||||
|
catch(err){
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
// Sends request; upon successful response go to next slide (wifi selection)
|
// Sends request; upon successful response go to next slide (wifi selection)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ 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'
|
||||||
|
const URL_sensebox = 'http://192.168.0.46'
|
||||||
/*
|
/*
|
||||||
Interface for uploading a binary to a senseBox MCU.
|
Interface for uploading a binary to a senseBox MCU.
|
||||||
*/
|
*/
|
||||||
|
@ -79,6 +79,17 @@ export class OtaWifiProvider {
|
||||||
.toPromise()
|
.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;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum WifiStrategy {
|
export enum WifiStrategy {
|
||||||
|
|
Loading…
Add table
Reference in a new issue