From f1ed71417b64d3d0f841572228dc99d82a81b394 Mon Sep 17 00:00:00 2001 From: Thiemann96 Date: Sat, 28 Mar 2020 18:09:27 +0100 Subject: [PATCH] added input field for IP address --- src/assets/i18n/de.json | 51 +++++++++++++------------- src/assets/i18n/en.json | 53 ++++++++++++++-------------- src/pages/ota-wizard/ota-wizard.html | 6 +++- src/pages/ota-wizard/ota-wizard.ts | 6 +++- src/providers/ota-wifi/ota-wifi.ts | 4 +-- 5 files changed, 65 insertions(+), 55 deletions(-) diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json index 32cfa15..bce692a 100644 --- a/src/assets/i18n/de.json +++ b/src/assets/i18n/de.json @@ -6,7 +6,7 @@ "BLOCKLY": "Blockly", "DOCS": "Dokumentation", "SETTINGS": "Einstellungen", - "MYSENSEBOX":"Meine senseBox" + "MYSENSEBOX": "Meine senseBox" }, "ABOUT": { "TITLE": "Über", @@ -26,24 +26,24 @@ "BTN_CODE": "Quellcode Ansicht", "BTN_OTA": "OTA Upload" }, - "CONFIG":{ - "WIFI":"WiFi Einstellungen", - "IDS":"senseBox und Sensor ID's", - "DEBUG":"Debugging einschalten", - "BUTTON":"Sketch hochladen!" + "CONFIG": { + "WIFI": "WiFi Einstellungen", + "IDS": "senseBox und Sensor ID's", + "DEBUG": "Debugging einschalten", + "BUTTON": "Sketch hochladen!" }, - "MYSENSEBOX":{ - "TITLE":"Meine senseBox", - "SHOW":"Zeige Sensoren", - "SKETCH":"Sketch hochladen", - "EXPOSURE":"Position" + "MYSENSEBOX": { + "TITLE": "Meine senseBox", + "SHOW": "Zeige Sensoren", + "SKETCH": "Sketch hochladen", + "EXPOSURE": "Position" }, - "LOGIN":{ - "LOADING":"Einloggen..." + "LOGIN": { + "LOADING": "Einloggen..." }, - "SENSORS":{ - "TYP":"Typ", - "MEASUREMENT":"Letzte Messung" + "SENSORS": { + "TYP": "Typ", + "MEASUREMENT": "Letzte Messung" }, "SETTINGS": { "TITLE": "Einstellungen", @@ -63,7 +63,7 @@ "TITLE": "Over The Air Programmierung", "BTN_NEXT": "Weiter", "BTN_CLOSE": "Schließen", - "BTN_REQUEST":"OTA Modus aktivieren!", + "BTN_REQUEST": "OTA Modus aktivieren!", "BTN_BACK": "Zurück", "INTRO": { "TITLE": "Willkommen", @@ -80,15 +80,16 @@ "STEP1": "halte den den 'Switch' Knopf (grau oder blau) gedrückt", "STEP2": "drücke den roten 'Reset' Knopf einmal", "STEP3": "lasse den 'Switch' Knopf nach einer Sekunde los.", - "AUTOMATIC":{ - "STEP1":"Laden den Over-the-Air Sketch der openSenseMap auf die senseBox", - "STEP2":"Verbinde dich mit gleichen Netzwekr in dem die senseBox eingewählt ist", - "STEP3":"Klicke auf 'Weiter'!" + "AUTOMATIC": { + "STEP0": "IP Addresse der senseBox: ", + "STEP1": "Laden den Over-the-Air Sketch der openSenseMap auf die senseBox", + "STEP2": "Verbinde dich mit gleichen Netzwekr in dem die senseBox eingewählt ist", + "STEP3": "Klicke auf 'Weiter'!" } }, - "OTAMODESELECTION":{ - "AUTOMATIC":"Wähle diesen Modus wenn du den openSenseMap Sketch nach dem 20.03.2020 auf die senseBox hochgeladen hast!", - "MANUAL":"Wähle diesen Modus aus um die senseBox manuell in den OTA Modus zu schalten!" + "OTAMODESELECTION": { + "AUTOMATIC": "Wähle diesen Modus wenn du den openSenseMap Sketch nach dem 20.03.2020 auf die senseBox hochgeladen hast!", + "MANUAL": "Wähle diesen Modus aus um die senseBox manuell in den OTA Modus zu schalten!" }, "COMPILATION": { "COMPILING": { @@ -128,4 +129,4 @@ "ERROR": "Fehler!" } } -} +} \ No newline at end of file diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 2e7c311..501d25f 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -21,23 +21,23 @@ }, "HINT": "Hint: A web version of Blockly for senseBox is available as well!" }, - "LOGIN":{ - "LOADING":"Logging in..." - }, + "LOGIN": { + "LOADING": "Logging in..." + }, "BLOCKLY": { "TITLE": "Blockly for senseBox", "BTN_CODE": "Code View", "BTN_OTA": "OTA Programmer" }, - "MYSENSEBOX":{ - "TITLE":"My senseBox", - "SHOW":"Show sensors", - "SKETCH":"Upload Sketch", - "EXPOSURE":"Exposure" + "MYSENSEBOX": { + "TITLE": "My senseBox", + "SHOW": "Show sensors", + "SKETCH": "Upload Sketch", + "EXPOSURE": "Exposure" }, - "SENSORS":{ - "TYP":"Type", - "MEASUREMENT":"Last measurement" + "SENSORS": { + "TYP": "Type", + "MEASUREMENT": "Last measurement" }, "SETTINGS": { "TITLE": "Settings", @@ -58,7 +58,7 @@ "BTN_NEXT": "Continue", "BTN_CLOSE": "Close", "BTN_BACK": "Back", - "BTN_REQUEST":"Enable OTA Mode", + "BTN_REQUEST": "Enable OTA Mode", "INTRO": { "TITLE": "Welcome", "TEXT": "To transfer your code to your senseBox over the air (OTA), please follow these steps.", @@ -74,15 +74,16 @@ "STEP1": "press & hold the switch button (gray or blue)", "STEP2": "press the red r eset button shortly", "STEP3": "release the switch button after one second", - "AUTOMATIC":{ - "STEP1":"Upload the Over-the-Air Sketch from the OpenSenseMap to the senseBox", - "STEP2":"Connect this device to the same network the senseBox is connected with", - "STEP3":"Click Continue!" + "AUTOMATIC": { + "STEP0": "IP Address of the senseBox: ", + "STEP1": "Upload the Over-the-Air Sketch from the OpenSenseMap to the senseBox", + "STEP2": "Connect this device to the same network the senseBox is connected with", + "STEP3": "Click Continue!" } }, - "OTAMODESELECTION":{ - "AUTOMATIC":"Choose this mode if your senseBox is currently running an OpenSenseMap Sketch acquired after 20.03.2020", - "MANUAL":"Choose this mode if you have uploaded the OTA Sketch" + "OTAMODESELECTION": { + "AUTOMATIC": "Choose this mode if your senseBox is currently running an OpenSenseMap Sketch acquired after 20.03.2020", + "MANUAL": "Choose this mode if you have uploaded the OTA Sketch" }, "COMPILATION": { "COMPILING": { @@ -122,11 +123,11 @@ "ERROR": "Error!" } }, - "CONFIG":{ - "TITLE":"Initial configuration", - "BUTTON":"Upload Sketch!", - "WIFI":"Configure WiFi Settings", - "IDS":"senseBox and sensor ID's", - "DEBUG":"Enable debugging" + "CONFIG": { + "TITLE": "Initial configuration", + "BUTTON": "Upload Sketch!", + "WIFI": "Configure WiFi Settings", + "IDS": "senseBox and sensor ID's", + "DEBUG": "Enable debugging" } -} +} \ No newline at end of file diff --git a/src/pages/ota-wizard/ota-wizard.html b/src/pages/ota-wizard/ota-wizard.html index 3560046..fc5c730 100644 --- a/src/pages/ota-wizard/ota-wizard.html +++ b/src/pages/ota-wizard/ota-wizard.html @@ -120,7 +120,11 @@ -
    +
      +
    1. + {{ 'OTAWIZ.OTAMODE.AUTOMATIC.STEP0' | translate }} + +
    2. diff --git a/src/pages/ota-wizard/ota-wizard.ts b/src/pages/ota-wizard/ota-wizard.ts index 013768e..c8c67ca 100644 --- a/src/pages/ota-wizard/ota-wizard.ts +++ b/src/pages/ota-wizard/ota-wizard.ts @@ -52,6 +52,7 @@ export class OtaWizardPage implements OnInit, OnDestroy { private slideHistory: string[] = [OtaSlides[OtaSlides.Intro]] // for debug info in logs private counts = { compile: 0, connect: 0, upload: 0 } private modus; + private OTAAddress = '192.168.0.46' private wifiSlideHidden = false; constructor( private network: Network, @@ -136,12 +137,14 @@ export class OtaWizardPage implements OnInit, OnDestroy { showAutomatic() { this.hideSlide(OtaSlides.WifiSelection); this.modus = "automatic"; + this.OTAAddress = '192.168.0.46' this.slides.lockSwipeToNext(false); this.slides.slideNext() } showManual() { this.modus = "manual"; + this.OTAAddress = '192.168.1.1' this.showSlide(this.slideWifi); this.slides.lockSwipeToNext(false); this.slides.slideNext() @@ -185,6 +188,7 @@ export class OtaWizardPage implements OnInit, OnDestroy { } get currentSlide(): OtaSlides { + console.log(this.OTAAddress); let current = this.slides.getActiveIndex() const hiddenOffset = this.hiddenSlides.filter(slide => slide <= current).length if(current === 3 && this.slideIsHidden(this.slideWifi)){ @@ -270,7 +274,7 @@ export class OtaWizardPage implements OnInit, OnDestroy { this.state.upload = 'uploading' try { - const res = await this.otaWifi.uploadFirmware(this.compiledSketch) + const res = await this.otaWifi.uploadFirmware(this.compiledSketch,this.OTAAddress) this.log.debug(JSON.stringify(res, null, 2)) this.state.upload = 'done' diff --git a/src/providers/ota-wifi/ota-wifi.ts b/src/providers/ota-wifi/ota-wifi.ts index 882ab43..4471c42 100644 --- a/src/providers/ota-wifi/ota-wifi.ts +++ b/src/providers/ota-wifi/ota-wifi.ts @@ -68,9 +68,9 @@ export class OtaWifiProvider { : WifiWizard2.connect(ssid, true) // true: bind to all connections, even without internet } - async uploadFirmware (binary: ArrayBuffer): Promise { + async uploadFirmware (binary: ArrayBuffer,OTAAddress:String): Promise { // TODO: send checksum? - return this.http.post(`${URL_sensebox}/sketch`, binary, { + return this.http.post(`${OTAAddress}/sketch`, binary, { responseType: 'text', }) .pipe(timeout(5000), catchError(err => {