multiple replies on device request with more than one city provided
This commit is contained in:
parent
d34b43f61a
commit
664ba5e28b
@ -52,14 +52,22 @@ public class MqttService {
|
|||||||
//existing device
|
//existing device
|
||||||
res.first();
|
res.first();
|
||||||
|
|
||||||
// TODO: 23.01.20 --> check device_city db and foreach all cities
|
ResultSet devicecities = db.executeQuery("SELECT * from device_city WHERE DeviceID='" + deviceid + "'");
|
||||||
int cityid = res.getInt("CityID");
|
devicecities.last();
|
||||||
if (cityid == -1) {
|
if (devicecities.getRow() == 0) {
|
||||||
//device not configured yet
|
//not configured
|
||||||
tramsmitMessage(deviceid + ",-1");
|
tramsmitMessage(deviceid + ",-1");
|
||||||
} else {
|
} else {
|
||||||
checkDatabase(cityid, Integer.parseInt(deviceid));
|
devicecities.first();
|
||||||
|
devicecities.previous();
|
||||||
|
// TODO: 23.01.20 Test this stuff
|
||||||
|
while (devicecities.next()) {
|
||||||
|
int cityid = devicecities.getInt("CityID");
|
||||||
|
checkDatabase(cityid, Integer.parseInt(deviceid));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//new device
|
//new device
|
||||||
db.executeUpdate("INSERT INTO devices (DeviceID) VALUES (" + deviceid + ")");
|
db.executeUpdate("INSERT INTO devices (DeviceID) VALUES (" + deviceid + ")");
|
||||||
@ -131,8 +139,8 @@ public class MqttService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void tramsmitMessage(String temp) {
|
private void tramsmitMessage(String temp) {
|
||||||
Log.debug("sending message >>>"+temp);
|
Log.debug("sending message >>>" + temp);
|
||||||
MqttMessage message = new MqttMessage(temp.getBytes());
|
MqttMessage message = new MqttMessage(temp.getBytes());
|
||||||
message.setQos(2);
|
message.setQos(2);
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user