Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doorbird] Warning and SAT cleanup #15824

Merged
merged 3 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ public void setThingHandler(@Nullable ThingHandler handler) {
@RuleAction(label = "restart the Doorbird", description = "Restarts the Doorbird device.")
public void restart() {
logger.debug("Doorbird action 'restart' called");
DoorbellHandler handler = this.handler;
lsiepel marked this conversation as resolved.
Show resolved Hide resolved
if (handler != null) {
handler.actionRestart();
this.handler = handler;
lsiepel marked this conversation as resolved.
Show resolved Hide resolved
} else {
logger.info("Doorbird Action service ThingHandler is null!");
}
Expand All @@ -68,8 +70,10 @@ public static void restart(ThingActions actions) {
@RuleAction(label = "hangup a SIP call", description = "Hangup SIP call.")
public void sipHangup() {
logger.debug("Doorbird action 'sipHangup' called");
DoorbellHandler handler = this.handler;
if (handler != null) {
handler.actionSIPHangup();
this.handler = handler;
lsiepel marked this conversation as resolved.
Show resolved Hide resolved
} else {
logger.info("Doorbird Action service ThingHandler is null!");
}
Expand All @@ -82,6 +86,7 @@ public static void sipHangup(ThingActions actions) {
@RuleAction(label = "get the ring time limit", description = "Get the value of RING_TIME_LIMIT.")
public @ActionOutput(name = "getRingTimeLimit", type = "java.lang.String") String getRingTimeLimit() {
logger.debug("Doorbird action 'getRingTimeLimit' called");
DoorbellHandler handler = this.handler;
if (handler != null) {
return handler.actionGetRingTimeLimit();
} else {
Expand All @@ -97,6 +102,7 @@ public static String getRingTimeLimit(ThingActions actions) {
@RuleAction(label = "get the call time limit", description = "Get the value of CALL_TIME_LIMIT.")
public @ActionOutput(name = "getCallTimeLimit", type = "java.lang.String") String getCallTimeLimit() {
logger.debug("Doorbird action 'getCallTimeLimit' called");
DoorbellHandler handler = this.handler;
if (handler != null) {
return handler.actionGetCallTimeLimit();
} else {
Expand All @@ -112,6 +118,7 @@ public static String getCallTimeLimit(ThingActions actions) {
@RuleAction(label = "get the last error code", description = "Get the value of LASTERRORCODE.")
public @ActionOutput(name = "getLastErrorCode", type = "java.lang.String") String getLastErrorCode() {
logger.debug("Doorbird action 'getLastErrorCode' called");
DoorbellHandler handler = this.handler;
if (handler != null) {
return handler.actionGetLastErrorCode();
} else {
Expand All @@ -127,6 +134,7 @@ public static String getLastErrorCode(ThingActions actions) {
@RuleAction(label = "get the last error text", description = "Get the value of LASTERRORTEXT.")
public @ActionOutput(name = "getLastErrorText", type = "java.lang.String") String getLastErrorText() {
logger.debug("Doorbird action 'getLastErrorText' called");
DoorbellHandler handler = this.handler;
if (handler != null) {
return handler.actionGetLastErrorText();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public final class DoorbirdAPI {
private static final Gson GSON = new Gson();

private final Logger logger = LoggerFactory.getLogger(DoorbirdAPI.class);
private static final int CHUNK_SIZE = 256;

private @Nullable Authorization authorization;
private @Nullable HttpClient httpClient;
Expand Down Expand Up @@ -191,7 +192,6 @@ public void sendAudio(InputStream audioInputStream) {
// It is crucial to send data in small chunks to not overload the doorbird
// It means that we have to wait the appropriate amount of time between chunk to send
// real time data, as if it were live spoken.
int CHUNK_SIZE = 256;
int nbByteRead = -1;
long nextChunkSendTimeStamp = 0;
do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,10 @@ private void startImageRefreshJob() {
}

private void stopImageRefreshJob() {
ScheduledFuture<?> imageRefreshJob = this.imageRefreshJob;
if (imageRefreshJob != null) {
imageRefreshJob.cancel(true);
imageRefreshJob = null;
this.imageRefreshJob = null;
logger.debug("Canceling image refresh job");
}
}
Expand All @@ -378,6 +379,7 @@ private void startUDPListenerJob() {
}

private void stopUDPListenerJob() {
ScheduledFuture<?> listenerJob = this.listenerJob;
if (listenerJob != null) {
listenerJob.cancel(true);
udpListener.shutdown();
lsiepel marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -390,19 +392,21 @@ private void startDoorbellOffJob() {
if (offDelay == null) {
return;
}
ScheduledFuture<?> doorbellOffJob = this.doorbellOffJob;
if (doorbellOffJob != null) {
doorbellOffJob.cancel(true);
}
doorbellOffJob = scheduler.schedule(() -> {
this.doorbellOffJob = scheduler.schedule(() -> {
logger.debug("Update channel 'doorbell' to OFF for thing {}", getThing().getUID());
triggerChannel(CHANNEL_DOORBELL, CommonTriggerEvents.RELEASED);
}, offDelay, TimeUnit.SECONDS);
}

private void stopDoorbellOffJob() {
ScheduledFuture<?> doorbellOffJob = this.doorbellOffJob;
if (doorbellOffJob != null) {
doorbellOffJob.cancel(true);
doorbellOffJob = null;
this.doorbellOffJob = null;
logger.debug("Canceling doorbell off job");
}
}
Expand All @@ -412,6 +416,7 @@ private void startMotionOffJob() {
if (offDelay == null) {
return;
}
ScheduledFuture<?> motionOffJob = this.motionOffJob;
lsiepel marked this conversation as resolved.
Show resolved Hide resolved
if (motionOffJob != null) {
motionOffJob.cancel(true);
}
Expand All @@ -422,9 +427,10 @@ private void startMotionOffJob() {
}

private void stopMotionOffJob() {
ScheduledFuture<?> motionOffJob = this.motionOffJob;
if (motionOffJob != null) {
motionOffJob.cancel(true);
motionOffJob = null;
this.motionOffJob = null;
logger.debug("Canceling motion off job");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ public void run() {
}

public void shutdown() {
DatagramSocket socket = this.socket;
if (socket != null) {
socket.close();
logger.debug("Listener closing listener socket");
socket = null;
this.socket = null;
}
}

Expand Down