Merge pull request #143 from sensebox/block/add-ethernet-bee
Block/add ethernet bee
This commit is contained in:
commit
df9abdc826
@ -22,6 +22,7 @@ import "./serial";
|
|||||||
import "./time";
|
import "./time";
|
||||||
import "./variables";
|
import "./variables";
|
||||||
import "./lists";
|
import "./lists";
|
||||||
|
import "./watchdog";
|
||||||
import "./webserver";
|
import "./webserver";
|
||||||
|
|
||||||
import "../helpers/types";
|
import "../helpers/types";
|
||||||
|
@ -49,10 +49,10 @@ Blockly.Blocks["sensebox_display_printDisplay"] = {
|
|||||||
.appendField(new FieldSlider(1, 1, 4), "SIZE");
|
.appendField(new FieldSlider(1, 1, 4), "SIZE");
|
||||||
this.appendDummyInput()
|
this.appendDummyInput()
|
||||||
.appendField(Blockly.Msg.senseBox_display_printDisplay_x)
|
.appendField(Blockly.Msg.senseBox_display_printDisplay_x)
|
||||||
.appendField(new FieldSlider(0, 0, 128), "X");
|
.appendField(new FieldSlider(0, 0, 127), "X");
|
||||||
this.appendDummyInput()
|
this.appendDummyInput()
|
||||||
.appendField(Blockly.Msg.senseBox_display_printDisplay_y)
|
.appendField(Blockly.Msg.senseBox_display_printDisplay_y)
|
||||||
.appendField(new FieldSlider(0, 0, 64), "Y");
|
.appendField(new FieldSlider(0, 0, 63), "Y");
|
||||||
this.appendValueInput("printDisplay")
|
this.appendValueInput("printDisplay")
|
||||||
.appendField(Blockly.Msg.senseBox_display_printDisplay_value)
|
.appendField(Blockly.Msg.senseBox_display_printDisplay_value)
|
||||||
.setCheck(null);
|
.setCheck(null);
|
||||||
|
@ -13,13 +13,19 @@ var selectedBox = "";
|
|||||||
|
|
||||||
Blockly.Blocks["sensebox_osem_connection"] = {
|
Blockly.Blocks["sensebox_osem_connection"] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
|
var ssl = "TRUE";
|
||||||
|
var workspace = Blockly.getMainWorkspace();
|
||||||
|
if (workspace.getBlocksByType("sensebox_ethernet").length > 0) {
|
||||||
|
ssl = "FALSE";
|
||||||
|
console.log("ethernet");
|
||||||
|
}
|
||||||
this.setTooltip(Blockly.Msg.senseBox_osem_connection_tip);
|
this.setTooltip(Blockly.Msg.senseBox_osem_connection_tip);
|
||||||
this.setHelpUrl("");
|
this.setHelpUrl("");
|
||||||
this.setColour(getColour().sensebox);
|
this.setColour(getColour().sensebox);
|
||||||
this.appendDummyInput()
|
this.appendDummyInput()
|
||||||
.appendField(Blockly.Msg.senseBox_osem_connection)
|
.appendField(Blockly.Msg.senseBox_osem_connection)
|
||||||
.appendField("SSL")
|
.appendField("SSL")
|
||||||
.appendField(new Blockly.FieldCheckbox("TRUE"), "SSL");
|
.appendField(new Blockly.FieldCheckbox(ssl), "SSL");
|
||||||
this.appendDummyInput()
|
this.appendDummyInput()
|
||||||
.setAlign(Blockly.ALIGN_LEFT)
|
.setAlign(Blockly.ALIGN_LEFT)
|
||||||
.appendField(Blockly.Msg.senseBox_osem_exposure)
|
.appendField(Blockly.Msg.senseBox_osem_exposure)
|
||||||
@ -94,7 +100,6 @@ Blockly.Blocks["sensebox_osem_connection"] = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateShape_(isMobile) {
|
updateShape_(isMobile) {
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
if (this.getInput("lat") == null) {
|
if (this.getInput("lat") == null) {
|
||||||
@ -119,33 +124,6 @@ Blockly.Blocks["sensebox_osem_connection"] = {
|
|||||||
this.removeInput("timeStamp", true);
|
this.removeInput("timeStamp", true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// updateShape_: function () {
|
|
||||||
// var extraFieldExist = this.getFieldValue("gps");
|
|
||||||
// var input = this.getFieldValue("type");
|
|
||||||
// if (input === "Mobile" && extraFieldExist === null) {
|
|
||||||
// this.appendValueInput("lat", "Number").appendField(
|
|
||||||
// Blockly.Msg.senseBox_gps_lat,
|
|
||||||
// "gps"
|
|
||||||
// );
|
|
||||||
// this.appendValueInput("lng", "Number").appendField(
|
|
||||||
// Blockly.Msg.senseBox_gps_lng
|
|
||||||
// );
|
|
||||||
// this.appendValueInput("altitude", "Number").appendField(
|
|
||||||
// Blockly.Msg.senseBox_gps_alt
|
|
||||||
// );
|
|
||||||
// this.appendValueInput("timeStamp", "Number").appendField(
|
|
||||||
// Blockly.Msg.senseBox_gps_timeStamp
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (input === "Stationary" && extraFieldExist !== null) {
|
|
||||||
// this.removeInput("lat");
|
|
||||||
// this.removeInput("lng");
|
|
||||||
// this.removeInput("altitude");
|
|
||||||
// this.removeInput("timeStamp");
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
LOOP_TYPES: ["sensebox_interval_timer"],
|
LOOP_TYPES: ["sensebox_interval_timer"],
|
||||||
};
|
};
|
||||||
Blockly.Blocks["sensebox_send_to_osem"] = {
|
Blockly.Blocks["sensebox_send_to_osem"] = {
|
||||||
|
@ -40,6 +40,87 @@ Blockly.Blocks["sensebox_wifi"] = {
|
|||||||
LOOP_TYPES: ["arduino_functions"],
|
LOOP_TYPES: ["arduino_functions"],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Blockly.Blocks["sensebox_startap"] = {
|
||||||
|
init: function () {
|
||||||
|
this.setTooltip(Blockly.Msg.senseBox_wifi_startap_tooltip);
|
||||||
|
this.setHelpUrl("");
|
||||||
|
this.setColour(getColour().sensebox);
|
||||||
|
this.appendDummyInput().appendField(Blockly.Msg.senseBox_wifi_startap);
|
||||||
|
this.appendDummyInput()
|
||||||
|
.setAlign(Blockly.ALIGN_LEFT)
|
||||||
|
.appendField(Blockly.Msg.senseBox_wifi_ssid)
|
||||||
|
.appendField(new Blockly.FieldTextInput("SSID"), "SSID");
|
||||||
|
this.setHelpUrl(Blockly.Msg.senseBox_wifi_helpurl);
|
||||||
|
this.setPreviousStatement(true, null);
|
||||||
|
this.setNextStatement(true, null);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
Blockly.Blocks["sensebox_ethernet"] = {
|
||||||
|
init: function () {
|
||||||
|
this.setTooltip(Blockly.Msg.senseBox_ethernet_tooltip);
|
||||||
|
this.setHelpUrl("");
|
||||||
|
this.setColour(getColour().sensebox);
|
||||||
|
this.appendDummyInput()
|
||||||
|
.appendField(Blockly.Msg.senseBox_ethernet)
|
||||||
|
.appendField(
|
||||||
|
new Blockly.FieldDropdown([
|
||||||
|
[Blockly.Msg.senseBox_ethernet_dhcp, "Dhcp"],
|
||||||
|
[Blockly.Msg.senseBox_ethernet_manuel_config, "Manual"],
|
||||||
|
]),
|
||||||
|
"dhcp"
|
||||||
|
);
|
||||||
|
this.appendDummyInput()
|
||||||
|
.appendField(Blockly.Msg.senseBox_ethernet_mac)
|
||||||
|
.appendField(
|
||||||
|
new Blockly.FieldTextInput("0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED"),
|
||||||
|
"mac"
|
||||||
|
);
|
||||||
|
|
||||||
|
this.setHelpUrl(Blockly.Msg.senseBox_ethernet_helpurl);
|
||||||
|
this.setPreviousStatement(true, null);
|
||||||
|
this.setNextStatement(true, null);
|
||||||
|
this.getField("dhcp").setValidator(
|
||||||
|
function (val) {
|
||||||
|
this.updateShape_(val === "Manual");
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
updateShape_(isManual) {
|
||||||
|
if (isManual) {
|
||||||
|
this.appendDummyInput("ip-field")
|
||||||
|
.appendField(Blockly.Msg.senseBox_ethernet_ip)
|
||||||
|
.appendField(new Blockly.FieldTextInput("192.168.1.100"), "ip");
|
||||||
|
this.appendDummyInput("subnetmask-field")
|
||||||
|
.appendField(Blockly.Msg.senseBox_ethernet_subnetmask)
|
||||||
|
.appendField(new Blockly.FieldTextInput("255.255.255.0"), "subnetmask");
|
||||||
|
this.appendDummyInput("gateway-field")
|
||||||
|
.appendField(Blockly.Msg.senseBox_ethernet_gateway)
|
||||||
|
.appendField(new Blockly.FieldTextInput("192.168.1.1"), "gateway");
|
||||||
|
this.appendDummyInput("dns-field")
|
||||||
|
.appendField(Blockly.Msg.senseBox_ethernet_dns)
|
||||||
|
.appendField(new Blockly.FieldTextInput("8.8.8.8"), "dns");
|
||||||
|
} else {
|
||||||
|
this.removeInput("ip-field", true);
|
||||||
|
this.removeInput("subnetmask-field", true);
|
||||||
|
this.removeInput("gateway-field", true);
|
||||||
|
this.removeInput("dns-field", true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
Blockly.Blocks["sensebox_ethernetIp"] = {
|
||||||
|
init: function () {
|
||||||
|
this.appendDummyInput().appendField(Blockly.Msg.senseBox_ethernet_ip);
|
||||||
|
|
||||||
|
this.setColour(getColour().sensebox);
|
||||||
|
this.setHelpUrl(Blockly.Msg.senseBox_ethernetIp_helpurl);
|
||||||
|
this.setTooltip(Blockly.Msg.senseBox_ethernet_ip_tooltip);
|
||||||
|
this.setOutput(true, null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Blockly.Blocks["sensebox_wifi_status"] = {
|
Blockly.Blocks["sensebox_wifi_status"] = {
|
||||||
init: function () {
|
init: function () {
|
||||||
this.setTooltip(Blockly.Msg.senseBox_wifi_status_tooltip);
|
this.setTooltip(Blockly.Msg.senseBox_wifi_status_tooltip);
|
||||||
@ -70,18 +151,3 @@ Blockly.Blocks["sensebox_wifi_rssi"] = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
Blockly.Blocks["sensebox_startap"] = {
|
|
||||||
init: function () {
|
|
||||||
this.setTooltip(Blockly.Msg.senseBox_wifi_startap_tooltip);
|
|
||||||
this.setHelpUrl("");
|
|
||||||
this.setColour(getColour().sensebox);
|
|
||||||
this.appendDummyInput().appendField(Blockly.Msg.senseBox_wifi_startap);
|
|
||||||
this.appendDummyInput()
|
|
||||||
.setAlign(Blockly.ALIGN_LEFT)
|
|
||||||
.appendField(Blockly.Msg.senseBox_wifi_ssid)
|
|
||||||
.appendField(new Blockly.FieldTextInput("SSID"), "SSID");
|
|
||||||
this.setHelpUrl(Blockly.Msg.senseBox_wifi_helpurl);
|
|
||||||
this.setPreviousStatement(true, null);
|
|
||||||
this.setNextStatement(true, null);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
28
src/components/Blockly/blocks/watchdog.js
Normal file
28
src/components/Blockly/blocks/watchdog.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import Blockly from "blockly/core";
|
||||||
|
import { getColour } from "../helpers/colour";
|
||||||
|
|
||||||
|
Blockly.Blocks["watchdog_enable"] = {
|
||||||
|
init: function () {
|
||||||
|
this.appendDummyInput()
|
||||||
|
.appendField("Watchdog aktivieren")
|
||||||
|
.appendField(new Blockly.FieldTextInput("10000"), "TIME")
|
||||||
|
.appendField("ms");
|
||||||
|
|
||||||
|
this.setPreviousStatement(true, null);
|
||||||
|
this.setNextStatement(true, null);
|
||||||
|
this.setColour(getColour().io);
|
||||||
|
this.setTooltip("");
|
||||||
|
this.setHelpUrl("");
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
Blockly.Blocks["watchdog_reset"] = {
|
||||||
|
init: function () {
|
||||||
|
this.appendDummyInput().appendField("Watchdog zurücksetzen");
|
||||||
|
this.setPreviousStatement(true, null);
|
||||||
|
this.setNextStatement(true, null);
|
||||||
|
this.setColour(getColour().io);
|
||||||
|
this.setTooltip("");
|
||||||
|
this.setHelpUrl("");
|
||||||
|
},
|
||||||
|
};
|
@ -23,4 +23,5 @@ import "./serial";
|
|||||||
import "./time";
|
import "./time";
|
||||||
import "./variables";
|
import "./variables";
|
||||||
import "./lists";
|
import "./lists";
|
||||||
|
import "./watchdog";
|
||||||
import "./webserver";
|
import "./webserver";
|
||||||
|
@ -17,6 +17,16 @@ Blockly.Arduino.sensebox_send_to_osem = function (block) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Blockly.Arduino.sensebox_osem_connection = function (Block) {
|
Blockly.Arduino.sensebox_osem_connection = function (Block) {
|
||||||
|
var workspace = Blockly.getMainWorkspace();
|
||||||
|
var wifi = false;
|
||||||
|
var ethernet = false;
|
||||||
|
if (workspace.getBlocksByType("sensebox_wifi").length > 0) {
|
||||||
|
wifi = true;
|
||||||
|
ethernet = false;
|
||||||
|
} else if (workspace.getBlocksByType("sensebox_ethernet").length > 0) {
|
||||||
|
ethernet = true;
|
||||||
|
wifi = false;
|
||||||
|
}
|
||||||
var box_id = this.getFieldValue("BoxID");
|
var box_id = this.getFieldValue("BoxID");
|
||||||
var branch = Blockly.Arduino.statementToCode(Block, "DO");
|
var branch = Blockly.Arduino.statementToCode(Block, "DO");
|
||||||
var access_token = this.getFieldValue("access_token");
|
var access_token = this.getFieldValue("access_token");
|
||||||
@ -41,6 +51,23 @@ Blockly.Arduino.sensebox_osem_connection = function (Block) {
|
|||||||
Blockly.Arduino.definitions_["SenseBoxID"] =
|
Blockly.Arduino.definitions_["SenseBoxID"] =
|
||||||
'const char SENSEBOX_ID [] PROGMEM = "' + box_id + '";';
|
'const char SENSEBOX_ID [] PROGMEM = "' + box_id + '";';
|
||||||
Blockly.Arduino.definitions_["host"] =
|
Blockly.Arduino.definitions_["host"] =
|
||||||
|
"const char server [] PROGMEM =" + host + ";";
|
||||||
|
if (wifi === true) {
|
||||||
|
if (ssl === "TRUE") {
|
||||||
|
Blockly.Arduino.definitions_["WiFiSSLClient"] = "WiFiSSLClient client;";
|
||||||
|
port = 443;
|
||||||
|
} else if (ssl === "FALSE") {
|
||||||
|
Blockly.Arduino.definitions_["WiFiClient"] = "WiFiClient client;";
|
||||||
|
port = 80;
|
||||||
|
}
|
||||||
|
} else if (ethernet === true) {
|
||||||
|
if (ssl === "TRUE") {
|
||||||
|
Blockly.Arduino.definitions_["WiFiSSLClient"] = "WiFiSSLClient client;";
|
||||||
|
port = 443;
|
||||||
|
} else if (ssl === "FALSE") {
|
||||||
|
Blockly.Arduino.definitions_["EthernetClient"] = "EthernetClient client;";
|
||||||
|
port = 80;
|
||||||
|
}
|
||||||
'const char server [] PROGMEM ="ingress.opensensemap.org";';
|
'const char server [] PROGMEM ="ingress.opensensemap.org";';
|
||||||
if (ssl === "TRUE") {
|
if (ssl === "TRUE") {
|
||||||
Blockly.Arduino.libraries_["library_bearSSL"] =
|
Blockly.Arduino.libraries_["library_bearSSL"] =
|
||||||
@ -220,7 +247,7 @@ Blockly.Arduino.sensebox_osem_connection = function (Block) {
|
|||||||
lat +
|
lat +
|
||||||
"/float(10000000)),(" +
|
"/float(10000000)),(" +
|
||||||
lng +
|
lng +
|
||||||
"/float(10000000),(" +
|
"/float(10000000)),(" +
|
||||||
altitude +
|
altitude +
|
||||||
"/float(100))," +
|
"/float(100))," +
|
||||||
timestamp +
|
timestamp +
|
||||||
|
@ -14,19 +14,22 @@ Blockly.Arduino.sensebox_rtc_set = function () {
|
|||||||
Blockly.Arduino.valueToCode(this, "second", Blockly.Arduino.ORDER_ATOMIC) ||
|
Blockly.Arduino.valueToCode(this, "second", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||||
"0";
|
"0";
|
||||||
var minutes =
|
var minutes =
|
||||||
Blockly.Arduino.valueToCode(this, "second", Blockly.Arduino.ORDER_ATOMIC) ||
|
Blockly.Arduino.valueToCode(
|
||||||
"0";
|
this,
|
||||||
|
"minutes",
|
||||||
|
Blockly.Arduino.ORDER_ATOMIC
|
||||||
|
) || "0";
|
||||||
var hour =
|
var hour =
|
||||||
Blockly.Arduino.valueToCode(this, "second", Blockly.Arduino.ORDER_ATOMIC) ||
|
Blockly.Arduino.valueToCode(this, "hour", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||||
"0";
|
"0";
|
||||||
var day =
|
var day =
|
||||||
Blockly.Arduino.valueToCode(this, "second", Blockly.Arduino.ORDER_ATOMIC) ||
|
Blockly.Arduino.valueToCode(this, "day", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||||
"0";
|
"0";
|
||||||
var month =
|
var month =
|
||||||
Blockly.Arduino.valueToCode(this, "second", Blockly.Arduino.ORDER_ATOMIC) ||
|
Blockly.Arduino.valueToCode(this, "month", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||||
"0";
|
"0";
|
||||||
var year =
|
var year =
|
||||||
Blockly.Arduino.valueToCode(this, "second", Blockly.Arduino.ORDER_ATOMIC) ||
|
Blockly.Arduino.valueToCode(this, "year", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||||
"0";
|
"0";
|
||||||
Blockly.Arduino.libraries_["RV8523"] = `#include <RV8523.h>`;
|
Blockly.Arduino.libraries_["RV8523"] = `#include <RV8523.h>`;
|
||||||
Blockly.Arduino.setupCode_["rtc.start"] = `rtc.start();`;
|
Blockly.Arduino.setupCode_["rtc.start"] = `rtc.start();`;
|
||||||
|
@ -162,15 +162,15 @@ void addMeasurement(const char *sensorId, float value) {
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
Blockly.Arduino.functionNames_["writeMeasurementsToSdCard"] = `
|
Blockly.Arduino.functionNames_["writeMeasurementsToSdCard"] = `
|
||||||
void writeMeasurementsToSdCard(char* timeStamp, uint32_t latitudes, uint32_t longitudes) {
|
void writeMeasurementsToSdCard(char* timeStamp, int32_t latitudes, int32_t longitudes) {
|
||||||
// iterate throug the measurements array
|
// iterate throug the measurements array
|
||||||
for (uint8_t i = 0; i < num_measurements; i++) {
|
for (uint8_t i = 0; i < num_measurements; i++) {
|
||||||
char lng[20];
|
char lng[20];
|
||||||
char lat[20];
|
char lat[20];
|
||||||
float longitude = longitudes / (float)10000000;
|
float longitude = longitudes / (float)10000000;
|
||||||
float latitude = latitudes / (float)10000000;
|
float latitude = latitudes / (float)10000000;
|
||||||
dtostrf(longitude, 2, 7, lng);
|
dtostrf(longitude, 8, 7, lng);
|
||||||
dtostrf(latitude, 1, 7, lat);
|
dtostrf(latitude, 8, 7, lat);
|
||||||
sprintf_P(buffer, PSTR("%s,%9.2f,%s,%02s,%02s"), measurements[i].sensorId, measurements[i].value, timeStamp, lng, lat);
|
sprintf_P(buffer, PSTR("%s,%9.2f,%s,%02s,%02s"), measurements[i].sensorId, measurements[i].value, timeStamp, lng, lat);
|
||||||
// transmit buffer to client
|
// transmit buffer to client
|
||||||
${filename}.println(buffer);
|
${filename}.println(buffer);
|
||||||
|
@ -58,3 +58,57 @@ Blockly.Arduino.sensebox_startap = function (block) {
|
|||||||
var code = "";
|
var code = "";
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Blockly.Arduino.sensebox_ethernet = function () {
|
||||||
|
var ip = this.getFieldValue("ip");
|
||||||
|
var gateway = this.getFieldValue("gateway");
|
||||||
|
var subnetmask = this.getFieldValue("subnetmask");
|
||||||
|
var dns = this.getFieldValue("dns");
|
||||||
|
var mac = this.getFieldValue("mac");
|
||||||
|
var dhcp = this.getFieldValue("dhcp");
|
||||||
|
|
||||||
|
Blockly.Arduino.libraries_["library_senseBoxMCU"] =
|
||||||
|
'#include "SenseBoxMCU.h"';
|
||||||
|
Blockly.Arduino.libraries_["library_ethernet"] = "#include <Ethernet.h>";
|
||||||
|
|
||||||
|
Blockly.Arduino.definitions_["ethernet_config"] = `
|
||||||
|
byte mac[] = { ${mac}};`;
|
||||||
|
if (dhcp === "Manual") {
|
||||||
|
Blockly.Arduino.definitions_["ethernet_manual_config"] = `
|
||||||
|
//Configure static IP setup (only needed if DHCP is disabled)
|
||||||
|
IPAddress myIp(${ip.replaceAll(".", ", ")});
|
||||||
|
IPAddress myDns(${dns.replaceAll(".", ",")});
|
||||||
|
IPAddress myGateway(${gateway.replaceAll(".", ",")});
|
||||||
|
IPAddress mySubnet(${subnetmask.replaceAll(".", ",")});
|
||||||
|
`;
|
||||||
|
Blockly.Arduino.setupCode_["ethernet_setup"] = `
|
||||||
|
Ethernet.init(23);
|
||||||
|
// start the Ethernet connection:
|
||||||
|
if (Ethernet.begin(mac) == 0) {
|
||||||
|
// no point in carrying on, so do nothing forevermore:
|
||||||
|
// try to congifure using IP address instead of DHCP:
|
||||||
|
Ethernet.begin(mac, myIp);
|
||||||
|
}
|
||||||
|
// give the Ethernet shield a second to initialize:
|
||||||
|
delay(1000);
|
||||||
|
`;
|
||||||
|
} else {
|
||||||
|
Blockly.Arduino.setupCode_["ethernet_setup"] = `
|
||||||
|
Ethernet.init(23);
|
||||||
|
// start the Ethernet connection:
|
||||||
|
Ethernet.begin(mac);
|
||||||
|
// give the Ethernet shield a second to initialize:
|
||||||
|
delay(1000);
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
var code = "";
|
||||||
|
return code;
|
||||||
|
};
|
||||||
|
|
||||||
|
Blockly.Arduino.sensebox_ethernetIp = function () {
|
||||||
|
var code = "Ethernet.localIP()";
|
||||||
|
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||||
|
};
|
||||||
|
|
||||||
|
16
src/components/Blockly/generator/watchdog.js
Normal file
16
src/components/Blockly/generator/watchdog.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import * as Blockly from "blockly/core";
|
||||||
|
|
||||||
|
Blockly.Arduino.watchdog_enable = function () {
|
||||||
|
var time = this.getFieldValue("TIME");
|
||||||
|
|
||||||
|
Blockly.Arduino.libraries_["Adafruit_sleepydog"] =
|
||||||
|
"#include <Adafruit_SleepyDog.h>";
|
||||||
|
Blockly.Arduino.setupCode_["watchdog_enable"] = `Watchdog.enable(${time});`;
|
||||||
|
var code = "";
|
||||||
|
return code;
|
||||||
|
};
|
||||||
|
|
||||||
|
Blockly.Arduino.watchdog_reset = function () {
|
||||||
|
var code = "Watchdog.reset();";
|
||||||
|
return code;
|
||||||
|
};
|
@ -14,6 +14,7 @@ const maxInstances = {
|
|||||||
sensebox_lora_initialize_otaa: 1,
|
sensebox_lora_initialize_otaa: 1,
|
||||||
sensebox_lora_initialize_abp: 1,
|
sensebox_lora_initialize_abp: 1,
|
||||||
sensebox_phyphox_init: 1,
|
sensebox_phyphox_init: 1,
|
||||||
|
sensebox_ethernet: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getMaxInstances = () => {
|
export const getMaxInstances = () => {
|
||||||
|
@ -16,4 +16,14 @@ export const WEB = {
|
|||||||
senseBox_wifi_startap_tooltip:
|
senseBox_wifi_startap_tooltip:
|
||||||
"Erstellt einen WiFi-Accesspoint zu dem du dich verbinden kannst. Beachte, dass immer nur 1 Gerät gleichzeitig verbunden werden kann.",
|
"Erstellt einen WiFi-Accesspoint zu dem du dich verbinden kannst. Beachte, dass immer nur 1 Gerät gleichzeitig verbunden werden kann.",
|
||||||
senseBox_wifi_helpurl: "https://docs.sensebox.de/blockly/blockly-web-wifi/",
|
senseBox_wifi_helpurl: "https://docs.sensebox.de/blockly/blockly-web-wifi/",
|
||||||
|
senseBox_ethernet: "Verbinde mit Ethernet",
|
||||||
|
senseBox_ethernet_dhcp: "DHCP",
|
||||||
|
senseBox_ethernet_manuel_config: "Manuelle Konfiguration",
|
||||||
|
senseBox_ethernet_ip: "IP-Adresse",
|
||||||
|
senseBox_ethernet_gateway: "Gateway",
|
||||||
|
senseBox_ethernet_subnetmask: "Subnetzmaske",
|
||||||
|
senseBox_ethernet_mac: "MAC-Adresse",
|
||||||
|
senseBox_ethernet_dns: "DNS-Server",
|
||||||
|
senseBox_ethernet_tooltip:
|
||||||
|
"Verbinde das LAN-Bee mit dem Steckplatz XBEE1. Die meisten Netzwerke verwenden DHCP und vergeben automatisch eine IP-Adresse. Solltest du eine Manuelle Konfiguration durchführen wollen wählen im Dropdown Menü **Manuelle Konfiguration** aus und gebe die entsprechenden Daten ein.",
|
||||||
};
|
};
|
||||||
|
@ -17,4 +17,14 @@ export const WEB = {
|
|||||||
"Creates a WiFi access point to which you can connect. Note that only 1 device can be connected at a time.",
|
"Creates a WiFi access point to which you can connect. Note that only 1 device can be connected at a time.",
|
||||||
senseBox_wifi_helpurl:
|
senseBox_wifi_helpurl:
|
||||||
"https://en.docs.sensebox.de/blockly/blockly-web-wifi/",
|
"https://en.docs.sensebox.de/blockly/blockly-web-wifi/",
|
||||||
|
senseBox_ethernet: "Connect to Ethernet",
|
||||||
|
senseBox_ethernet_dhcp: "DHCP",
|
||||||
|
senseBox_ethernet_manuel_config: "Manual configuration",
|
||||||
|
senseBox_ethernet_ip: "IP address",
|
||||||
|
senseBox_ethernet_gateway: "Gateway",
|
||||||
|
senseBox_ethernet_subnetmask: "Subnet mask",
|
||||||
|
senseBox_ethernet_mac: "MAC address",
|
||||||
|
senseBox_ethernet_dns: "DNS-Server",
|
||||||
|
senseBox_ethernet_tooltip:
|
||||||
|
"Connect the LAN-Bee to the XBEE1 slot. Most networks use DHCP and assign an IP address automatically. If you want to do a manual configuration select **Manual Configuration** in the dropdown menu and enter the appropriate data.",
|
||||||
};
|
};
|
||||||
|
@ -98,6 +98,10 @@ class Toolbox extends React.Component {
|
|||||||
<Block type="sensebox_get_ip" />
|
<Block type="sensebox_get_ip" />
|
||||||
<Block type="sensebox_startap" />
|
<Block type="sensebox_startap" />
|
||||||
</Category>
|
</Category>
|
||||||
|
<Category name="Ethernet" colour={getColour().sensebox}>
|
||||||
|
<Block type="sensebox_ethernet" />
|
||||||
|
<Block type="sensebox_ethernetIp" />
|
||||||
|
</Category>
|
||||||
<Category name="SD" colour={getColour().sensebox}>
|
<Category name="SD" colour={getColour().sensebox}>
|
||||||
<Block type="sensebox_sd_create_file" />
|
<Block type="sensebox_sd_create_file" />
|
||||||
<Block type="sensebox_sd_open_file">
|
<Block type="sensebox_sd_open_file">
|
||||||
@ -613,6 +617,7 @@ class Toolbox extends React.Component {
|
|||||||
custom="PROCEDURE"
|
custom="PROCEDURE"
|
||||||
></Category>
|
></Category>
|
||||||
<sep></sep>
|
<sep></sep>
|
||||||
|
<Category name="Advanced" colour={getColour().io}>
|
||||||
<Category name={Blockly.Msg.toolbox_io} colour={getColour().io}>
|
<Category name={Blockly.Msg.toolbox_io} colour={getColour().io}>
|
||||||
<Block type="io_digitalwrite"></Block>
|
<Block type="io_digitalwrite"></Block>
|
||||||
<Block type="io_digitalread"></Block>
|
<Block type="io_digitalread"></Block>
|
||||||
@ -636,6 +641,11 @@ class Toolbox extends React.Component {
|
|||||||
</Value>
|
</Value>
|
||||||
</Block>
|
</Block>
|
||||||
</Category>
|
</Category>
|
||||||
|
<Category name="Watchdog" colour={getColour().io}>
|
||||||
|
<Block type="watchdog_enable"></Block>
|
||||||
|
<Block type="watchdog_reset"></Block>
|
||||||
|
</Category>
|
||||||
|
</Category>
|
||||||
{/* this block is the initial block of the workspace; not necessary
|
{/* this block is the initial block of the workspace; not necessary
|
||||||
to display, because it can only be used once anyway
|
to display, because it can only be used once anyway
|
||||||
<Category name="Procedures" colour={getColour().procedures}>
|
<Category name="Procedures" colour={getColour().procedures}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user