From 596419ec92e02fbb4d8924ac036b4520f95379bc Mon Sep 17 00:00:00 2001
From: Grzegorz Sluja <grzegorz.sluja@sigma.se>
Date: Tue, 2 Aug 2022 12:10:47 +0200
Subject: [PATCH] Handle incoming call properly in case if there is no free
 DECT handset

---
 channels/chan_brcm.c | 3 +++
 channels/chan_brcm.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/channels/chan_brcm.c b/channels/chan_brcm.c
index a1d2220164..436e25e1ea 100644
--- a/channels/chan_brcm.c
+++ b/channels/chan_brcm.c
@@ -271,6 +271,7 @@ static struct endpt_event event_map[] = {
 	{ .name = "EARLY_ONHOOK", .event = EVENT_EARLY_ONHOOK },
 	{ .name = "FLASH", .event = EVENT_FLASH },
 	{ .name = "CALL_REJECT", .event = EVENT_CALL_REJECT },
+	{ .name = "DECT_UNAVAILABLE", .event = EVENT_DECT_UNAVAILABLE },
 	{ .name = "MEDIA", .event = EVENT_MEDIA },
 	{ .name = "SWITCH", .event = EVENT_SWITCH },
 	{ .name = "JOIN", .event = EVENT_JOIN },
@@ -2997,6 +2998,8 @@ static void brcm_process_event(struct endpt_event *ev)
 					ast_queue_control(owner, AST_CONTROL_HANGUP);
 			}
 			break;
+		case EVENT_DECT_UNAVAILABLE:
+			ast_queue_control(owner, AST_CONTROL_HANGUP);
 		case EVENT_SWITCH:
 		case EVENT_JOIN:
 		case EVENT_RELEASE:
diff --git a/channels/chan_brcm.h b/channels/chan_brcm.h
index 79e3aea545..e2df705cd9 100644
--- a/channels/chan_brcm.h
+++ b/channels/chan_brcm.h
@@ -79,6 +79,7 @@ enum LINE_EVENT {																// Events from low level line (endpoint etc.)
 	EVENT_EARLY_ONHOOK,
 	EVENT_FLASH,
 	EVENT_CALL_REJECT,
+	EVENT_DECT_UNAVAILABLE,
 	EVENT_MEDIA,
 	EVENT_SWITCH,
 	EVENT_JOIN,
-- 
GitLab