|
|
|
@@ -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;
|
|
|
|
|
};
|
|
|
|
|