add restart to osem block

This commit is contained in:
Mario Pesch 2022-02-16 20:01:22 +01:00
parent 321cba25ba
commit 772797bb6b
5 changed files with 56 additions and 34 deletions

View File

@ -21,6 +21,9 @@ Blockly.Blocks["sensebox_osem_connection"] = {
.appendField(Blockly.Msg.senseBox_osem_connection) .appendField(Blockly.Msg.senseBox_osem_connection)
.appendField("SSL") .appendField("SSL")
.appendField(new Blockly.FieldCheckbox(ssl), "SSL"); .appendField(new Blockly.FieldCheckbox(ssl), "SSL");
this.appendDummyInput()
.appendField(Blockly.Msg.senseBox_osem_restart)
.appendField(new Blockly.FieldCheckbox("TRUE"), "RESTART");
this.appendDummyInput() this.appendDummyInput()
.setAlign(Blockly.ALIGN_LEFT) .setAlign(Blockly.ALIGN_LEFT)
.appendField(Blockly.Msg.senseBox_osem_exposure) .appendField(Blockly.Msg.senseBox_osem_exposure)

View File

@ -33,6 +33,7 @@ Blockly.Arduino.sensebox_osem_connection = function (Block) {
var blocks = this.getDescendants(); var blocks = this.getDescendants();
var type = this.getFieldValue("type"); var type = this.getFieldValue("type");
var ssl = this.getFieldValue("SSL"); var ssl = this.getFieldValue("SSL");
var restart = this.getFieldValue("RESTART");
var port = 0; var port = 0;
var count = 0; var count = 0;
if (blocks !== undefined) { if (blocks !== undefined) {
@ -186,6 +187,12 @@ ${
} }
delay(1000); delay(1000);
} }
${
restart === "TRUE"
? "if (connected == false) {\n delay(5000);\n noInterrupts();\n NVIC_SystemReset();\n while (1)\n ;\n }"
: ""
}
}`; }`;
var code = ""; var code = "";
@ -271,12 +278,20 @@ ${
client.stop(); client.stop();
break; break;
} }
delay(1000);
} }
num_measurements = 0; num_measurements = 0;
break; break;
} }
} }
${
restart === "TRUE"
? "if (connected == false) {\n delay(5000);\n noInterrupts();\n NVIC_SystemReset();\n while (1)\n ;\n }"
: ""
}
}`; }`;
code = ""; code = "";
code += branch; code += branch;

View File

@ -35,6 +35,7 @@ Blockly.Arduino.sensebox_sensor_uv_light = function () {
} }
if (dropdown_name === "Illuminance") { if (dropdown_name === "Illuminance") {
Blockly.Arduino.libraries_["library_ltr329"] = `#include <LTR329.h>`; Blockly.Arduino.libraries_["library_ltr329"] = `#include <LTR329.h>`;
Blockly.Arduino.libraries_["library_wire"] = "#include <Wire.h>";
Blockly.Arduino.codeFunctions_["read_reg"] = ` Blockly.Arduino.codeFunctions_["read_reg"] = `
int read_reg(byte address, uint8_t reg) int read_reg(byte address, uint8_t reg)
{ {

View File

@ -1,17 +1,20 @@
export const OSEM = { export const OSEM = {
/** /**
* openSenseMap * openSenseMap
*/ */
senseBox_osem_connection_tip: "stellt eine WLAN verbindung her", senseBox_osem_connection_tip: "stellt eine WLAN verbindung her",
senseBox_send_to_osem_tip: "sende Messwert an", senseBox_send_to_osem_tip: "sende Messwert an",
senseBox_send_to_osem: "Sende Messwert an die openSenseMap", senseBox_send_to_osem: "Sende Messwert an die openSenseMap",
senseBox_osem_connection: "Verbinde mit openSenseMap:", senseBox_osem_connection: "Verbinde mit openSenseMap:",
senseBox_osem_host: "opensensemap.org", senseBox_osem_host: "opensensemap.org",
senseBox_osem_host_workshop: "workshop.opensensemap.org", senseBox_osem_host_workshop: "workshop.opensensemap.org",
senseBox_osem_exposure: "Typ", senseBox_osem_exposure: "Typ",
senseBox_osem_stationary: "Stationär", senseBox_osem_stationary: "Stationär",
senseBox_osem_mobile: "Mobil", senseBox_osem_mobile: "Mobil",
senseBox_osem_access_token: "API Schlüssel", senseBox_osem_access_token: "API Schlüssel",
senseBox_send_mobile_to_osem: "Sende Messwert und Standort an die openSenseMap", senseBox_send_mobile_to_osem:
senseBox_send_mobile_to_osem_tip: "Sende Messwert und Standort an die openSenseMap", "Sende Messwert und Standort an die openSenseMap",
} senseBox_send_mobile_to_osem_tip:
"Sende Messwert und Standort an die openSenseMap",
senseBox_osem_restart: "Bei Verbindungsverlust Gerät neustarten?",
};

View File

@ -1,20 +1,20 @@
export const OSEM = { export const OSEM = {
/** /**
* openSenseMap * openSenseMap
*/ */
senseBox_osem_connection_tip: "connect to the openSenseMap",
senseBox_send_to_osem_tip: "sends the measurement to openSenseMap. Make shure to enter the correct BoxID and SensorID",
senseBox_send_to_osem: "Send measurement to openSenseMap",
senseBox_osem_connection: "Connect to openSenseMap",
senseBox_osem_host: "opensensemap.org",
senseBox_osem_host_workshop: "workshop.opensensemap.org",
senseBox_osem_exposure: "Type",
senseBox_osem_stationary: "Stationary",
senseBox_osem_mobile: "Mobile",
senseBox_osem_access_token: "API Key",
senseBox_send_mobile_to_osem: "Send measurement and location to openSenseMap",
senseBox_send_mobile_to_osem_tip: "Send Value and Location to openSenseMap",
}
senseBox_osem_connection_tip: "connect to the openSenseMap",
senseBox_send_to_osem_tip:
"sends the measurement to openSenseMap. Make shure to enter the correct BoxID and SensorID",
senseBox_send_to_osem: "Send measurement to openSenseMap",
senseBox_osem_connection: "Connect to openSenseMap",
senseBox_osem_host: "opensensemap.org",
senseBox_osem_host_workshop: "workshop.opensensemap.org",
senseBox_osem_exposure: "Type",
senseBox_osem_stationary: "Stationary",
senseBox_osem_mobile: "Mobile",
senseBox_osem_access_token: "API Key",
senseBox_send_mobile_to_osem: "Send measurement and location to openSenseMap",
senseBox_send_mobile_to_osem_tip: "Send Value and Location to openSenseMap",
senseBox_osem_restart: "Restart device if disconnected?",
};