From b9933ef78fee574e410a4247e5cc765a632b0822 Mon Sep 17 00:00:00 2001 From: Yalu Zhang <yalu.zhang@iopsys.eu> Date: Mon, 8 May 2023 16:58:21 +0200 Subject: [PATCH] Change the logic for DECT hook event simulation to fit different behaviors on platforms line_new_connection_by_dect() is called in the following scenarios: - DECT handset answers an incoming call - DECT handset initiates an outgoing call Depending upon the current hook state, either OFFHOOK or FLASH is simulated. But different platforms have different ways to simulate the hook events. On Broadcom platform, simulation is a delayed process and the original logic works fine. On Qualcomm/D2 platform, simulation is a synchronized process and the original logic will generate two events, OFFHOOK and FLASH simultaneously. This causes the call be held. --- line.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/line.c b/line.c index 4ef3101..2272b04 100644 --- a/line.c +++ b/line.c @@ -30,7 +30,8 @@ static char *pcmState2Str(callid_state state) void pcm_states_dump(const char *func, int line) { - ENDPT_DBG("%s line: %d pcm_callid[%d]: \'%s\', pcm_callid[%d]: \'%s\'\n", func, line, PCM_0, pcmState2Str(lines[line].pcm_callid[PCM_0]), + ENDPT_DBG("%s: line=%d, pcm_callid[%d]=\'%s\', pcm_callid[%d]=\'%s\'\n", func, line, + PCM_0, pcmState2Str(lines[line].pcm_callid[PCM_0]), PCM_1, pcmState2Str(lines[line].pcm_callid[PCM_1])); } @@ -495,24 +496,21 @@ int line_new_connection_by_dect(int line, const char *cid, int pcm, struct voice { struct line_req_t *line_req; - if (!voice_line_is_ready(line)) + if (!voice_line_is_ready(line) || lines[line].type != VOICE_LINE_DECT) return -1; - if(lines[line].type != VOICE_LINE_DECT) - return -1; - - ENDPT_DBG("%s line: %d, pcm: %d, cid: %s\n", __func__, line, pcm, cid); + ENDPT_DBG("%s: line=%d, pcm=%d, cid=%s\n", __func__, line, pcm, cid); pcm_states_dump(__func__, line); - if(pcm <= PCM_1) { + if (pcm <= PCM_1) { lines[line].pcm_callid[pcm] = CALLID_OBTAINING; lines[line].signaled_call_waiting = 0; } - if(!voice_line_is_offhook(line) && voice_line_simulate_hook(line, VOICE_EVT_OFFHOOK)) - return -1; - - if(voice_line_is_offhook(line)) { + if (!voice_line_is_offhook(line)) { + if (voice_line_simulate_hook(line, VOICE_EVT_OFFHOOK)) + return -1; + } else { switch(pcm) { case CALL_DEFAULT0: case CALL_DEFAULT1: @@ -541,12 +539,12 @@ int line_new_connection_by_dect(int line, const char *cid, int pcm, struct voice /* Store the ubus request in a queue. It will be picked up * later, via the Asterisk ubus answer handler. */ line_req = calloc(1, sizeof(struct line_req_t)); - if(!line_req) return -1; + if (!line_req) return -1; line_req->line = line; line_req->connection_id = -1; line_req->action = ACTION_CONN_CREATE; memcpy(&line_req->ubus, ubus_req, sizeof(struct voice_ubus_req_t)); - if(ubus_queue_req_to_asterisk(line_req)) { + if (ubus_queue_req_to_asterisk(line_req)) { free(line_req); return -1; } -- GitLab