* added some todos
This commit is contained in:
parent
c3fb92d6eb
commit
ac02e4bd62
@ -19,7 +19,7 @@ public class MySQLConnector extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Connection getConnection() throws SQLException {
|
public Connection getConnection() throws SQLException {
|
||||||
DriverManager.setLoginTimeout(1); // TODO: 30.11.19 set higher maybe
|
DriverManager.setLoginTimeout(1);
|
||||||
return DriverManager.getConnection(
|
return DriverManager.getConnection(
|
||||||
"jdbc:mysql://" + host + ":" + port + "/" + dbName + "?useSSL=false",
|
"jdbc:mysql://" + host + ":" + port + "/" + dbName + "?useSSL=false",
|
||||||
user,
|
user,
|
||||||
|
@ -43,7 +43,7 @@ public class MqttService {
|
|||||||
@Override
|
@Override
|
||||||
public void messageArrived(String s, MqttMessage mqttMessage) {
|
public void messageArrived(String s, MqttMessage mqttMessage) {
|
||||||
String message = new String(mqttMessage.getPayload());
|
String message = new String(mqttMessage.getPayload());
|
||||||
Log.info("received Request from PCB");
|
Log.message("received Request from PCB");
|
||||||
|
|
||||||
ResultSet res = db.executeQuery("SELECT * from devices WHERE DeviceID=" + message);
|
ResultSet res = db.executeQuery("SELECT * from devices WHERE DeviceID=" + message);
|
||||||
try {
|
try {
|
||||||
@ -61,6 +61,7 @@ public class MqttService {
|
|||||||
} else {
|
} else {
|
||||||
//new device
|
//new device
|
||||||
db.executeUpdate("INSERT INTO devices (DeviceID) VALUES (" + message + ")");
|
db.executeUpdate("INSERT INTO devices (DeviceID) VALUES (" + message + ")");
|
||||||
|
Log.info("new device registered to server");
|
||||||
tramsmitMessage(message + ",-1");
|
tramsmitMessage(message + ",-1");
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -99,6 +100,7 @@ public class MqttService {
|
|||||||
|
|
||||||
if (timestamp == timestampnow || timestamp == timestampnow + 86400000) { // 86400000 == one day
|
if (timestamp == timestampnow || timestamp == timestampnow + 86400000) { // 86400000 == one day
|
||||||
// valid time
|
// valid time
|
||||||
|
// TODO: 12.01.20 read right waste type from db and replace below
|
||||||
tramsmitMessage(deviceid + "," + "Plastic" + "," + 1);
|
tramsmitMessage(deviceid + "," + "Plastic" + "," + 1);
|
||||||
Log.debug("valid time");
|
Log.debug("valid time");
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user