Merge branch 'master' into ui-updates
This commit is contained in:
@@ -8,6 +8,7 @@ import "./sensebox-web";
|
||||
import "./sensebox-display";
|
||||
import "./sensebox-lora";
|
||||
import "./sensebox-led";
|
||||
import "./sensebox-rtc";
|
||||
import "./sensebox-ble";
|
||||
import "./sensebox-sd";
|
||||
import "./mqtt";
|
||||
|
||||
@@ -1,284 +1,301 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
import { getColour } from '../helpers/colour';
|
||||
|
||||
import * as Blockly from "blockly/core";
|
||||
import { getColour } from "../helpers/colour";
|
||||
|
||||
/*
|
||||
----------------------------------LoRa--------------------------------------------------
|
||||
*/
|
||||
|
||||
Blockly.Blocks['sensebox_lora_initialize_otaa'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_init_otaa_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_LoRa_init_helpurl);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.appendField("Initialize LoRa (OTAA)");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_device_id)
|
||||
.appendField(new Blockly.FieldTextInput("DEVICE ID"), "DEVICEID");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_app_id)
|
||||
.appendField(new Blockly.FieldTextInput("APP ID"), "APPID");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_app_key)
|
||||
.appendField(new Blockly.FieldTextInput("APP KEY"), "APPKEY");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_interval)
|
||||
.appendField(new Blockly.FieldTextInput("5"), "INTERVAL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
Blockly.Blocks["sensebox_lora_initialize_otaa"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_init_otaa_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_LoRa_init_helpurl);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField("Initialize LoRa (OTAA)");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_device_id)
|
||||
.appendField("{")
|
||||
.appendField(new Blockly.FieldTextInput("DEVICE ID"), "DEVICEID")
|
||||
.appendField("}");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_app_id)
|
||||
.appendField("{")
|
||||
.appendField(new Blockly.FieldTextInput("APP ID"), "APPID")
|
||||
.appendField("}");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_app_key)
|
||||
.appendField("{")
|
||||
.appendField(new Blockly.FieldTextInput("APP KEY"), "APPKEY")
|
||||
.appendField("}");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_interval)
|
||||
.appendField(new Blockly.FieldTextInput("5"), "INTERVAL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['sensebox_lora_initialize_abp'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_init_abp_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_LoRa_init_helpurl);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.appendField("Initialize LoRa (ABP)");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_nwskey_id)
|
||||
.appendField(new Blockly.FieldTextInput("NWSKEY"), "NWSKEY");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_appskey_id)
|
||||
.appendField(new Blockly.FieldTextInput("APPSKEY"), "APPSKEY");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_devaddr_id)
|
||||
.appendField(new Blockly.FieldTextInput("DEVADDR"), "DEVADDR");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_interval)
|
||||
.appendField(new Blockly.FieldTextInput("5"), "INTERVAL");
|
||||
// this.appendStatementInput('DO')
|
||||
// .appendField(Blockly.Msg.senseBox_measurements)
|
||||
// .setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
Blockly.Blocks["sensebox_lora_initialize_abp"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_init_abp_tooltip);
|
||||
this.setHelpUrl(Blockly.Msg.senseBox_LoRa_init_helpurl);
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField("Initialize LoRa (ABP)");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_nwskey_id)
|
||||
.appendField("{")
|
||||
.appendField(new Blockly.FieldTextInput("NWSKEY"), "NWSKEY")
|
||||
.appendField("}");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_appskey_id)
|
||||
.appendField("{")
|
||||
.appendField(new Blockly.FieldTextInput("APPSKEY"), "APPSKEY")
|
||||
.appendField("}");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_devaddr_id)
|
||||
.appendField(new Blockly.FieldTextInput("DEVADDR"), "DEVADDR");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_interval)
|
||||
.appendField(new Blockly.FieldTextInput("5"), "INTERVAL");
|
||||
// this.appendStatementInput('DO')
|
||||
// .appendField(Blockly.Msg.senseBox_measurements)
|
||||
// .setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['sensebox_lora_message_send'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_message_tooltip);
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_send_message)
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
Blockly.Blocks["sensebox_lora_message_send"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_message_tooltip);
|
||||
this.setHelpUrl("");
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendStatementInput("DO")
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_send_message)
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_send_lora_sensor_value"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_sensor_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("Value").appendField(
|
||||
Blockly.Msg.senseBox_measurement
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField("Bytes")
|
||||
.appendField(new Blockly.FieldTextInput("2"), "MESSAGE_BYTES");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
/**
|
||||
* Called whenever anything on the workspace changes.
|
||||
* Add warning if block is not nested inside a the correct loop.
|
||||
* @param {!Blockly.Events.Abstract} e Change event.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
onchange: function (e) {
|
||||
var legal = false;
|
||||
// Is the block nested in a loop?
|
||||
var block = this;
|
||||
do {
|
||||
if (this.LOOP_TYPES.indexOf(block.type) !== -1) {
|
||||
legal = true;
|
||||
break;
|
||||
}
|
||||
block = block.getSurroundParent();
|
||||
} while (block);
|
||||
if (legal) {
|
||||
this.setWarningText(null);
|
||||
} else {
|
||||
this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
|
||||
}
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_message_send"],
|
||||
};
|
||||
|
||||
Blockly.Blocks['sensebox_send_lora_sensor_value'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_sensor_tip);
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput('Value')
|
||||
.appendField(Blockly.Msg.senseBox_measurement)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField("Bytes")
|
||||
.appendField(new Blockly.FieldTextInput("2"), "MESSAGE_BYTES");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
/**
|
||||
* Called whenever anything on the workspace changes.
|
||||
* Add warning if block is not nested inside a the correct loop.
|
||||
* @param {!Blockly.Events.Abstract} e Change event.
|
||||
* @this Blockly.Block
|
||||
*/
|
||||
onchange: function (e) {
|
||||
var legal = false;
|
||||
// Is the block nested in a loop?
|
||||
var block = this;
|
||||
do {
|
||||
if (this.LOOP_TYPES.indexOf(block.type) !== -1) {
|
||||
legal = true;
|
||||
break;
|
||||
}
|
||||
block = block.getSurroundParent();
|
||||
} while (block);
|
||||
if (legal) {
|
||||
this.setWarningText(null);
|
||||
} else {
|
||||
this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);
|
||||
}
|
||||
},
|
||||
LOOP_TYPES: ['sensebox_lora_message_send'],
|
||||
Blockly.Blocks["sensebox_lora_ttn_mapper"] = {
|
||||
init: function (block) {
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput().appendField("TTN Mapper");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField("Fix Type Limit")
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(
|
||||
[
|
||||
["0", "0"],
|
||||
["1", "1"],
|
||||
["2", "2"],
|
||||
["3", "3"],
|
||||
].reverse()
|
||||
),
|
||||
"dropdown"
|
||||
);
|
||||
// reverse() because i want 3 be be at first and i'm to lazy to write the array again
|
||||
this.appendValueInput("Latitude")
|
||||
.appendField(Blockly.Msg.senseBox_gps_lat)
|
||||
.setCheck(null);
|
||||
this.appendValueInput("Longitude")
|
||||
.appendField(Blockly.Msg.senseBox_gps_lng)
|
||||
.setCheck(null);
|
||||
this.appendValueInput("Altitude")
|
||||
.appendField(Blockly.Msg.senseBox_gps_alt)
|
||||
.setCheck(null);
|
||||
this.appendValueInput("pDOP").appendField("pDOP").setCheck(null);
|
||||
this.appendValueInput("Fix Type").appendField("Fix Type").setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.senseBox_display_printDisplay_tip);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['sensebox_lora_ttn_mapper'] = {
|
||||
init: function (block) {
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendDummyInput()
|
||||
.appendField("TTN Mapper");
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_RIGHT)
|
||||
.appendField("Fix Type Limit")
|
||||
.appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"]].reverse()), "dropdown");
|
||||
// reverse() because i want 3 be be at first and i'm to lazy to write the array again
|
||||
this.appendValueInput('Latitude')
|
||||
.appendField(Blockly.Msg.senseBox_gps_lat)
|
||||
.setCheck(null);
|
||||
this.appendValueInput('Longitude')
|
||||
.appendField(Blockly.Msg.senseBox_gps_lng)
|
||||
.setCheck(null);
|
||||
this.appendValueInput('Altitude')
|
||||
.appendField(Blockly.Msg.senseBox_gps_alt)
|
||||
.setCheck(null);
|
||||
this.appendValueInput('pDOP')
|
||||
.appendField('pDOP')
|
||||
.setCheck(null);
|
||||
this.appendValueInput('Fix Type')
|
||||
.appendField('Fix Type')
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip(Blockly.Msg.senseBox_display_printDisplay_tip);
|
||||
|
||||
}
|
||||
Blockly.Blocks["sensebox_lora_cayenne_send"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendStatementInput("DO")
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_send_cayenne)
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['sensebox_lora_cayenne_send'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_tip);
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendStatementInput('DO')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_send_cayenne)
|
||||
.setCheck(null);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
}
|
||||
Blockly.Blocks["sensebox_lora_cayenne_temperature"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_temperature_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("Value").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_temperature
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
.appendField(new Blockly.FieldTextInput("1"), "CHANNEL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_cayenne_send"],
|
||||
};
|
||||
Blockly.Blocks['sensebox_lora_cayenne_temperature'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_temperature_tip);
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput('Value')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_temperature)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
.appendField(new Blockly.FieldTextInput("1"), "CHANNEL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ['sensebox_lora_cayenne_send'],
|
||||
Blockly.Blocks["sensebox_lora_cayenne_humidity"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_humidity_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("Value").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_humidity
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
.appendField(new Blockly.FieldTextInput("1"), "CHANNEL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_cayenne_send"],
|
||||
};
|
||||
Blockly.Blocks['sensebox_lora_cayenne_humidity'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_humidity_tip);
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput('Value')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_humidity)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
.appendField(new Blockly.FieldTextInput("1"), "CHANNEL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ['sensebox_lora_cayenne_send'],
|
||||
Blockly.Blocks["sensebox_lora_cayenne_pressure"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_pressure_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("Value").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_pressure
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
.appendField(new Blockly.FieldTextInput("1"), "CHANNEL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_cayenne_send"],
|
||||
};
|
||||
Blockly.Blocks['sensebox_lora_cayenne_pressure'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_pressure_tip);
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput('Value')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_pressure)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
.appendField(new Blockly.FieldTextInput("1"), "CHANNEL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ['sensebox_lora_cayenne_send'],
|
||||
Blockly.Blocks["sensebox_lora_cayenne_luminosity"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_luminosity_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("Value").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_luminosity
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
.appendField(new Blockly.FieldTextInput("1"), "CHANNEL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_cayenne_send"],
|
||||
};
|
||||
Blockly.Blocks['sensebox_lora_cayenne_luminosity'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_luminosity_tip);
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput('Value')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_luminosity)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
.appendField(new Blockly.FieldTextInput("1"), "CHANNEL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ['sensebox_lora_cayenne_send'],
|
||||
Blockly.Blocks["sensebox_lora_cayenne_sensor"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_analog_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("Value").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_analog
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
.appendField(new Blockly.FieldTextInput("1"), "CHANNEL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_cayenne_send"],
|
||||
};
|
||||
Blockly.Blocks['sensebox_lora_cayenne_sensor'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_analog_tip);
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput('Value')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_analog)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
.appendField(new Blockly.FieldTextInput("1"), "CHANNEL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ['sensebox_lora_cayenne_send'],
|
||||
Blockly.Blocks["sensebox_lora_cayenne_accelerometer"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_gyros_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("X").appendField(Blockly.Msg.senseBox_LoRa_cayenne_x);
|
||||
this.appendValueInput("Y").appendField(Blockly.Msg.senseBox_LoRa_cayenne_y);
|
||||
this.appendValueInput("Z").appendField(Blockly.Msg.senseBox_LoRa_cayenne_z);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
.appendField(new Blockly.FieldTextInput("1"), "CHANNEL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_cayenne_send"],
|
||||
};
|
||||
Blockly.Blocks['sensebox_lora_cayenne_accelerometer'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_gyros_tip);
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput('X')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_x)
|
||||
this.appendValueInput('Y')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_y)
|
||||
this.appendValueInput('Z')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_z)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
.appendField(new Blockly.FieldTextInput("1"), "CHANNEL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ['sensebox_lora_cayenne_send'],
|
||||
};
|
||||
Blockly.Blocks['sensebox_lora_cayenne_gps'] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_gps_tip);
|
||||
this.setHelpUrl('');
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput('LAT')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_lat)
|
||||
this.appendValueInput('LNG')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_lng)
|
||||
this.appendValueInput('ALT')
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_alt)
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
.appendField(new Blockly.FieldTextInput("1"), "CHANNEL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ['sensebox_lora_cayenne_send'],
|
||||
Blockly.Blocks["sensebox_lora_cayenne_gps"] = {
|
||||
init: function () {
|
||||
this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_gps_tip);
|
||||
this.setHelpUrl("");
|
||||
this.setColour(getColour().sensebox);
|
||||
this.appendValueInput("LAT").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_lat
|
||||
);
|
||||
this.appendValueInput("LNG").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_lng
|
||||
);
|
||||
this.appendValueInput("ALT").appendField(
|
||||
Blockly.Msg.senseBox_LoRa_cayenne_alt
|
||||
);
|
||||
this.appendDummyInput()
|
||||
.setAlign(Blockly.ALIGN_LEFT)
|
||||
.appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel)
|
||||
.appendField(new Blockly.FieldTextInput("1"), "CHANNEL");
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
},
|
||||
LOOP_TYPES: ["sensebox_lora_cayenne_send"],
|
||||
};
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
import * as Blockly from "blockly";
|
||||
import { getColour } from "../helpers/colour";
|
||||
import * as Types from "../helpers/types";
|
||||
|
||||
Blockly.Blocks["sensebox_rtc_init"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.sensebox_rtc_init);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.sensebox_rtc_init_tooltip);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_rtc_set"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.sensebox_rtc_set);
|
||||
this.appendValueInput("second").appendField(
|
||||
Blockly.Msg.sensebox_rtc_second
|
||||
);
|
||||
this.appendValueInput("minutes").appendField(
|
||||
Blockly.Msg.sensebox_rtc_minutes
|
||||
);
|
||||
this.appendValueInput("hour").appendField(Blockly.Msg.sensebox_rtc_hour);
|
||||
this.appendValueInput("day").appendField(Blockly.Msg.sensebox_rtc_day);
|
||||
this.appendValueInput("month").appendField(Blockly.Msg.sensebox_rtc_month);
|
||||
this.appendValueInput("year").appendField(Blockly.Msg.sensebox_rtc_year);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.sensebox_rtc_set_tooltip);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_rtc_set_ntp"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendValueInput("time").appendField(Blockly.Msg.sensebox_rtc_set_ntp);
|
||||
this.setPreviousStatement(true);
|
||||
this.setNextStatement(true);
|
||||
this.setTooltip(Blockly.Msg.sensebox_rtc_set_ntp_tooltip);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_rtc_get"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput()
|
||||
.appendField(Blockly.Msg.sensebox_rtc_get)
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown([
|
||||
[Blockly.Msg.sensebox_rtc_hour, "hour"],
|
||||
[Blockly.Msg.sensebox_rtc_minutes, "minutes"],
|
||||
[Blockly.Msg.sensebox_rtc_second, "seconds"],
|
||||
[Blockly.Msg.sensebox_rtc_day, "day"],
|
||||
[Blockly.Msg.sensebox_rtc_month, "month"],
|
||||
[Blockly.Msg.sensebox_rtc_year, "year"],
|
||||
]),
|
||||
"dropdown"
|
||||
);
|
||||
this.setOutput(true, Types.LARGE_NUMBER.typeId);
|
||||
this.setTooltip(Blockly.Msg.sensebox_rtc_get_tooltip);
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks["sensebox_rtc_get_timestamp"] = {
|
||||
init: function () {
|
||||
this.setHelpUrl(Blockly.Msg.sensebox_rtc_helpurl);
|
||||
this.setColour(getColour().time);
|
||||
this.appendDummyInput().appendField(Blockly.Msg.sensebox_rtc_get_timestamp);
|
||||
this.setOutput(true);
|
||||
this.setTooltip(Blockly.Msg.sensebox_rtc_get_timestamp_tooltip);
|
||||
},
|
||||
};
|
||||
@@ -238,6 +238,8 @@ Blockly["Arduino"].finish = function (code) {
|
||||
loraSetupCode += Blockly["Arduino"].loraSetupCode_[key] + "\n" || "";
|
||||
}
|
||||
|
||||
setupCode =
|
||||
"\nvoid setup() { \n" + preSetupCode + "\n" + loraSetupCode + "\n}\n";
|
||||
for (const key in Blockly["Arduino"].phyphoxSetupCode_) {
|
||||
phyphoxSetupCode += Blockly["Arduino"].phyphoxSetupCode_[key] + "\n" || "";
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import "./sensebox-display";
|
||||
import "./sensebox-lora";
|
||||
import "./sensebox-led";
|
||||
import "./sensebox";
|
||||
import "./sensebox-rtc";
|
||||
import "./sensebox-ble";
|
||||
import "./sensebox-sd";
|
||||
import "./mqtt";
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
import * as Blockly from "blockly/core";
|
||||
|
||||
Blockly.Arduino.sensebox_lora_initialize_otaa = function (block) {
|
||||
var deivceID = this.getFieldValue('DEVICEID');
|
||||
var appID = this.getFieldValue('APPID');
|
||||
var appKey = this.getFieldValue('APPKEY');
|
||||
var interval = this.getFieldValue('INTERVAL');
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.libraries_['library_spi'] = '#include <SPI.h>';
|
||||
Blockly.Arduino.libraries_['library_lmic'] = '#include <lmic.h>';
|
||||
Blockly.Arduino.libraries_['library_hal'] = '#include <hal/hal.h>';
|
||||
Blockly.Arduino.definitions_['define_LoRaVariablesOTAA'] = `
|
||||
static const u1_t PROGMEM APPEUI[8]= `+ appID + ` ;
|
||||
var deivceID = this.getFieldValue("DEVICEID");
|
||||
var appID = this.getFieldValue("APPID");
|
||||
var appKey = this.getFieldValue("APPKEY");
|
||||
var interval = this.getFieldValue("INTERVAL");
|
||||
Blockly.Arduino.libraries_["library_senseBoxMCU"] =
|
||||
'#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.libraries_["library_spi"] = "#include <SPI.h>";
|
||||
Blockly.Arduino.libraries_["library_lmic"] = "#include <lmic.h>";
|
||||
Blockly.Arduino.libraries_["library_hal"] = "#include <hal/hal.h>";
|
||||
Blockly.Arduino.definitions_["define_LoRaVariablesOTAA"] = `
|
||||
static const u1_t PROGMEM APPEUI[8]= {${appID}};
|
||||
void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI , 8);}
|
||||
|
||||
static const u1_t PROGMEM DEVEUI[8]= `+ deivceID + `;
|
||||
static const u1_t PROGMEM DEVEUI[8]= {${deivceID}};
|
||||
void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI , 8);}
|
||||
|
||||
// This key should be in big endian format (or, since it is not really a
|
||||
// number but a block of memory, endianness does not really apply). In
|
||||
// practice, a key taken from ttnctl can be copied as-is.
|
||||
// The key shown here is the semtech default key.
|
||||
static const u1_t PROGMEM APPKEY[16] = `+ appKey + `;
|
||||
static const u1_t PROGMEM APPKEY[16] = {${appKey}};
|
||||
void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY , 16);}
|
||||
|
||||
static osjob_t sendjob;
|
||||
@@ -38,7 +38,7 @@ Blockly.Arduino.sensebox_lora_initialize_otaa = function (block) {
|
||||
.dio = {PIN_XB1_INT, PIN_XB1_INT, LMIC_UNUSED_PIN},
|
||||
};`;
|
||||
|
||||
Blockly.Arduino.codeFunctions_['functions_initLora'] = `
|
||||
Blockly.Arduino.codeFunctions_["functions_initLora"] = `
|
||||
void initLora() {
|
||||
delay(2000);
|
||||
// LMIC init
|
||||
@@ -48,9 +48,9 @@ Blockly.Arduino.sensebox_lora_initialize_otaa = function (block) {
|
||||
|
||||
// Start job (sending automatically starts OTAA too)
|
||||
do_send(&sendjob);
|
||||
}`
|
||||
}`;
|
||||
|
||||
Blockly.Arduino.codeFunctions_['functions_onEvent'] = `
|
||||
Blockly.Arduino.codeFunctions_["functions_onEvent"] = `
|
||||
void onEvent (ev_t ev) {
|
||||
Serial.print(os_getTime());
|
||||
Serial.print(": ");
|
||||
@@ -120,16 +120,18 @@ Blockly.Arduino.sensebox_lora_initialize_otaa = function (block) {
|
||||
break;
|
||||
}
|
||||
}`;
|
||||
Blockly.Arduino.loraSetupCode_['initLora'] = 'initLora();\n';
|
||||
Blockly.Arduino.setupCode_['serial.begin'] = 'Serial.begin(9600);\ndelay(1000);\n';
|
||||
var code = '';
|
||||
return code;
|
||||
Blockly.Arduino.loraSetupCode_["initLora"] = "initLora();\n";
|
||||
Blockly.Arduino.setupCode_["serial.begin"] =
|
||||
"Serial.begin(9600);\ndelay(1000);\n";
|
||||
var code = "";
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_lora_message_send = function (block) {
|
||||
Blockly.Arduino.libraries_['library_lora_message'] = '#include <LoraMessage.h>';
|
||||
var lora_sensor_values = Blockly.Arduino.statementToCode(block, 'DO');
|
||||
Blockly.Arduino.functionNames_['functions_do_send'] = `
|
||||
Blockly.Arduino.libraries_["library_lora_message"] =
|
||||
"#include <LoraMessage.h>";
|
||||
var lora_sensor_values = Blockly.Arduino.statementToCode(block, "DO");
|
||||
Blockly.Arduino.functionNames_["functions_do_send"] = `
|
||||
void do_send(osjob_t* j){
|
||||
// Check if there is not a current TX/RX job running
|
||||
if (LMIC.opmode & OP_TXRXPEND) {
|
||||
@@ -144,39 +146,41 @@ Blockly.Arduino.sensebox_lora_message_send = function (block) {
|
||||
}
|
||||
// Next TX is scheduled after TX_COMPLETE event.
|
||||
}`;
|
||||
Blockly.Arduino.loopCodeOnce_['os_runloop'] = 'os_runloop_once();'
|
||||
return ''
|
||||
}
|
||||
Blockly.Arduino.loopCodeOnce_["os_runloop"] = "os_runloop_once();";
|
||||
return "";
|
||||
};
|
||||
|
||||
/**
|
||||
* Block send Data to TTN
|
||||
*/
|
||||
Blockly.Arduino.sensebox_send_lora_sensor_value = function (block) {
|
||||
const reading = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || '"Keine Eingabe"';
|
||||
var messageBytes = this.getFieldValue('MESSAGE_BYTES');
|
||||
var code = ''
|
||||
switch (Number(messageBytes)) {
|
||||
case 1:
|
||||
code = `message.addUint8(${reading});\n`
|
||||
break;
|
||||
case 2:
|
||||
code = `message.addUint16(${reading});\n`
|
||||
break;
|
||||
case 3:
|
||||
code = `message.addUint8(${reading});
|
||||
message.addUint16(${reading} >> 8);\n`
|
||||
break;
|
||||
default:
|
||||
code = `message.addUint16(${reading});\n`
|
||||
}
|
||||
return code;
|
||||
const reading =
|
||||
Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
'"Keine Eingabe"';
|
||||
var messageBytes = this.getFieldValue("MESSAGE_BYTES");
|
||||
var code = "";
|
||||
switch (Number(messageBytes)) {
|
||||
case 1:
|
||||
code = `message.addUint8(${reading});\n`;
|
||||
break;
|
||||
case 2:
|
||||
code = `message.addUint16(${reading});\n`;
|
||||
break;
|
||||
case 3:
|
||||
code = `message.addUint8(${reading});
|
||||
message.addUint16(${reading} >> 8);\n`;
|
||||
break;
|
||||
default:
|
||||
code = `message.addUint16(${reading});\n`;
|
||||
}
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_send = function (block) {
|
||||
Blockly.Arduino.libraries_['library_cayene'] = '#include <CayenneLPP.h>';
|
||||
Blockly.Arduino.variables_['variable_cayenne'] = 'CayenneLPP lpp(51);'
|
||||
var lora_sensor_values = Blockly.Arduino.statementToCode(block, 'DO');
|
||||
Blockly.Arduino.functionNames_['functions_do_send'] = `
|
||||
Blockly.Arduino.libraries_["library_cayene"] = "#include <CayenneLPP.h>";
|
||||
Blockly.Arduino.variables_["variable_cayenne"] = "CayenneLPP lpp(51);";
|
||||
var lora_sensor_values = Blockly.Arduino.statementToCode(block, "DO");
|
||||
Blockly.Arduino.functionNames_["functions_do_send"] = `
|
||||
void do_send(osjob_t* j){
|
||||
// Check if there is not a current TX/RX job running
|
||||
if (LMIC.opmode & OP_TXRXPEND) {
|
||||
@@ -191,18 +195,38 @@ Blockly.Arduino.sensebox_lora_cayenne_send = function (block) {
|
||||
}
|
||||
// Next TX is scheduled after TX_COMPLETE event.
|
||||
}`;
|
||||
Blockly.Arduino.loopCodeOnce_['os_runloop'] = 'os_runloop_once();'
|
||||
return '';
|
||||
}
|
||||
Blockly.Arduino.loopCodeOnce_["os_runloop"] = "os_runloop_once();";
|
||||
return "";
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_lora_ttn_mapper = function (block) {
|
||||
var latitude = Blockly.Arduino.valueToCode(this, 'Latitude', Blockly.Arduino.ORDER_ATOMIC)
|
||||
var longitude = Blockly.Arduino.valueToCode(this, 'Longitude', Blockly.Arduino.ORDER_ATOMIC)
|
||||
var altitude = Blockly.Arduino.valueToCode(this, 'Altitude', Blockly.Arduino.ORDER_ATOMIC)
|
||||
var pDOP = Blockly.Arduino.valueToCode(this, 'pDOP', Blockly.Arduino.ORDER_ATOMIC)
|
||||
var fixType = Blockly.Arduino.valueToCode(this, 'Fix Type', Blockly.Arduino.ORDER_ATOMIC)
|
||||
var fixTypeLimit = this.getFieldValue('dropdown');
|
||||
Blockly.Arduino.functionNames_['functions_do_send'] = `
|
||||
var latitude = Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"Latitude",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var longitude = Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"Longitude",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var altitude = Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"Altitude",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var pDOP = Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"pDOP",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var fixType = Blockly.Arduino.valueToCode(
|
||||
this,
|
||||
"Fix Type",
|
||||
Blockly.Arduino.ORDER_ATOMIC
|
||||
);
|
||||
var fixTypeLimit = this.getFieldValue("dropdown");
|
||||
Blockly.Arduino.functionNames_["functions_do_send"] = `
|
||||
void do_send(osjob_t* j){
|
||||
// Check if there is not a current TX/RX job running
|
||||
if (LMIC.opmode & OP_TXRXPEND) {
|
||||
@@ -245,29 +269,30 @@ Blockly.Arduino.sensebox_lora_ttn_mapper = function (block) {
|
||||
}
|
||||
// Next TX is scheduled after TX_COMPLETE event.
|
||||
}`;
|
||||
Blockly.Arduino.loopCodeOnce_['os_runloop'] = 'os_runloop_once();'
|
||||
return '';
|
||||
}
|
||||
Blockly.Arduino.loopCodeOnce_["os_runloop"] = "os_runloop_once();";
|
||||
return "";
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_lora_initialize_abp = function (block) {
|
||||
var nwskey = this.getFieldValue('NWSKEY');
|
||||
var appskey = this.getFieldValue('APPSKEY');
|
||||
var devaddr = this.getFieldValue('DEVADDR');
|
||||
var interval = this.getFieldValue('INTERVAL');
|
||||
Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.libraries_['library_spi'] = '#include <SPI.h>';
|
||||
Blockly.Arduino.libraries_['library_lmic'] = '#include <lmic.h>';
|
||||
Blockly.Arduino.libraries_['library_hal'] = '#include <hal/hal.h>';
|
||||
Blockly.Arduino.definitions_['define_LoRaVariablesABP'] = `
|
||||
var nwskey = this.getFieldValue("NWSKEY");
|
||||
var appskey = this.getFieldValue("APPSKEY");
|
||||
var devaddr = this.getFieldValue("DEVADDR");
|
||||
var interval = this.getFieldValue("INTERVAL");
|
||||
Blockly.Arduino.libraries_["library_senseBoxMCU"] =
|
||||
'#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.libraries_["library_spi"] = "#include <SPI.h>";
|
||||
Blockly.Arduino.libraries_["library_lmic"] = "#include <lmic.h>";
|
||||
Blockly.Arduino.libraries_["library_hal"] = "#include <hal/hal.h>";
|
||||
Blockly.Arduino.definitions_["define_LoRaVariablesABP"] = `
|
||||
// LoRaWAN NwkSKey, network session key
|
||||
// This is the default Semtech key, which is used by the early prototype TTN
|
||||
// network.
|
||||
static const PROGMEM u1_t NWKSKEY[16] = ${nwskey};
|
||||
static const PROGMEM u1_t NWKSKEY[16] = { ${nwskey} };
|
||||
|
||||
// LoRaWAN AppSKey, application session key
|
||||
// This is the default Semtech key, which is used by the early prototype TTN
|
||||
// network.
|
||||
static const u1_t PROGMEM APPSKEY[16] = ${appskey};
|
||||
static const u1_t PROGMEM APPSKEY[16] = { ${appskey} };
|
||||
|
||||
// LoRaWAN end-device address (DevAddr)
|
||||
static const u4_t DEVADDR = 0x${devaddr};
|
||||
@@ -293,7 +318,7 @@ Blockly.Arduino.sensebox_lora_initialize_abp = function (block) {
|
||||
.dio = {PIN_XB1_INT, PIN_XB1_INT, LMIC_UNUSED_PIN},
|
||||
};`;
|
||||
|
||||
Blockly.Arduino.codeFunctions_['functions_initLora'] = `
|
||||
Blockly.Arduino.codeFunctions_["functions_initLora"] = `
|
||||
void initLora() {
|
||||
delay(2000);
|
||||
// LMIC init
|
||||
@@ -359,9 +384,9 @@ Blockly.Arduino.sensebox_lora_initialize_abp = function (block) {
|
||||
|
||||
// Start job
|
||||
do_send(&sendjob);
|
||||
}`
|
||||
}`;
|
||||
|
||||
Blockly.Arduino.codeFunctions_['functions_onEvent'] = `
|
||||
Blockly.Arduino.codeFunctions_["functions_onEvent"] = `
|
||||
void onEvent (ev_t ev) {
|
||||
Serial.print(os_getTime());
|
||||
Serial.print(": ");
|
||||
@@ -426,60 +451,77 @@ Blockly.Arduino.sensebox_lora_initialize_abp = function (block) {
|
||||
break;
|
||||
}
|
||||
}`;
|
||||
Blockly.Arduino.loraSetupCode_['initLora'] = 'initLora();\n';
|
||||
Blockly.Arduino.setupCode_['serial.begin'] = 'Serial.begin(9600);\ndelay(1000);\n';
|
||||
return '';
|
||||
}
|
||||
Blockly.Arduino.loraSetupCode_["initLora"] = "initLora();\n";
|
||||
Blockly.Arduino.setupCode_["serial.begin"] =
|
||||
"Serial.begin(9600);\ndelay(1000);\n";
|
||||
return "";
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_temperature = function (block) {
|
||||
var temperature = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var channel = this.getFieldValue('CHANNEL');
|
||||
var code = `lpp.addTemperature(${channel}, ${temperature});\n`;
|
||||
return code;
|
||||
}
|
||||
var temperature =
|
||||
Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
0;
|
||||
var channel = this.getFieldValue("CHANNEL");
|
||||
var code = `lpp.addTemperature(${channel}, ${temperature});\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_humidity = function (block) {
|
||||
var humidity = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var channel = this.getFieldValue('CHANNEL');
|
||||
var code = `lpp.addRelativeHumidity(${channel}, ${humidity});\n`;
|
||||
return code;
|
||||
}
|
||||
var humidity =
|
||||
Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
0;
|
||||
var channel = this.getFieldValue("CHANNEL");
|
||||
var code = `lpp.addRelativeHumidity(${channel}, ${humidity});\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_pressure = function (block) {
|
||||
var pressure = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var channel = this.getFieldValue('CHANNEL');
|
||||
var code = `lpp.addBarometricPressure(${channel}, ${pressure});\n`;
|
||||
return code;
|
||||
}
|
||||
var pressure =
|
||||
Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
0;
|
||||
var channel = this.getFieldValue("CHANNEL");
|
||||
var code = `lpp.addBarometricPressure(${channel}, ${pressure});\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_luminosity = function (block) {
|
||||
var luminosity = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var channel = this.getFieldValue('CHANNEL');
|
||||
var code = `lpp.addLuminosity(${channel}, ${luminosity});\n`;
|
||||
return code;
|
||||
}
|
||||
var luminosity =
|
||||
Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
0;
|
||||
var channel = this.getFieldValue("CHANNEL");
|
||||
var code = `lpp.addLuminosity(${channel}, ${luminosity});\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_sensor = function (block) {
|
||||
var sensorValue = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var channel = this.getFieldValue('CHANNEL');
|
||||
var code = `lpp.addAnalogInput(${channel}, ${sensorValue});\n`;
|
||||
return code;
|
||||
}
|
||||
var sensorValue =
|
||||
Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
0;
|
||||
var channel = this.getFieldValue("CHANNEL");
|
||||
var code = `lpp.addAnalogInput(${channel}, ${sensorValue});\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_accelerometer = function (block) {
|
||||
var x = Blockly.Arduino.valueToCode(this, 'X', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var y = Blockly.Arduino.valueToCode(this, 'Y', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var z = Blockly.Arduino.valueToCode(this, 'Z', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var channel = this.getFieldValue('CHANNEL');
|
||||
var code = `lpp.addAccelerometer(${channel}, ${x}, ${y}, ${z});\n`;
|
||||
return code;
|
||||
}
|
||||
var x =
|
||||
Blockly.Arduino.valueToCode(this, "X", Blockly.Arduino.ORDER_ATOMIC) || 0;
|
||||
var y =
|
||||
Blockly.Arduino.valueToCode(this, "Y", Blockly.Arduino.ORDER_ATOMIC) || 0;
|
||||
var z =
|
||||
Blockly.Arduino.valueToCode(this, "Z", Blockly.Arduino.ORDER_ATOMIC) || 0;
|
||||
var channel = this.getFieldValue("CHANNEL");
|
||||
var code = `lpp.addAccelerometer(${channel}, ${x}, ${y}, ${z});\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_lora_cayenne_gps = function (block) {
|
||||
var lat = Blockly.Arduino.valueToCode(this, 'LAT', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var lng = Blockly.Arduino.valueToCode(this, 'LNG', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var alt = Blockly.Arduino.valueToCode(this, 'ALT', Blockly.Arduino.ORDER_ATOMIC) || 0
|
||||
var channel = this.getFieldValue('CHANNEL');
|
||||
var code = `lpp.addGPS(${channel}, ${lat}, ${lng}, ${alt});\n`
|
||||
return code;
|
||||
}
|
||||
var lat =
|
||||
Blockly.Arduino.valueToCode(this, "LAT", Blockly.Arduino.ORDER_ATOMIC) || 0;
|
||||
var lng =
|
||||
Blockly.Arduino.valueToCode(this, "LNG", Blockly.Arduino.ORDER_ATOMIC) || 0;
|
||||
var alt =
|
||||
Blockly.Arduino.valueToCode(this, "ALT", Blockly.Arduino.ORDER_ATOMIC) || 0;
|
||||
var channel = this.getFieldValue("CHANNEL");
|
||||
var code = `lpp.addGPS(${channel}, ${lat}, ${lng}, ${alt});\n`;
|
||||
return code;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
import Blockly from "blockly";
|
||||
|
||||
Blockly.Arduino.sensebox_rtc_init = function () {
|
||||
Blockly.Arduino.libraries_["RV8523"] = `#include <RV8523.h>`;
|
||||
Blockly.Arduino.definitions_["RTC"] = `RV8523 rtc;`;
|
||||
Blockly.Arduino.libraries_["library_senseBoxMCU"] =
|
||||
'#include "SenseBoxMCU.h"';
|
||||
Blockly.Arduino.setupCode_["rtc.begin"] = `rtc.begin();`;
|
||||
var code = ``;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_rtc_set = function () {
|
||||
var second =
|
||||
Blockly.Arduino.valueToCode(this, "second", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var minutes =
|
||||
Blockly.Arduino.valueToCode(this, "second", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var hour =
|
||||
Blockly.Arduino.valueToCode(this, "second", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var day =
|
||||
Blockly.Arduino.valueToCode(this, "second", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var month =
|
||||
Blockly.Arduino.valueToCode(this, "second", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
var year =
|
||||
Blockly.Arduino.valueToCode(this, "second", Blockly.Arduino.ORDER_ATOMIC) ||
|
||||
"0";
|
||||
Blockly.Arduino.libraries_["RV8523"] = `#include <RV8523.h>`;
|
||||
Blockly.Arduino.setupCode_["rtc.start"] = `rtc.start();`;
|
||||
Blockly.Arduino.setupCode_[
|
||||
"rtc.batterySwitchOver"
|
||||
] = `rtc.batterySwitchOver(1);`;
|
||||
Blockly.Arduino.setupCode_[
|
||||
"rtc.set"
|
||||
] = `rtc.set(${second}, ${minutes}, ${hour}, ${day}, ${month}, ${year});`;
|
||||
var code = ``;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_rtc_ntp = function () {
|
||||
Blockly.Arduino.libraries_["RV8523"] = `#include <RV8523.h>`;
|
||||
Blockly.Arduino.setupCode_["rtc.start"] = `rtc.start();`;
|
||||
Blockly.Arduino.setupCode_[
|
||||
"rtc.batterySwitchOver"
|
||||
] = `rtc.batterySwitchOver(1);`;
|
||||
Blockly.Arduino.setupCode_[
|
||||
"rtc.set"
|
||||
] = `rtc.set(SECOND, MINUTE, HOUR, DAY, MONTH, YEAR);`;
|
||||
var code = ``;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_rtc_get = function () {
|
||||
var dropdown = this.getFieldValue("dropdown");
|
||||
Blockly.Arduino.libraries_["RV8523"] = `#include <RV8523.h>`;
|
||||
Blockly.Arduino.setupCode_["rtc.start"] = `rtc.start();`;
|
||||
Blockly.Arduino.setupCode_[
|
||||
"rtc.batterySwitchOver"
|
||||
] = `rtc.batterySwitchOver(1);`;
|
||||
Blockly.Arduino.loopCodeOnce_[
|
||||
"rtc_variables"
|
||||
] = `uint8_t sec, min, hour, day, month;\nuint16_t year;`;
|
||||
|
||||
Blockly.Arduino.loopCodeOnce_[
|
||||
"rtc_get"
|
||||
] = `rtc.get(&sec, &min, &hour, &day, &month, &year);`;
|
||||
|
||||
var code = `${dropdown}`;
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
|
||||
Blockly.Arduino.sensebox_rtc_get_timestamp = function () {
|
||||
Blockly.Arduino.libraries_["RV8523"] = `#include <RV8523.h>`;
|
||||
Blockly.Arduino.setupCode_["rtc.start"] = `rtc.start();`;
|
||||
Blockly.Arduino.setupCode_[
|
||||
"rtc.batterySwitchOver"
|
||||
] = `rtc.batterySwitchOver(1);`;
|
||||
Blockly.Arduino.loopCodeOnce_[
|
||||
"rtc_variables"
|
||||
] = `uint8_t sec, min, hour, day, month;\nuint16_t year;`;
|
||||
Blockly.Arduino.variables_["rtc_timestamp"] = `char timestamp[20];`;
|
||||
Blockly.Arduino.loopCodeOnce_[
|
||||
"rtc_get"
|
||||
] = `rtc.get(&sec, &min, &hour, &day, &month, &year);`;
|
||||
|
||||
Blockly.Arduino.loopCodeOnce_[
|
||||
""
|
||||
] = `sprintf(timestamp, "%02d-%02d-%02dT%02d:%02d:%02dZ", year, month, day, hour, min, sec);`;
|
||||
|
||||
var code = `timestamp`;
|
||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||
};
|
||||
@@ -10,6 +10,7 @@ import { DISPLAY } from "./de/sensebox-display";
|
||||
import { LED } from "./de/sensebox-led";
|
||||
import { LORA } from "./de/sensebox-lora";
|
||||
import { OSEM } from "./de/sensebox-osem";
|
||||
import { RTC } from "./de/sensebox-rtc";
|
||||
import { SD } from "./de/sensebox-sd";
|
||||
import { SENSORS } from "./de/sensebox-sensors";
|
||||
import { SENSEBOX } from "./de/sensebox";
|
||||
@@ -36,6 +37,7 @@ export const De = {
|
||||
...LED,
|
||||
...LORA,
|
||||
...OSEM,
|
||||
...RTC,
|
||||
...SD,
|
||||
...SENSORS,
|
||||
...SENSEBOX,
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
export const RTC = {
|
||||
sensebox_rtc_init: "Initialisiere RTC",
|
||||
sensebox_rtc_init_tooltip:
|
||||
"Initialisiere die RTC. Schließe diese an einen der 5 I2C/Wire Anschlüsse an und lege die Batterie ein. Bevor du die Uhrzeit auslesen kannst muss diese zunächst einmal gesetzt werden. Dieser Schritt muss normalerweise nur einmalig durchgeführt werden.",
|
||||
sensebox_rtc_set: "Setze Uhrzeit/Datum der RTC",
|
||||
sensebox_rtc_set_tooltip:
|
||||
"Stellt die Uhrzeit der RTC ein. Beachte, dass du diesen Block im Setup ausführst.",
|
||||
sensebox_rtc_get_timestamp: "Zeitstempel",
|
||||
sensebox_rtc_get_timestamp_tooltip:
|
||||
"Gibt dir einen in ISO 8601 formatierten Zeitstempel zurück. Bsp: 2021-12-24T18:21Z",
|
||||
sensebox_rtc_get: "Wert: ",
|
||||
sensebox_rtc_get_tooltip: "Gibt dir den ausgewählten Wert zurück.",
|
||||
sensebox_rtc_second: "Sekunden",
|
||||
sensebox_rtc_minutes: "Minuten",
|
||||
sensebox_rtc_hour: "Stunden",
|
||||
sensebox_rtc_day: "Tag",
|
||||
sensebox_rtc_month: "Monat",
|
||||
sensebox_rtc_year: "Jahr",
|
||||
};
|
||||
@@ -11,6 +11,7 @@ import { DISPLAY } from "./en/sensebox-display";
|
||||
import { LED } from "./en/sensebox-led";
|
||||
import { LORA } from "./en/sensebox-lora";
|
||||
import { OSEM } from "./en/sensebox-osem";
|
||||
import { RTC } from "./en/sensebox-rtc";
|
||||
import { SD } from "./en/sensebox-sd";
|
||||
import { SENSORS } from "./en/sensebox-sensors";
|
||||
import { TELEGRAM } from "./en/sensebox-telegram";
|
||||
@@ -36,6 +37,7 @@ export const En = {
|
||||
...LED,
|
||||
...LORA,
|
||||
...OSEM,
|
||||
...RTC,
|
||||
...SD,
|
||||
...SENSORS,
|
||||
...SENSEBOX,
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
export const RTC = {
|
||||
sensebox_rtc_init: "Initialise RTC",
|
||||
sensebox_rtc_init_tooltip:
|
||||
"Initialise the RTC. Connect it to one of the 5 I2C/Wire connections and insert the battery. Before you can read out the time, it must first be set. This step usually only needs to be done once.",
|
||||
sensebox_rtc_set: "Set RTC time/date:",
|
||||
sensebox_rtc_set_tooltip:
|
||||
"Sets the time of the RTC. Note that you execute this block in the setup.",
|
||||
sensebox_rtc_get_timestamp: "Get timestamp",
|
||||
sensebox_rtc_get_timestamp_tooltip:
|
||||
"Returns a timestamp formatted in ISO 8601. Ex: 2021-12-24T18:21Z",
|
||||
sensebox_rtc_get_tooltip: "Returns the selected value",
|
||||
sensebox_rtc_set_ntp: "Set time via NTP-Server",
|
||||
sensebox_rtc_get: "Get: ",
|
||||
sensebox_rtc_second: "seconds",
|
||||
sensebox_rtc_minutes: "minutes",
|
||||
sensebox_rtc_hour: "hour",
|
||||
sensebox_rtc_day: "day",
|
||||
sensebox_rtc_month: "month",
|
||||
sensebox_rtc_year: "year",
|
||||
};
|
||||
@@ -484,6 +484,42 @@ class Toolbox extends React.Component {
|
||||
<Block type="time_micros"></Block>
|
||||
<Block type="infinite_loop"></Block>
|
||||
<Block type="sensebox_interval_timer"></Block>
|
||||
<Block type="sensebox_rtc_init"></Block>
|
||||
<Block type="sensebox_rtc_set">
|
||||
<Value name="second">
|
||||
<Block type="math_number">
|
||||
<Field name="NUM">00</Field>
|
||||
</Block>
|
||||
</Value>
|
||||
<Value name="minutes">
|
||||
<Block type="math_number">
|
||||
<Field name="NUM">00</Field>
|
||||
</Block>
|
||||
</Value>
|
||||
<Value name="hour">
|
||||
<Block type="math_number">
|
||||
<Field name="NUM">00</Field>
|
||||
</Block>
|
||||
</Value>
|
||||
<Value name="day">
|
||||
<Block type="math_number">
|
||||
<Field name="NUM">01</Field>
|
||||
</Block>
|
||||
</Value>
|
||||
<Value name="month">
|
||||
<Block type="math_number">
|
||||
<Field name="NUM">01</Field>
|
||||
</Block>
|
||||
</Value>
|
||||
<Value name="year">
|
||||
<Block type="math_number">
|
||||
<Field name="NUM">1970</Field>
|
||||
</Block>
|
||||
</Value>
|
||||
</Block>
|
||||
{/* <Block type="sensebox_rtc_set_ntp"></Block> */}
|
||||
<Block type="sensebox_rtc_get"></Block>
|
||||
<Block type="sensebox_rtc_get_timestamp"></Block>
|
||||
</Category>
|
||||
<Category
|
||||
id="math"
|
||||
|
||||
Reference in New Issue
Block a user