From 2aee8819bfba5bfa9e5eb8e5810b368bf4ded79e Mon Sep 17 00:00:00 2001 From: Michele Di Capua Date: Mon, 25 Oct 2021 12:16:45 +0200 Subject: [PATCH 1/5] The second message in the catch print, method evaluate(), must be arg2. --- src/senscript/SenScriptCondition_LESS.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/senscript/SenScriptCondition_LESS.java b/src/senscript/SenScriptCondition_LESS.java index 3bcfed6f..1e7c6cd1 100755 --- a/src/senscript/SenScriptCondition_LESS.java +++ b/src/senscript/SenScriptCondition_LESS.java @@ -26,7 +26,7 @@ public boolean evaluate() { v2 = Double.valueOf(sensor.getScript().getVariableValue(arg2)); } catch(Exception e) { - System.err.println("[CupCarbon ERROR] (S"+sensor.getId()+"): Condition < ("+arg1+" is not a number)"); + System.err.println("[CupCarbon ERROR] (S"+sensor.getId()+"): Condition < ("+arg2+" is not a number)"); } return (v1 < v2); From e2df607221b183de906feb5c874f1aef0da7d5ce Mon Sep 17 00:00:00 2001 From: Michele Di Capua Date: Mon, 25 Oct 2021 12:32:26 +0200 Subject: [PATCH 2/5] The second error message in the evaluate() method, should be arg2 --- src/senscript/SenScriptCondition_LESS.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/senscript/SenScriptCondition_LESS.java b/src/senscript/SenScriptCondition_LESS.java index 1e7c6cd1..a6492379 100755 --- a/src/senscript/SenScriptCondition_LESS.java +++ b/src/senscript/SenScriptCondition_LESS.java @@ -30,7 +30,5 @@ public boolean evaluate() { } return (v1 < v2); - } - - + } } From 2bf840f0ecb5527b5a28940f0c3e31064e080bec Mon Sep 17 00:00:00 2001 From: Michele Di Capua Date: Mon, 1 Nov 2021 20:17:26 +0100 Subject: [PATCH 3/5] Added a comment (#) feature in SenScript --- src/senscript/SenScriptAddCommand.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/senscript/SenScriptAddCommand.java b/src/senscript/SenScriptAddCommand.java index c78194f5..e13bcbab 100755 --- a/src/senscript/SenScriptAddCommand.java +++ b/src/senscript/SenScriptAddCommand.java @@ -451,6 +451,10 @@ public static void addCommand(String instStr, SensorNode sensorNode, SenScript s command = new Command_CPRINT(sensorNode, inst); } + if (inst[0].toLowerCase().startsWith("#")) { + //SKIP comment + } + //------- // This part must be here (at the end). All new commands must be added before (above) From 4450f695af40348b7721d13bbbff3eae1ca8f68d Mon Sep 17 00:00:00 2001 From: Michele Di Capua Date: Mon, 1 Nov 2021 21:16:55 +0100 Subject: [PATCH 4/5] IOT client for Thingsboard added --- src/iotlab/Client.java | 60 ++++++++++++++++++++ src/senscript/SenScript.java | 9 ++- src/senscript_functions/Functions.java | 31 ++++++++++ src/senscript_functions/ScriptFunctions.java | 6 +- 4 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 src/iotlab/Client.java diff --git a/src/iotlab/Client.java b/src/iotlab/Client.java new file mode 100644 index 00000000..3a433a33 --- /dev/null +++ b/src/iotlab/Client.java @@ -0,0 +1,60 @@ +package iotlab; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; + +public class Client +{ + + /** + * ThingsBoars simple client + * user micheledicapua@gmail.com + * Sulla pagine Thingsboard aprire la dashboard IoT Lab + * @param data + */ + public static void sendInCloud(float data) + { + URL url = null; + HttpURLConnection con = null; + try + { + url = new URL ("http://demo.thingsboard.io/api/v1/ZJifi2d7hOZWhhPz3FJq/telemetry"); + con = (HttpURLConnection)url.openConnection(); + con.setRequestMethod("POST"); + con.setRequestProperty("Content-Type", "application/json; utf-8"); + con.setRequestProperty("Accept", "application/json"); + con.setDoOutput(true); + //temperature รจ la chiave (KEY) del widget (lettura dati) di TensorBoard + String jsonInputString = "{\"temperature\":"+data+"}"; + + OutputStream os = con.getOutputStream(); + byte[] input = jsonInputString.getBytes("utf-8"); + os.write(input, 0, input.length); + } + catch (Exception e) + { + e.printStackTrace(); + } + + try + { + BufferedReader br = new BufferedReader (new InputStreamReader(con.getInputStream(), "utf-8")); + StringBuilder response = new StringBuilder(); + String responseLine = null; + while ((responseLine = br.readLine()) != null) + { + response.append(responseLine.trim()); + } + System.out.println("Response="+response.toString()); + System.out.println("Status="+con.getResponseCode()); + } + catch (Exception e) + { + e.printStackTrace(); + } + + } +} \ No newline at end of file diff --git a/src/senscript/SenScript.java b/src/senscript/SenScript.java index 4bec3afc..081cb6c5 100755 --- a/src/senscript/SenScript.java +++ b/src/senscript/SenScript.java @@ -205,11 +205,18 @@ public boolean isNumeric(String arg) { } } + /* BUG FIXED ISSUE ON GITHUB #20 public void variablesToValues(String [] args) { for(int i=0; i Date: Fri, 5 Nov 2021 17:36:53 +0100 Subject: [PATCH 5/5] Version added --- src/cupcarbon/CupCarbonVersion.java | 2 +- src/iotlab/{Client.java => HTTPClient.java} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/iotlab/{Client.java => HTTPClient.java} (100%) diff --git a/src/cupcarbon/CupCarbonVersion.java b/src/cupcarbon/CupCarbonVersion.java index d84212a0..20d41958 100755 --- a/src/cupcarbon/CupCarbonVersion.java +++ b/src/cupcarbon/CupCarbonVersion.java @@ -1,7 +1,7 @@ package cupcarbon; public final class CupCarbonVersion { - public static final String VERSION = "IoT 5.1"; + public static final String VERSION = "IoT 5.1.1 beta (Parthenope)"; public static final String YEAR = "2021"; public static final int UPDATE = 31; } diff --git a/src/iotlab/Client.java b/src/iotlab/HTTPClient.java similarity index 100% rename from src/iotlab/Client.java rename to src/iotlab/HTTPClient.java