diff --git a/JavaSample-tcp19216865151883/.lck b/JavaSample-tcp19216865151883/.lck
new file mode 100644
index 0000000..e69de29
diff --git a/UniquedeviceID-tcp19216864151883/.lck b/UniquedeviceID-tcp19216864151883/.lck
new file mode 100644
index 0000000..e69de29
diff --git a/UniquedeviceID-tcp19216865151883/.lck b/UniquedeviceID-tcp19216865151883/.lck
new file mode 100644
index 0000000..e69de29
diff --git a/WasteInformationServer.iml b/WasteInformationServer.iml
index b77913d..8bd06b5 100644
--- a/WasteInformationServer.iml
+++ b/WasteInformationServer.iml
@@ -9,5 +9,7 @@
+
+
\ No newline at end of file
diff --git a/src/com/wasteinformationserver/Date.java b/src/com/wasteinformationserver/Date.java
index abd507c..b4502fe 100644
--- a/src/com/wasteinformationserver/Date.java
+++ b/src/com/wasteinformationserver/Date.java
@@ -19,12 +19,12 @@ public class Date {
public void getdata() {
GregorianCalendar now = new GregorianCalendar();
- DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM); // 14.04.2012
+ DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
String datum = df.format(now.getTime());
URL url = null;
try {
- url = new URL("https://www.steyr.at/system/web/kalender.aspx?vdatum=" + datum + "&bdatum=12.10.2019&typ=&typid=0&typids=225781950&detailonr=0&menuonr=225781812");
+ url = new URL("https://www.steyr.at/system/web/kalender.aspx?vdatum="+datum+"&bdatum=19.10.2019&typ=&typid=0&typids=225781950&detailonr=0&menuonr=225781812");
Scanner scanner = new Scanner(new InputStreamReader(url.openStream()));
int n = 0;
@@ -46,6 +46,12 @@ public class Date {
}
public void printList() {
+ for (int n = 0; n < list.size(); n++) {
+ System.out.println(list.get(n));
+ }
+ }
+
+ public void printListnew() {
for (int n = 0; n < listnew.size(); n++) {
System.out.println(listnew.get(n));
}
@@ -68,18 +74,30 @@ public class Date {
zaehler++;
}
- String string = "004-034556";
+ /* String string = "004-034556";
String[] parts = string.split("-");
String part1 = parts[0]; // 004
- String part2 = parts[1]; // 034556
+ String part2 = parts[1]; // 034556*/
- for (int q = 0; q < listnew.size(); q++) {
-
- }
+ splitter();
}
}
}
}
+ private void splitter()
+ {
+ String temp="
";
+
+ for (int n=0; n {
+ /* Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
Thread.sleep(200);
Log.warning("Shutting down ...");
@@ -25,9 +28,15 @@ public class main {
Thread mythread = new Thread(() -> new Webserver().startserver());
mythread.start();
- Log.message("thread started");
-
+ Log.message("thread started");*/
+ mqtt m=new mqtt();
+ // m.notifymessage();
+ try {
+ m.getDatabasedata();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
}
}
diff --git a/src/com/wasteinformationserver/mqtt/Database.java b/src/com/wasteinformationserver/mqtt/Database.java
new file mode 100644
index 0000000..b33bfd2
--- /dev/null
+++ b/src/com/wasteinformationserver/mqtt/Database.java
@@ -0,0 +1,4 @@
+package com.wasteinformationserver.mqtt;
+
+public class Database {
+}
diff --git a/src/com/wasteinformationserver/mqtt/mqtt.java b/src/com/wasteinformationserver/mqtt/mqtt.java
new file mode 100644
index 0000000..16e21ff
--- /dev/null
+++ b/src/com/wasteinformationserver/mqtt/mqtt.java
@@ -0,0 +1,58 @@
+package com.wasteinformationserver.mqtt;
+
+import com.wasteinformationserver.db.jdcb;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+public class mqtt {
+
+ private ArrayList mylist=new ArrayList<>();
+ private int index=0;
+
+ public mqtt(){
+
+ }
+
+ public void notifymessage(){
+
+ mqttreceiver mr=new mqttreceiver();
+
+ mr.addMessageReceivedListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ System.out.println(e.getActionCommand());
+ }
+ });
+ }
+
+ public void getDatabasedata() throws SQLException {
+ jdcb database=new jdcb("placeuser","eaL956R6yFItQVBl","wasteinformation");
+ ResultSet result = database.executeQuery("SELECT*FROM place");
+
+ while(result.next())
+ {
+ String temp= String.valueOf(result.getStatement());
+ filllist(temp);
+ }
+
+
+
+ //transmitmessagetoESP();
+ }
+
+ private void transmitmessagetoESP()
+ {
+
+ mqtttransmitter mt=new mqtttransmitter();
+ }
+
+ private void filllist(String temp)
+ {
+ mylist.add(index,temp);
+ }
+
+}
diff --git a/src/com/wasteinformationserver/mqtt/mqttreceiver.java b/src/com/wasteinformationserver/mqtt/mqttreceiver.java
new file mode 100644
index 0000000..67445b4
--- /dev/null
+++ b/src/com/wasteinformationserver/mqtt/mqttreceiver.java
@@ -0,0 +1,59 @@
+package com.wasteinformationserver.mqtt;
+
+import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
+import org.eclipse.paho.client.mqttv3.MqttCallback;
+import org.eclipse.paho.client.mqttv3.MqttClient;
+import org.eclipse.paho.client.mqttv3.MqttException;
+import org.eclipse.paho.client.mqttv3.MqttMessage;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+
+public class mqttreceiver {
+
+ MqttClient client;
+ String message;
+
+ ArrayList mylisteners = new ArrayList<>();
+
+ public mqttreceiver() {
+
+ try {
+ client = new MqttClient("tcp://192.168.65.15:1883", "JavaSample");
+ client.connect();
+
+ client.setCallback(new MqttCallback() {
+ @Override
+ public void connectionLost(Throwable throwable) {
+
+ }
+
+ @Override
+ public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
+ System.out.println(new String(mqttMessage.getPayload()));
+ notifylisteners(new String(mqttMessage.getPayload()));
+ }
+
+ @Override
+ public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
+
+ }
+ });
+ client.subscribe("test/topic");
+ } catch (MqttException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ private void notifylisteners(String message){
+ for (ActionListener ac:mylisteners) {
+ new ActionEvent(this,0,message);
+ }
+ }
+
+ public void addMessageReceivedListener(ActionListener l){
+ mylisteners.add(l);
+ }
+}
diff --git a/src/com/wasteinformationserver/mqtt.java b/src/com/wasteinformationserver/mqtt/mqtttransmitter.java
similarity index 88%
rename from src/com/wasteinformationserver/mqtt.java
rename to src/com/wasteinformationserver/mqtt/mqtttransmitter.java
index a30178f..47087fc 100644
--- a/src/com/wasteinformationserver/mqtt.java
+++ b/src/com/wasteinformationserver/mqtt/mqtttransmitter.java
@@ -1,4 +1,4 @@
-package com.wasteinformationserver;
+package com.wasteinformationserver.mqtt;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
@@ -6,12 +6,14 @@ import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
-public class mqtt {
- public mqtt() {
- String topic = "MQTT Examples";
+public class mqtttransmitter {
+
+ public mqtttransmitter() {
+
+ String topic = "kk";
String content = "Message from MqttPublishSample";
int qos = 2;
- String broker = "tcp://iot.eclipse.org:1883";
+ String broker = "tcp://192.168.65.15:1883";
String clientId = "JavaSample";
MemoryPersistence persistence = new MemoryPersistence();