From 315e8b45506745f4b28f658772cc65cdef9a2d9e Mon Sep 17 00:00:00 2001 From: erin_yueh Date: Thu, 3 Jan 2008 09:13:39 +0000 Subject: gsmd: add Call Forwarding function (Sean Chiang) git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@3760 99fdad57-331a-0410-800a-d7fa5415bdb3 --- include/gsmd/usock.h | 38 +++++++++++ include/libgsmd/voicecall.h | 35 ++++++++++ src/gsmd/usock.c | 148 +++++++++++++++++++++++++++++++++++++++- src/libgsmd/libgsmd_voicecall.c | 123 +++++++++++++++++++++++++++++++++ src/util/shell.c | 57 +++++++++++++++- 5 files changed, 399 insertions(+), 2 deletions(-) diff --git a/include/gsmd/usock.h b/include/gsmd/usock.h index d05f2bc..ddec870 100644 --- a/include/gsmd/usock.h +++ b/include/gsmd/usock.h @@ -43,6 +43,11 @@ enum gsmd_msg_voicecall_type { GSMD_VOICECALL_VOL_GET = 6, GSMD_VOICECALL_GET_STAT = 7, GSMD_VOICECALL_CTRL = 8, + GSMD_VOICECALL_FWD_DIS = 9, + GSMD_VOICECALL_FWD_EN = 10, + GSMD_VOICECALL_FWD_STAT = 11, + GSMD_VOICECALL_FWD_REG = 12, + GSMD_VOICECALL_FWD_ERAS = 13, }; @@ -99,6 +104,22 @@ enum gsmd_call_ctrl_proc { GSMD_CALL_CTRL_M_HELD = 6, // 3 }; +/* call forward reason from 3GPP TS 07.07 subclause 07.10 */ +enum gsmd_call_fwd_reason { + GSMD_CALL_FWD_REASON_UNCOND = 0, + GSMD_CALL_FWD_REASON_BUSY = 1, + GSMD_CALL_FWD_REASON_NO_REPLY = 2, + GSMD_CALL_FWD_REASON_NOT_REACHABLE = 3, + GSMD_CALL_FWD_REASON_ALL_FORWARD = 4, + GSMD_CALL_FWD_REASON_ALL_COND_FORWARD = 5, +}; + +/* call forward status from 3GPP TS 07.07 subclause 07.10 */ +enum gsmd_call_fwd_status { + GSMD_CALL_FWD_STATUS_NOT_ACTIVE = 0, + GSMD_CALL_FWD_STATUS_ACTIVE = 1, +}; + /* Handset / MT related commands */ enum gsmd_msg_phone_type { GSMD_PHONE_VOLUME = 1, @@ -384,6 +405,23 @@ struct gsmd_call_ctrl { u_int8_t idx; } __attribute__ ((packed)); +/* call forwarding register from 3GPP TS 07.07 clause 7.10 */ +struct gsmd_call_fwd_reg { + enum gsmd_call_fwd_reason reason; + struct gsmd_addr addr; +} __attribute__ ((packed)); + +/* status of call forwarding from 3GPP TS 07.07 clause 7.10 */ +struct gsmd_call_fwd_stat { + enum gsmd_call_fwd_status status; + u_int8_t classx; + struct gsmd_addr addr; + char subaddr[16+1]; + u_int8_t satype; + u_int8_t time; + int is_last; +} __attribute__ ((packed)); + #define GSMD_PIN_MAXLEN 8 struct gsmd_pin { enum gsmd_pin_type type; diff --git a/include/libgsmd/voicecall.h b/include/libgsmd/voicecall.h index ac7b99c..87ecfcc 100644 --- a/include/libgsmd/voicecall.h +++ b/include/libgsmd/voicecall.h @@ -22,12 +22,28 @@ enum lgsm_voicecall_ctrl_proc { LGSM_VOICECALL_CTRL_M_HELD = 6, // 3 }; +/* call forward reason from 3GPP TS 07.07 subclause 07.10 */ +enum lgsmd_voicecall_fwd_reason { + GSMD_VOICECALL_FWD_REASON_UNCOND = 0, + GSMD_VOICECALL_FWD_REASON_BUSY = 1, + GSMD_VOICECALL_FWD_REASON_NO_REPLY = 2, + GSMD_VOICECALL_FWD_REASON_NOT_REACHABLE = 3, + GSMD_VOICECALL_FWD_REASON_ALL_FORWARD = 4, + GSMD_VOICECALL_FWD_REASON_ALL_COND_FORWARD = 5, +}; + /* Refer to GSM 07.07 subclause 7.12 and 02.30 subclause 4.5.5.1 */ struct lgsm_voicecall_ctrl { enum lgsm_voicecall_ctrl_proc proc; int idx; }; +/* Refer to GSM 07.07 subclause 07.10 */ +struct lgsm_voicecall_fwd_reg { + enum lgsmd_voicecall_fwd_reason reason; + struct lgsm_addr number; +}; + /* Initiate an outgoing voice call */ extern int lgsm_voice_out_init(struct lgsm_handle *lh, const struct lgsm_addr *number); @@ -48,4 +64,23 @@ extern int lgsm_voice_get_status(struct lgsm_handle *lh); extern int lgsm_voice_ctrl(struct lgsm_handle *lh, const struct lgsm_voicecall_ctrl *ctrl); +/* disable call forwarding */ +extern int lgsm_voice_fwd_disable(struct lgsm_handle *lh, + enum lgsmd_voicecall_fwd_reason reason); + +/* enable call forwarding */ +extern int lgsm_voice_fwd_enable(struct lgsm_handle *lh, + enum lgsmd_voicecall_fwd_reason reason); + +/* querty current status/setting of call forwarding */ +extern int lgsm_voice_fwd_stat(struct lgsm_handle *lh, + enum lgsmd_voicecall_fwd_reason reason); + +/* register call forwarding */ +extern int lgsm_voice_fwd_reg(struct lgsm_handle *lh, + struct lgsm_voicecall_fwd_reg *fwd_reg); + +/* erase the record of registered call forwarding */ +extern int lgsm_voice_fwd_erase(struct lgsm_handle *lh, + enum lgsmd_voicecall_fwd_reason reason); #endif diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c index c7a0224..5caedac 100644 --- a/src/gsmd/usock.c +++ b/src/gsmd/usock.c @@ -217,6 +217,75 @@ static int voicecall_ctrl_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) cmd->id, sizeof(ret), &ret); } +static int voicecall_fwd_stat_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp) +{ + struct gsmd_user *gu = ctx; + struct gsm_extrsp *er; + struct gsmd_call_fwd_stat gcfs; + int ret = 0; + + DEBUGP("resp: %s\n", resp); + + er = extrsp_parse(cmd, resp); + + if ( !er ) + return -ENOMEM; + + gcfs.is_last = (cmd->ret == 0 || cmd->ret == 4)? 1:0; + + if ( er->num_tokens == 2 && + er->tokens[0].type == GSMD_ECMD_RTT_NUMERIC && + er->tokens[1].type == GSMD_ECMD_RTT_NUMERIC ) { + + /* + * +CCFC: ,[,, + * [,,[,