Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
Rename modem response: ^CEND --> VOICE CALL.
Voice handling isn't based on this response. Just print prettier message to logger.
  • Loading branch information
RoEdAl committed May 26, 2024
1 parent 6f82ba4 commit 7058dcf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 82 deletions.
83 changes: 2 additions & 81 deletions src/at_response.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,73 +143,6 @@ static void request_clcc(struct pvt* pvt)

static int at_response_cmgs_error(struct pvt*, const at_queue_task_t* const);

#ifdef HANDLE_RCEND
static int at_response_rcend(struct pvt* pvt)
{
int call_index = 0;
unsigned int duration = 0;
int end_status = 0;
int cc_cause = 0;
struct cpvt* cpvt;

cpvt = active_cpvt(pvt);
if (cpvt) {
if (CPVT_IS_SOUND_SOURCE(cpvt)) {
at_enqueue_cpcmreg(&pvt->sys_chan, 0);
}
call_index = cpvt->call_idx;
ast_debug(1, "[%s] CEND: call_index %d duration %d end_status %d cc_cause %d Line disconnected\n", PVT_ID(pvt), call_index, duration, end_status,
cc_cause);
CPVT_RESET_FLAG(cpvt, CALL_FLAG_NEED_HANGUP);
PVT_STAT(pvt, calls_duration[cpvt->dir]) += duration;
change_channel_state(cpvt, CALL_STATE_RELEASED, cc_cause);
}

return 0;
}
#endif

#ifdef HANDLE_CEND
static int at_response_cend(struct pvt* const pvt, const char* str)
{
int call_index = 0;
int duration = 0;
int end_status = 0;
int cc_cause = 0;
struct cpvt* cpvt;

request_clcc(pvt);

/*
* parse CEND info in the following format:
* ^CEND:<call_index>,<duration>,<end_status>[,<cc_cause>]
*/

if (sscanf(str, "VOICE CALL: END: %d", &duration) != 1) {
ast_debug(1, "[%s] Could not parse all CEND parameters\n", PVT_ID(pvt));
return 0;
}

ast_debug(1, "[%s] CEND: call_index %d duration %d end_status %d cc_cause %d Line disconnected\n", PVT_ID(pvt), call_index, duration, end_status, cc_cause);


cpvt = active_cpvt(pvt);
if (cpvt) {
at_enqueue_cpcmreg(&pvt->sys_chan, 0);
call_index = cpvt->call_idx;
ast_debug(1, "[%s] CEND: call_index %d duration %d end_status %d cc_cause %d Line disconnected\n", PVT_ID(pvt), call_index, duration, end_status,
cc_cause);
CPVT_RESET_FLAG(cpvt, CALL_FLAG_NEED_HANGUP);
PVT_STAT(pvt, calls_duration[cpvt->dir]) += duration;
change_channel_state(cpvt, CALL_STATE_RELEASED, cc_cause);
} else {
ast_log(LOG_ERROR, "[%s] CEND event for unknown call idx '%d'\n", PVT_ID(pvt), call_index);
}

return 0;
}
#endif

static void __attribute__((format(printf, 7, 8))) at_ok_response_log(int level, const char* file, int line, const char* function, const struct pvt* const pvt,
const at_queue_cmd_t* const ecmd, const char* const fmt, ...)
{
Expand Down Expand Up @@ -2810,6 +2743,8 @@ int at_response(struct pvt* const pvt, const struct ast_str* const response, con
case RES_CPMS:
case RES_CONF:
case RES_DST:
case RES_VOICE_CALL:
case RES_RCEND:
return 0;

case RES_OK:
Expand All @@ -2829,20 +2764,6 @@ int at_response(struct pvt* const pvt, const struct ast_str* const response, con
case RES_DSCI:
return at_response_dsci(pvt, response);

case RES_CEND:
#ifdef HANDLE_CEND
return at_response_cend(pvt, str);
#else
return 0;
#endif

case RES_RCEND:
#ifdef HANDLE_RCEND
return at_response_rcend(pvt);
#else
return 0;
#endif

case RES_CREG:
case RES_CEREG:
/* An error here is not fatal. Just keep going. */
Expand Down
2 changes: 1 addition & 1 deletion src/at_response.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct iovec;
/* and "ERROR+CNUM:", hacked later on */ \
\
_(DSCI, "^DSCI", "^DSCI:") \
_(CEND, "^CEND", "VOICE CALL:") \
_(VOICE_CALL, "VOICE CALL", "VOICE CALL:") \
_(CPIN, "+CPIN", "+CPIN:") \
\
_(CREG, "+CREG", "+CREG:") \
Expand Down

0 comments on commit 7058dcf

Please sign in to comment.