private static final int CAMERA_FPS = 15;
private static final int CHECK_TIME_WAIT = 1; // in seconds
private static final int SECOND_TO_TURN_ON = 60; // in seconds
+ private static final int SECOND_TO_TURN_OFF = 1; // in seconds
/**
* IoT Sets and Relations
try {
alm.init();
System.out.println("DEBUG: Initialized alarm!");
+ // TODO: Check that this initialization works for multiple times - might be that setZone() only works once!
+ //for (RoomSmart room : roomSet.values()) {
+ // turnOffAlarms(room.getRoomID());
+ // System.out.println("DEBUG: Initialized alarm for room (turn off): " + room.getRoomID());
+ //}
} catch (Exception e) {
e.printStackTrace();
}
// Get and init the alarm (this single alarm set can serve multiple zones / rooms)
Iterator alarmIt = alarmSet.iterator();
AlarmSmart alm = (AlarmSmart) alarmIt.next();
- alm.setZone(zoneId, true, SECOND_TO_TURN_ON);
+ alm.setZone(zoneId, true, SECOND_TO_TURN_OFF);
}
Iterator alarmIt = alarmSet.iterator();
AlarmSmart alm = (AlarmSmart) alarmIt.next();
// Turn this alarm off indefinitely
- alm.setZone(zoneId, false, -1);
+ alm.setZone(zoneId, false, SECOND_TO_TURN_ON);
}
// Receive until maxlen
if (maxlen>BUFFSIZE) {
System.out.println("IoTSocketClient/Server: Sending more bytes then will fit in buffer! Number of bytes: " + maxlen);
+ // Allocate a bigger array when needed
+ int newLen = 2;
+ while (newLen < maxlen) // Shift until we get a new buffer size that's bigger than maxLen (basically power of 2)
+ newLen = newLen << 1;
+ System.out.println("IoTSocketClient/Server: Allocating a bigger buffer now with size: " + newLen);
+ data = new byte[newLen];
}
val = new byte[maxlen];
while (totalbytes < maxlen)