parent
							
								
									f6947f8c6b
								
							
						
					
					
						commit
						1e979f948c
					
				| @ -1,284 +1,301 @@ | |||||||
| import * as Blockly from 'blockly/core'; | import * as Blockly from "blockly/core"; | ||||||
| import { getColour } from '../helpers/colour'; | import { getColour } from "../helpers/colour"; | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| /* | /* | ||||||
| ----------------------------------LoRa-------------------------------------------------- | ----------------------------------LoRa-------------------------------------------------- | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['sensebox_lora_initialize_otaa'] = { | Blockly.Blocks["sensebox_lora_initialize_otaa"] = { | ||||||
|     init: function () { |   init: function () { | ||||||
|         this.setTooltip(Blockly.Msg.senseBox_LoRa_init_otaa_tooltip); |     this.setTooltip(Blockly.Msg.senseBox_LoRa_init_otaa_tooltip); | ||||||
|         this.setHelpUrl(Blockly.Msg.senseBox_LoRa_init_helpurl); |     this.setHelpUrl(Blockly.Msg.senseBox_LoRa_init_helpurl); | ||||||
|         this.setColour(getColour().sensebox); |     this.setColour(getColour().sensebox); | ||||||
|         this.appendDummyInput() |     this.appendDummyInput().appendField("Initialize LoRa (OTAA)"); | ||||||
|             .appendField("Initialize LoRa (OTAA)"); |     this.appendDummyInput() | ||||||
|         this.appendDummyInput() |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|             .setAlign(Blockly.ALIGN_LEFT) |       .appendField(Blockly.Msg.senseBox_LoRa_device_id) | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_device_id) |       .appendField("{") | ||||||
|             .appendField(new Blockly.FieldTextInput("DEVICE ID"), "DEVICEID"); |       .appendField(new Blockly.FieldTextInput("DEVICE ID"), "DEVICEID") | ||||||
|         this.appendDummyInput() |       .appendField("}"); | ||||||
|             .setAlign(Blockly.ALIGN_LEFT) |     this.appendDummyInput() | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_app_id) |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|             .appendField(new Blockly.FieldTextInput("APP ID"), "APPID"); |       .appendField(Blockly.Msg.senseBox_LoRa_app_id) | ||||||
|         this.appendDummyInput() |       .appendField("{") | ||||||
|             .setAlign(Blockly.ALIGN_LEFT) |       .appendField(new Blockly.FieldTextInput("APP ID"), "APPID") | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_app_key) |       .appendField("}"); | ||||||
|             .appendField(new Blockly.FieldTextInput("APP KEY"), "APPKEY"); |     this.appendDummyInput() | ||||||
|         this.appendDummyInput() |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|             .setAlign(Blockly.ALIGN_LEFT) |       .appendField(Blockly.Msg.senseBox_LoRa_app_key) | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_interval) |       .appendField("{") | ||||||
|             .appendField(new Blockly.FieldTextInput("5"), "INTERVAL"); |       .appendField(new Blockly.FieldTextInput("APP KEY"), "APPKEY") | ||||||
|         this.setPreviousStatement(true, null); |       .appendField("}"); | ||||||
|         this.setNextStatement(true, null); |     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'] = { | Blockly.Blocks["sensebox_lora_initialize_abp"] = { | ||||||
|     init: function () { |   init: function () { | ||||||
|         this.setTooltip(Blockly.Msg.senseBox_LoRa_init_abp_tooltip); |     this.setTooltip(Blockly.Msg.senseBox_LoRa_init_abp_tooltip); | ||||||
|         this.setHelpUrl(Blockly.Msg.senseBox_LoRa_init_helpurl); |     this.setHelpUrl(Blockly.Msg.senseBox_LoRa_init_helpurl); | ||||||
|         this.setColour(getColour().sensebox); |     this.setColour(getColour().sensebox); | ||||||
|         this.appendDummyInput() |     this.appendDummyInput().appendField("Initialize LoRa (ABP)"); | ||||||
|             .appendField("Initialize LoRa (ABP)"); |     this.appendDummyInput() | ||||||
|         this.appendDummyInput() |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|             .setAlign(Blockly.ALIGN_LEFT) |       .appendField(Blockly.Msg.senseBox_LoRa_nwskey_id) | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_nwskey_id) |       .appendField("{") | ||||||
|             .appendField(new Blockly.FieldTextInput("NWSKEY"), "NWSKEY"); |       .appendField(new Blockly.FieldTextInput("NWSKEY"), "NWSKEY") | ||||||
|         this.appendDummyInput() |       .appendField("}"); | ||||||
|             .setAlign(Blockly.ALIGN_LEFT) |     this.appendDummyInput() | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_appskey_id) |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|             .appendField(new Blockly.FieldTextInput("APPSKEY"), "APPSKEY"); |       .appendField(Blockly.Msg.senseBox_LoRa_appskey_id) | ||||||
|         this.appendDummyInput() |       .appendField("{") | ||||||
|             .setAlign(Blockly.ALIGN_LEFT) |       .appendField(new Blockly.FieldTextInput("APPSKEY"), "APPSKEY") | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_devaddr_id) |       .appendField("}"); | ||||||
|             .appendField(new Blockly.FieldTextInput("DEVADDR"), "DEVADDR"); |     this.appendDummyInput() | ||||||
|         this.appendDummyInput() |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|             .setAlign(Blockly.ALIGN_LEFT) |       .appendField(Blockly.Msg.senseBox_LoRa_devaddr_id) | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_interval) |       .appendField(new Blockly.FieldTextInput("DEVADDR"), "DEVADDR"); | ||||||
|             .appendField(new Blockly.FieldTextInput("5"), "INTERVAL"); |     this.appendDummyInput() | ||||||
|         // this.appendStatementInput('DO')
 |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|         //     .appendField(Blockly.Msg.senseBox_measurements)
 |       .appendField(Blockly.Msg.senseBox_LoRa_interval) | ||||||
|         //     .setCheck(null);
 |       .appendField(new Blockly.FieldTextInput("5"), "INTERVAL"); | ||||||
|         this.setPreviousStatement(true, null); |     // this.appendStatementInput('DO')
 | ||||||
|         this.setNextStatement(true, null); |     //     .appendField(Blockly.Msg.senseBox_measurements)
 | ||||||
|     }, |     //     .setCheck(null);
 | ||||||
|  |     this.setPreviousStatement(true, null); | ||||||
|  |     this.setNextStatement(true, null); | ||||||
|  |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['sensebox_lora_message_send'] = { | Blockly.Blocks["sensebox_lora_message_send"] = { | ||||||
|     init: function () { |   init: function () { | ||||||
|         this.setTooltip(Blockly.Msg.senseBox_LoRa_message_tooltip); |     this.setTooltip(Blockly.Msg.senseBox_LoRa_message_tooltip); | ||||||
|         this.setHelpUrl(''); |     this.setHelpUrl(""); | ||||||
|         this.setColour(getColour().sensebox); |     this.setColour(getColour().sensebox); | ||||||
|         this.appendStatementInput('DO') |     this.appendStatementInput("DO") | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_send_message) |       .appendField(Blockly.Msg.senseBox_LoRa_send_message) | ||||||
|             .setCheck(null); |       .setCheck(null); | ||||||
|         this.setPreviousStatement(true, null); |     this.setPreviousStatement(true, null); | ||||||
|         this.setNextStatement(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'] = { | Blockly.Blocks["sensebox_lora_ttn_mapper"] = { | ||||||
|     init: function () { |   init: function (block) { | ||||||
|         this.setTooltip(Blockly.Msg.senseBox_LoRa_sensor_tip); |     this.setColour(getColour().sensebox); | ||||||
|         this.setHelpUrl(''); |     this.appendDummyInput().appendField("TTN Mapper"); | ||||||
|         this.setColour(getColour().sensebox); |     this.appendDummyInput() | ||||||
|         this.appendValueInput('Value') |       .setAlign(Blockly.ALIGN_RIGHT) | ||||||
|             .appendField(Blockly.Msg.senseBox_measurement) |       .appendField("Fix Type Limit") | ||||||
|         this.appendDummyInput() |       .appendField( | ||||||
|             .setAlign(Blockly.ALIGN_LEFT) |         new Blockly.FieldDropdown( | ||||||
|             .appendField("Bytes") |           [ | ||||||
|             .appendField(new Blockly.FieldTextInput("2"), "MESSAGE_BYTES"); |             ["0", "0"], | ||||||
|         this.setPreviousStatement(true, null); |             ["1", "1"], | ||||||
|         this.setNextStatement(true, null); |             ["2", "2"], | ||||||
|     }, |             ["3", "3"], | ||||||
|     /** |           ].reverse() | ||||||
|      * Called whenever anything on the workspace changes. |         ), | ||||||
|      * Add warning if block is not nested inside a the correct loop. |         "dropdown" | ||||||
|      * @param {!Blockly.Events.Abstract} e Change event. |       ); | ||||||
|      * @this Blockly.Block |     // reverse() because i want 3 be be at first and i'm to lazy to write the array again
 | ||||||
|      */ |     this.appendValueInput("Latitude") | ||||||
|     onchange: function (e) { |       .appendField(Blockly.Msg.senseBox_gps_lat) | ||||||
|         var legal = false; |       .setCheck(null); | ||||||
|         // Is the block nested in a loop?
 |     this.appendValueInput("Longitude") | ||||||
|         var block = this; |       .appendField(Blockly.Msg.senseBox_gps_lng) | ||||||
|         do { |       .setCheck(null); | ||||||
|             if (this.LOOP_TYPES.indexOf(block.type) !== -1) { |     this.appendValueInput("Altitude") | ||||||
|                 legal = true; |       .appendField(Blockly.Msg.senseBox_gps_alt) | ||||||
|                 break; |       .setCheck(null); | ||||||
|             } |     this.appendValueInput("pDOP").appendField("pDOP").setCheck(null); | ||||||
|             block = block.getSurroundParent(); |     this.appendValueInput("Fix Type").appendField("Fix Type").setCheck(null); | ||||||
|         } while (block); |     this.setPreviousStatement(true, null); | ||||||
|         if (legal) { |     this.setNextStatement(true, null); | ||||||
|             this.setWarningText(null); |     this.setTooltip(Blockly.Msg.senseBox_display_printDisplay_tip); | ||||||
|         } else { |   }, | ||||||
|             this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING); |  | ||||||
|         } |  | ||||||
|     }, |  | ||||||
|     LOOP_TYPES: ['sensebox_lora_message_send'], |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['sensebox_lora_ttn_mapper'] = { | Blockly.Blocks["sensebox_lora_cayenne_send"] = { | ||||||
|     init: function (block) { |   init: function () { | ||||||
|         this.setColour(getColour().sensebox); |     this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_tip); | ||||||
|         this.appendDummyInput() |     this.setHelpUrl(""); | ||||||
|             .appendField("TTN Mapper"); |     this.setColour(getColour().sensebox); | ||||||
|         this.appendDummyInput() |     this.appendStatementInput("DO") | ||||||
|             .setAlign(Blockly.ALIGN_RIGHT) |       .appendField(Blockly.Msg.senseBox_LoRa_send_cayenne) | ||||||
|             .appendField("Fix Type Limit") |       .setCheck(null); | ||||||
|             .appendField(new Blockly.FieldDropdown([["0", "0"], ["1", "1"], ["2", "2"], ["3", "3"]].reverse()), "dropdown"); |     this.setPreviousStatement(true, null); | ||||||
|         // reverse() because i want 3 be be at first and i'm to lazy to write the array again
 |     this.setNextStatement(true, null); | ||||||
|         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_temperature"] = { | ||||||
| Blockly.Blocks['sensebox_lora_cayenne_send'] = { |   init: function () { | ||||||
|     init: function () { |     this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_temperature_tip); | ||||||
|         this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_tip); |     this.setHelpUrl(""); | ||||||
|         this.setHelpUrl(''); |     this.setColour(getColour().sensebox); | ||||||
|         this.setColour(getColour().sensebox); |     this.appendValueInput("Value").appendField( | ||||||
|         this.appendStatementInput('DO') |       Blockly.Msg.senseBox_LoRa_cayenne_temperature | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_send_cayenne) |     ); | ||||||
|             .setCheck(null); |     this.appendDummyInput() | ||||||
|         this.setPreviousStatement(true, null); |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|         this.setNextStatement(true, null); |       .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'] = { | Blockly.Blocks["sensebox_lora_cayenne_humidity"] = { | ||||||
|     init: function () { |   init: function () { | ||||||
|         this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_temperature_tip); |     this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_humidity_tip); | ||||||
|         this.setHelpUrl(''); |     this.setHelpUrl(""); | ||||||
|         this.setColour(getColour().sensebox); |     this.setColour(getColour().sensebox); | ||||||
|         this.appendValueInput('Value') |     this.appendValueInput("Value").appendField( | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_cayenne_temperature) |       Blockly.Msg.senseBox_LoRa_cayenne_humidity | ||||||
|         this.appendDummyInput() |     ); | ||||||
|             .setAlign(Blockly.ALIGN_LEFT) |     this.appendDummyInput() | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel) |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|             .appendField(new Blockly.FieldTextInput("1"), "CHANNEL"); |       .appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel) | ||||||
|         this.setPreviousStatement(true, null); |       .appendField(new Blockly.FieldTextInput("1"), "CHANNEL"); | ||||||
|         this.setNextStatement(true, null); |     this.setPreviousStatement(true, null); | ||||||
|     }, |     this.setNextStatement(true, null); | ||||||
|     LOOP_TYPES: ['sensebox_lora_cayenne_send'], |   }, | ||||||
|  |   LOOP_TYPES: ["sensebox_lora_cayenne_send"], | ||||||
| }; | }; | ||||||
| Blockly.Blocks['sensebox_lora_cayenne_humidity'] = { | Blockly.Blocks["sensebox_lora_cayenne_pressure"] = { | ||||||
|     init: function () { |   init: function () { | ||||||
|         this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_humidity_tip); |     this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_pressure_tip); | ||||||
|         this.setHelpUrl(''); |     this.setHelpUrl(""); | ||||||
|         this.setColour(getColour().sensebox); |     this.setColour(getColour().sensebox); | ||||||
|         this.appendValueInput('Value') |     this.appendValueInput("Value").appendField( | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_cayenne_humidity) |       Blockly.Msg.senseBox_LoRa_cayenne_pressure | ||||||
|         this.appendDummyInput() |     ); | ||||||
|             .setAlign(Blockly.ALIGN_LEFT) |     this.appendDummyInput() | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel) |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|             .appendField(new Blockly.FieldTextInput("1"), "CHANNEL"); |       .appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel) | ||||||
|         this.setPreviousStatement(true, null); |       .appendField(new Blockly.FieldTextInput("1"), "CHANNEL"); | ||||||
|         this.setNextStatement(true, null); |     this.setPreviousStatement(true, null); | ||||||
|     }, |     this.setNextStatement(true, null); | ||||||
|     LOOP_TYPES: ['sensebox_lora_cayenne_send'], |   }, | ||||||
|  |   LOOP_TYPES: ["sensebox_lora_cayenne_send"], | ||||||
| }; | }; | ||||||
| Blockly.Blocks['sensebox_lora_cayenne_pressure'] = { | Blockly.Blocks["sensebox_lora_cayenne_luminosity"] = { | ||||||
|     init: function () { |   init: function () { | ||||||
|         this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_pressure_tip); |     this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_luminosity_tip); | ||||||
|         this.setHelpUrl(''); |     this.setHelpUrl(""); | ||||||
|         this.setColour(getColour().sensebox); |     this.setColour(getColour().sensebox); | ||||||
|         this.appendValueInput('Value') |     this.appendValueInput("Value").appendField( | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_cayenne_pressure) |       Blockly.Msg.senseBox_LoRa_cayenne_luminosity | ||||||
|         this.appendDummyInput() |     ); | ||||||
|             .setAlign(Blockly.ALIGN_LEFT) |     this.appendDummyInput() | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel) |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|             .appendField(new Blockly.FieldTextInput("1"), "CHANNEL"); |       .appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel) | ||||||
|         this.setPreviousStatement(true, null); |       .appendField(new Blockly.FieldTextInput("1"), "CHANNEL"); | ||||||
|         this.setNextStatement(true, null); |     this.setPreviousStatement(true, null); | ||||||
|     }, |     this.setNextStatement(true, null); | ||||||
|     LOOP_TYPES: ['sensebox_lora_cayenne_send'], |   }, | ||||||
|  |   LOOP_TYPES: ["sensebox_lora_cayenne_send"], | ||||||
| }; | }; | ||||||
| Blockly.Blocks['sensebox_lora_cayenne_luminosity'] = { | Blockly.Blocks["sensebox_lora_cayenne_sensor"] = { | ||||||
|     init: function () { |   init: function () { | ||||||
|         this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_luminosity_tip); |     this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_analog_tip); | ||||||
|         this.setHelpUrl(''); |     this.setHelpUrl(""); | ||||||
|         this.setColour(getColour().sensebox); |     this.setColour(getColour().sensebox); | ||||||
|         this.appendValueInput('Value') |     this.appendValueInput("Value").appendField( | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_cayenne_luminosity) |       Blockly.Msg.senseBox_LoRa_cayenne_analog | ||||||
|         this.appendDummyInput() |     ); | ||||||
|             .setAlign(Blockly.ALIGN_LEFT) |     this.appendDummyInput() | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel) |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|             .appendField(new Blockly.FieldTextInput("1"), "CHANNEL"); |       .appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel) | ||||||
|         this.setPreviousStatement(true, null); |       .appendField(new Blockly.FieldTextInput("1"), "CHANNEL"); | ||||||
|         this.setNextStatement(true, null); |     this.setPreviousStatement(true, null); | ||||||
|     }, |     this.setNextStatement(true, null); | ||||||
|     LOOP_TYPES: ['sensebox_lora_cayenne_send'], |   }, | ||||||
|  |   LOOP_TYPES: ["sensebox_lora_cayenne_send"], | ||||||
| }; | }; | ||||||
| Blockly.Blocks['sensebox_lora_cayenne_sensor'] = { | Blockly.Blocks["sensebox_lora_cayenne_accelerometer"] = { | ||||||
|     init: function () { |   init: function () { | ||||||
|         this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_analog_tip); |     this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_gyros_tip); | ||||||
|         this.setHelpUrl(''); |     this.setHelpUrl(""); | ||||||
|         this.setColour(getColour().sensebox); |     this.setColour(getColour().sensebox); | ||||||
|         this.appendValueInput('Value') |     this.appendValueInput("X").appendField(Blockly.Msg.senseBox_LoRa_cayenne_x); | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_cayenne_analog) |     this.appendValueInput("Y").appendField(Blockly.Msg.senseBox_LoRa_cayenne_y); | ||||||
|         this.appendDummyInput() |     this.appendValueInput("Z").appendField(Blockly.Msg.senseBox_LoRa_cayenne_z); | ||||||
|             .setAlign(Blockly.ALIGN_LEFT) |     this.appendDummyInput() | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel) |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|             .appendField(new Blockly.FieldTextInput("1"), "CHANNEL"); |       .appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel) | ||||||
|         this.setPreviousStatement(true, null); |       .appendField(new Blockly.FieldTextInput("1"), "CHANNEL"); | ||||||
|         this.setNextStatement(true, null); |     this.setPreviousStatement(true, null); | ||||||
|     }, |     this.setNextStatement(true, null); | ||||||
|     LOOP_TYPES: ['sensebox_lora_cayenne_send'], |   }, | ||||||
|  |   LOOP_TYPES: ["sensebox_lora_cayenne_send"], | ||||||
| }; | }; | ||||||
| Blockly.Blocks['sensebox_lora_cayenne_accelerometer'] = { | Blockly.Blocks["sensebox_lora_cayenne_gps"] = { | ||||||
|     init: function () { |   init: function () { | ||||||
|         this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_gyros_tip); |     this.setTooltip(Blockly.Msg.senseBox_LoRa_cayenne_gps_tip); | ||||||
|         this.setHelpUrl(''); |     this.setHelpUrl(""); | ||||||
|         this.setColour(getColour().sensebox); |     this.setColour(getColour().sensebox); | ||||||
|         this.appendValueInput('X') |     this.appendValueInput("LAT").appendField( | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_cayenne_x) |       Blockly.Msg.senseBox_LoRa_cayenne_lat | ||||||
|         this.appendValueInput('Y') |     ); | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_cayenne_y) |     this.appendValueInput("LNG").appendField( | ||||||
|         this.appendValueInput('Z') |       Blockly.Msg.senseBox_LoRa_cayenne_lng | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_cayenne_z) |     ); | ||||||
|         this.appendDummyInput() |     this.appendValueInput("ALT").appendField( | ||||||
|             .setAlign(Blockly.ALIGN_LEFT) |       Blockly.Msg.senseBox_LoRa_cayenne_alt | ||||||
|             .appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel) |     ); | ||||||
|             .appendField(new Blockly.FieldTextInput("1"), "CHANNEL"); |     this.appendDummyInput() | ||||||
|         this.setPreviousStatement(true, null); |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|         this.setNextStatement(true, null); |       .appendField(Blockly.Msg.senseBox_LoRa_cayenne_channel) | ||||||
|     }, |       .appendField(new Blockly.FieldTextInput("1"), "CHANNEL"); | ||||||
|     LOOP_TYPES: ['sensebox_lora_cayenne_send'], |     this.setPreviousStatement(true, null); | ||||||
| }; |     this.setNextStatement(true, null); | ||||||
| Blockly.Blocks['sensebox_lora_cayenne_gps'] = { |   }, | ||||||
|     init: function () { |   LOOP_TYPES: ["sensebox_lora_cayenne_send"], | ||||||
|         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'], |  | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,27 +1,27 @@ | |||||||
| import * as Blockly from 'blockly/core'; | import * as Blockly from "blockly/core"; | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_lora_initialize_otaa = function (block) { | Blockly.Arduino.sensebox_lora_initialize_otaa = function (block) { | ||||||
|     var deivceID = this.getFieldValue('DEVICEID'); |   var deivceID = this.getFieldValue("DEVICEID"); | ||||||
|     var appID = this.getFieldValue('APPID'); |   var appID = this.getFieldValue("APPID"); | ||||||
|     var appKey = this.getFieldValue('APPKEY'); |   var appKey = this.getFieldValue("APPKEY"); | ||||||
|     var interval = this.getFieldValue('INTERVAL'); |   var interval = this.getFieldValue("INTERVAL"); | ||||||
|     Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"'; |   Blockly.Arduino.libraries_["library_senseBoxMCU"] = | ||||||
|     Blockly.Arduino.libraries_['library_spi'] = '#include <SPI.h>'; |     '#include "SenseBoxMCU.h"'; | ||||||
|     Blockly.Arduino.libraries_['library_lmic'] = '#include <lmic.h>'; |   Blockly.Arduino.libraries_["library_spi"] = "#include <SPI.h>"; | ||||||
|     Blockly.Arduino.libraries_['library_hal'] = '#include <hal/hal.h>'; |   Blockly.Arduino.libraries_["library_lmic"] = "#include <lmic.h>"; | ||||||
|     Blockly.Arduino.definitions_['define_LoRaVariablesOTAA'] = ` |   Blockly.Arduino.libraries_["library_hal"] = "#include <hal/hal.h>"; | ||||||
|     static const u1_t PROGMEM APPEUI[8]= `+ appID + ` ; |   Blockly.Arduino.definitions_["define_LoRaVariablesOTAA"] = ` | ||||||
|  |     static const u1_t PROGMEM APPEUI[8]= {${appID}}; | ||||||
|     void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI , 8);} |     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);} |     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
 |     // 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
 |     // number but a block of memory, endianness does not really apply). In
 | ||||||
|     // practice, a key taken from ttnctl can be copied as-is.
 |     // practice, a key taken from ttnctl can be copied as-is.
 | ||||||
|     // The key shown here is the semtech default key.
 |     // 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);} |     void os_getDevKey (u1_t* buf) {  memcpy_P(buf, APPKEY , 16);} | ||||||
|    |    | ||||||
|     static osjob_t sendjob; |     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}, |         .dio = {PIN_XB1_INT, PIN_XB1_INT, LMIC_UNUSED_PIN}, | ||||||
|     };`;
 |     };`;
 | ||||||
| 
 | 
 | ||||||
|     Blockly.Arduino.codeFunctions_['functions_initLora'] = ` |   Blockly.Arduino.codeFunctions_["functions_initLora"] = ` | ||||||
|     void initLora() { |     void initLora() { | ||||||
|       delay(2000); |       delay(2000); | ||||||
|       // LMIC init
 |       // LMIC init
 | ||||||
| @ -48,9 +48,9 @@ Blockly.Arduino.sensebox_lora_initialize_otaa = function (block) { | |||||||
|      |      | ||||||
|       // Start job (sending automatically starts OTAA too)
 |       // Start job (sending automatically starts OTAA too)
 | ||||||
|       do_send(&sendjob); |       do_send(&sendjob); | ||||||
|     }` |     }`;
 | ||||||
| 
 | 
 | ||||||
|     Blockly.Arduino.codeFunctions_['functions_onEvent'] = ` |   Blockly.Arduino.codeFunctions_["functions_onEvent"] = ` | ||||||
|     void onEvent (ev_t ev) { |     void onEvent (ev_t ev) { | ||||||
|       Serial.print(os_getTime()); |       Serial.print(os_getTime()); | ||||||
|       Serial.print(": "); |       Serial.print(": "); | ||||||
| @ -120,16 +120,18 @@ Blockly.Arduino.sensebox_lora_initialize_otaa = function (block) { | |||||||
|               break; |               break; | ||||||
|       } |       } | ||||||
|   }`;
 |   }`;
 | ||||||
|     Blockly.Arduino.loraSetupCode_['initLora'] = 'initLora();\n'; |   Blockly.Arduino.loraSetupCode_["initLora"] = "initLora();\n"; | ||||||
|     Blockly.Arduino.setupCode_['serial.begin'] = 'Serial.begin(9600);\ndelay(1000);\n'; |   Blockly.Arduino.setupCode_["serial.begin"] = | ||||||
|     var code = ''; |     "Serial.begin(9600);\ndelay(1000);\n"; | ||||||
|     return code; |   var code = ""; | ||||||
|  |   return code; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_lora_message_send = function (block) { | Blockly.Arduino.sensebox_lora_message_send = function (block) { | ||||||
|     Blockly.Arduino.libraries_['library_lora_message'] = '#include <LoraMessage.h>'; |   Blockly.Arduino.libraries_["library_lora_message"] = | ||||||
|     var lora_sensor_values = Blockly.Arduino.statementToCode(block, 'DO'); |     "#include <LoraMessage.h>"; | ||||||
|     Blockly.Arduino.functionNames_['functions_do_send'] = ` |   var lora_sensor_values = Blockly.Arduino.statementToCode(block, "DO"); | ||||||
|  |   Blockly.Arduino.functionNames_["functions_do_send"] = ` | ||||||
|   void do_send(osjob_t* j){ |   void do_send(osjob_t* j){ | ||||||
|       // Check if there is not a current TX/RX job running
 |       // Check if there is not a current TX/RX job running
 | ||||||
|       if (LMIC.opmode & OP_TXRXPEND) { |       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.
 |       // Next TX is scheduled after TX_COMPLETE event.
 | ||||||
|   }`;
 |   }`;
 | ||||||
|     Blockly.Arduino.loopCodeOnce_['os_runloop'] = 'os_runloop_once();' |   Blockly.Arduino.loopCodeOnce_["os_runloop"] = "os_runloop_once();"; | ||||||
|     return '' |   return ""; | ||||||
| } | }; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Block send Data to TTN |  * Block send Data to TTN | ||||||
|  */ |  */ | ||||||
| Blockly.Arduino.sensebox_send_lora_sensor_value = function (block) { | Blockly.Arduino.sensebox_send_lora_sensor_value = function (block) { | ||||||
|     const reading = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || '"Keine Eingabe"'; |   const reading = | ||||||
|     var messageBytes = this.getFieldValue('MESSAGE_BYTES'); |     Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) || | ||||||
|     var code = '' |     '"Keine Eingabe"'; | ||||||
|     switch (Number(messageBytes)) { |   var messageBytes = this.getFieldValue("MESSAGE_BYTES"); | ||||||
|         case 1: |   var code = ""; | ||||||
|             code = `message.addUint8(${reading});\n` |   switch (Number(messageBytes)) { | ||||||
|             break; |     case 1: | ||||||
|         case 2: |       code = `message.addUint8(${reading});\n`; | ||||||
|             code = `message.addUint16(${reading});\n` |       break; | ||||||
|             break; |     case 2: | ||||||
|         case 3: |       code = `message.addUint16(${reading});\n`; | ||||||
|             code = `message.addUint8(${reading});
 |       break; | ||||||
|         message.addUint16(${reading} >> 8);\n` |     case 3: | ||||||
|             break; |       code = `message.addUint8(${reading});
 | ||||||
|         default: |         message.addUint16(${reading} >> 8);\n`;
 | ||||||
|             code = `message.addUint16(${reading});\n` |       break; | ||||||
|     } |     default: | ||||||
|     return code; |       code = `message.addUint16(${reading});\n`; | ||||||
|  |   } | ||||||
|  |   return code; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_lora_cayenne_send = function (block) { | Blockly.Arduino.sensebox_lora_cayenne_send = function (block) { | ||||||
|     Blockly.Arduino.libraries_['library_cayene'] = '#include <CayenneLPP.h>'; |   Blockly.Arduino.libraries_["library_cayene"] = "#include <CayenneLPP.h>"; | ||||||
|     Blockly.Arduino.variables_['variable_cayenne'] = 'CayenneLPP lpp(51);' |   Blockly.Arduino.variables_["variable_cayenne"] = "CayenneLPP lpp(51);"; | ||||||
|     var lora_sensor_values = Blockly.Arduino.statementToCode(block, 'DO'); |   var lora_sensor_values = Blockly.Arduino.statementToCode(block, "DO"); | ||||||
|     Blockly.Arduino.functionNames_['functions_do_send'] = ` |   Blockly.Arduino.functionNames_["functions_do_send"] = ` | ||||||
|   void do_send(osjob_t* j){ |   void do_send(osjob_t* j){ | ||||||
|       // Check if there is not a current TX/RX job running
 |       // Check if there is not a current TX/RX job running
 | ||||||
|       if (LMIC.opmode & OP_TXRXPEND) { |       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.
 |       // Next TX is scheduled after TX_COMPLETE event.
 | ||||||
|   }`;
 |   }`;
 | ||||||
|     Blockly.Arduino.loopCodeOnce_['os_runloop'] = 'os_runloop_once();' |   Blockly.Arduino.loopCodeOnce_["os_runloop"] = "os_runloop_once();"; | ||||||
|     return ''; |   return ""; | ||||||
| } | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_lora_ttn_mapper = function (block) { | Blockly.Arduino.sensebox_lora_ttn_mapper = function (block) { | ||||||
|     var latitude = Blockly.Arduino.valueToCode(this, 'Latitude', Blockly.Arduino.ORDER_ATOMIC) |   var latitude = Blockly.Arduino.valueToCode( | ||||||
|     var longitude = Blockly.Arduino.valueToCode(this, 'Longitude', Blockly.Arduino.ORDER_ATOMIC) |     this, | ||||||
|     var altitude = Blockly.Arduino.valueToCode(this, 'Altitude', Blockly.Arduino.ORDER_ATOMIC) |     "Latitude", | ||||||
|     var pDOP = Blockly.Arduino.valueToCode(this, 'pDOP', Blockly.Arduino.ORDER_ATOMIC) |     Blockly.Arduino.ORDER_ATOMIC | ||||||
|     var fixType = Blockly.Arduino.valueToCode(this, 'Fix Type', Blockly.Arduino.ORDER_ATOMIC) |   ); | ||||||
|     var fixTypeLimit = this.getFieldValue('dropdown'); |   var longitude = Blockly.Arduino.valueToCode( | ||||||
|     Blockly.Arduino.functionNames_['functions_do_send'] = ` |     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){ |   void do_send(osjob_t* j){ | ||||||
|       // Check if there is not a current TX/RX job running
 |       // Check if there is not a current TX/RX job running
 | ||||||
|       if (LMIC.opmode & OP_TXRXPEND) { |       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.
 |       // Next TX is scheduled after TX_COMPLETE event.
 | ||||||
|   }`;
 |   }`;
 | ||||||
|     Blockly.Arduino.loopCodeOnce_['os_runloop'] = 'os_runloop_once();' |   Blockly.Arduino.loopCodeOnce_["os_runloop"] = "os_runloop_once();"; | ||||||
|     return ''; |   return ""; | ||||||
| } | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_lora_initialize_abp = function (block) { | Blockly.Arduino.sensebox_lora_initialize_abp = function (block) { | ||||||
|     var nwskey = this.getFieldValue('NWSKEY'); |   var nwskey = this.getFieldValue("NWSKEY"); | ||||||
|     var appskey = this.getFieldValue('APPSKEY'); |   var appskey = this.getFieldValue("APPSKEY"); | ||||||
|     var devaddr = this.getFieldValue('DEVADDR'); |   var devaddr = this.getFieldValue("DEVADDR"); | ||||||
|     var interval = this.getFieldValue('INTERVAL'); |   var interval = this.getFieldValue("INTERVAL"); | ||||||
|     Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"'; |   Blockly.Arduino.libraries_["library_senseBoxMCU"] = | ||||||
|     Blockly.Arduino.libraries_['library_spi'] = '#include <SPI.h>'; |     '#include "SenseBoxMCU.h"'; | ||||||
|     Blockly.Arduino.libraries_['library_lmic'] = '#include <lmic.h>'; |   Blockly.Arduino.libraries_["library_spi"] = "#include <SPI.h>"; | ||||||
|     Blockly.Arduino.libraries_['library_hal'] = '#include <hal/hal.h>'; |   Blockly.Arduino.libraries_["library_lmic"] = "#include <lmic.h>"; | ||||||
|     Blockly.Arduino.definitions_['define_LoRaVariablesABP'] = ` |   Blockly.Arduino.libraries_["library_hal"] = "#include <hal/hal.h>"; | ||||||
|  |   Blockly.Arduino.definitions_["define_LoRaVariablesABP"] = ` | ||||||
|     // LoRaWAN NwkSKey, network session key
 |     // LoRaWAN NwkSKey, network session key
 | ||||||
|     // This is the default Semtech key, which is used by the early prototype TTN
 |     // This is the default Semtech key, which is used by the early prototype TTN
 | ||||||
|     // network.
 |     // network.
 | ||||||
|     static const PROGMEM u1_t NWKSKEY[16] = ${nwskey}; |     static const PROGMEM u1_t NWKSKEY[16] = { ${nwskey} }; | ||||||
|      |      | ||||||
|     // LoRaWAN AppSKey, application session key
 |     // LoRaWAN AppSKey, application session key
 | ||||||
|     // This is the default Semtech key, which is used by the early prototype TTN
 |     // This is the default Semtech key, which is used by the early prototype TTN
 | ||||||
|     // network.
 |     // network.
 | ||||||
|     static const u1_t PROGMEM APPSKEY[16] = ${appskey}; |     static const u1_t PROGMEM APPSKEY[16] = { ${appskey} }; | ||||||
|      |      | ||||||
|     // LoRaWAN end-device address (DevAddr)
 |     // LoRaWAN end-device address (DevAddr)
 | ||||||
|     static const u4_t DEVADDR = 0x${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}, |         .dio = {PIN_XB1_INT, PIN_XB1_INT, LMIC_UNUSED_PIN}, | ||||||
|     };`;
 |     };`;
 | ||||||
| 
 | 
 | ||||||
|     Blockly.Arduino.codeFunctions_['functions_initLora'] = ` |   Blockly.Arduino.codeFunctions_["functions_initLora"] = ` | ||||||
|     void initLora() { |     void initLora() { | ||||||
|       delay(2000); |       delay(2000); | ||||||
|       // LMIC init
 |       // LMIC init
 | ||||||
| @ -359,9 +384,9 @@ Blockly.Arduino.sensebox_lora_initialize_abp = function (block) { | |||||||
|    |    | ||||||
|       // Start job
 |       // Start job
 | ||||||
|       do_send(&sendjob); |       do_send(&sendjob); | ||||||
|     }` |     }`;
 | ||||||
| 
 | 
 | ||||||
|     Blockly.Arduino.codeFunctions_['functions_onEvent'] = ` |   Blockly.Arduino.codeFunctions_["functions_onEvent"] = ` | ||||||
|     void onEvent (ev_t ev) { |     void onEvent (ev_t ev) { | ||||||
|       Serial.print(os_getTime()); |       Serial.print(os_getTime()); | ||||||
|       Serial.print(": "); |       Serial.print(": "); | ||||||
| @ -426,60 +451,77 @@ Blockly.Arduino.sensebox_lora_initialize_abp = function (block) { | |||||||
|               break; |               break; | ||||||
|       } |       } | ||||||
|   }`;
 |   }`;
 | ||||||
|     Blockly.Arduino.loraSetupCode_['initLora'] = 'initLora();\n'; |   Blockly.Arduino.loraSetupCode_["initLora"] = "initLora();\n"; | ||||||
|     Blockly.Arduino.setupCode_['serial.begin'] = 'Serial.begin(9600);\ndelay(1000);\n'; |   Blockly.Arduino.setupCode_["serial.begin"] = | ||||||
|     return ''; |     "Serial.begin(9600);\ndelay(1000);\n"; | ||||||
| } |   return ""; | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_lora_cayenne_temperature = function (block) { | Blockly.Arduino.sensebox_lora_cayenne_temperature = function (block) { | ||||||
|     var temperature = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || 0 |   var temperature = | ||||||
|     var channel = this.getFieldValue('CHANNEL'); |     Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) || | ||||||
|     var code = `lpp.addTemperature(${channel}, ${temperature});\n`; |     0; | ||||||
|     return code; |   var channel = this.getFieldValue("CHANNEL"); | ||||||
| } |   var code = `lpp.addTemperature(${channel}, ${temperature});\n`; | ||||||
|  |   return code; | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_lora_cayenne_humidity = function (block) { | Blockly.Arduino.sensebox_lora_cayenne_humidity = function (block) { | ||||||
|     var humidity = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || 0 |   var humidity = | ||||||
|     var channel = this.getFieldValue('CHANNEL'); |     Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) || | ||||||
|     var code = `lpp.addRelativeHumidity(${channel}, ${humidity});\n`; |     0; | ||||||
|     return code; |   var channel = this.getFieldValue("CHANNEL"); | ||||||
| } |   var code = `lpp.addRelativeHumidity(${channel}, ${humidity});\n`; | ||||||
|  |   return code; | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_lora_cayenne_pressure = function (block) { | Blockly.Arduino.sensebox_lora_cayenne_pressure = function (block) { | ||||||
|     var pressure = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || 0 |   var pressure = | ||||||
|     var channel = this.getFieldValue('CHANNEL'); |     Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) || | ||||||
|     var code = `lpp.addBarometricPressure(${channel}, ${pressure});\n`; |     0; | ||||||
|     return code; |   var channel = this.getFieldValue("CHANNEL"); | ||||||
| } |   var code = `lpp.addBarometricPressure(${channel}, ${pressure});\n`; | ||||||
|  |   return code; | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_lora_cayenne_luminosity = function (block) { | Blockly.Arduino.sensebox_lora_cayenne_luminosity = function (block) { | ||||||
|     var luminosity = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || 0 |   var luminosity = | ||||||
|     var channel = this.getFieldValue('CHANNEL'); |     Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) || | ||||||
|     var code = `lpp.addLuminosity(${channel}, ${luminosity});\n`; |     0; | ||||||
|     return code; |   var channel = this.getFieldValue("CHANNEL"); | ||||||
| } |   var code = `lpp.addLuminosity(${channel}, ${luminosity});\n`; | ||||||
|  |   return code; | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_lora_cayenne_sensor = function (block) { | Blockly.Arduino.sensebox_lora_cayenne_sensor = function (block) { | ||||||
|     var sensorValue = Blockly.Arduino.valueToCode(this, 'Value', Blockly.Arduino.ORDER_ATOMIC) || 0 |   var sensorValue = | ||||||
|     var channel = this.getFieldValue('CHANNEL'); |     Blockly.Arduino.valueToCode(this, "Value", Blockly.Arduino.ORDER_ATOMIC) || | ||||||
|     var code = `lpp.addAnalogInput(${channel}, ${sensorValue});\n`; |     0; | ||||||
|     return code; |   var channel = this.getFieldValue("CHANNEL"); | ||||||
| } |   var code = `lpp.addAnalogInput(${channel}, ${sensorValue});\n`; | ||||||
|  |   return code; | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_lora_cayenne_accelerometer = function (block) { | Blockly.Arduino.sensebox_lora_cayenne_accelerometer = function (block) { | ||||||
|     var x = Blockly.Arduino.valueToCode(this, 'X', Blockly.Arduino.ORDER_ATOMIC) || 0 |   var x = | ||||||
|     var y = Blockly.Arduino.valueToCode(this, 'Y', Blockly.Arduino.ORDER_ATOMIC) || 0 |     Blockly.Arduino.valueToCode(this, "X", Blockly.Arduino.ORDER_ATOMIC) || 0; | ||||||
|     var z = Blockly.Arduino.valueToCode(this, 'Z', Blockly.Arduino.ORDER_ATOMIC) || 0 |   var y = | ||||||
|     var channel = this.getFieldValue('CHANNEL'); |     Blockly.Arduino.valueToCode(this, "Y", Blockly.Arduino.ORDER_ATOMIC) || 0; | ||||||
|     var code = `lpp.addAccelerometer(${channel}, ${x}, ${y}, ${z});\n`; |   var z = | ||||||
|     return code; |     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) { | Blockly.Arduino.sensebox_lora_cayenne_gps = function (block) { | ||||||
|     var lat = Blockly.Arduino.valueToCode(this, 'LAT', Blockly.Arduino.ORDER_ATOMIC) || 0 |   var lat = | ||||||
|     var lng = Blockly.Arduino.valueToCode(this, 'LNG', Blockly.Arduino.ORDER_ATOMIC) || 0 |     Blockly.Arduino.valueToCode(this, "LAT", Blockly.Arduino.ORDER_ATOMIC) || 0; | ||||||
|     var alt = Blockly.Arduino.valueToCode(this, 'ALT', Blockly.Arduino.ORDER_ATOMIC) || 0 |   var lng = | ||||||
|     var channel = this.getFieldValue('CHANNEL'); |     Blockly.Arduino.valueToCode(this, "LNG", Blockly.Arduino.ORDER_ATOMIC) || 0; | ||||||
|     var code = `lpp.addGPS(${channel}, ${lat}, ${lng}, ${alt});\n` |   var alt = | ||||||
|     return code; |     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; | ||||||
|  | }; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user