From cbffc8d64707828b045b679e8db0269ae362ffcf Mon Sep 17 00:00:00 2001 From: laforge Date: Mon, 23 Oct 2006 20:28:37 +0000 Subject: more gsmd/libgsm implementation git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@114 99fdad57-331a-0410-800a-d7fa5415bdb3 --- src/libgsmd/libgsmd_voicecall.c | 50 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 6 deletions(-) (limited to 'src/libgsmd/libgsmd_voicecall.c') diff --git a/src/libgsmd/libgsmd_voicecall.c b/src/libgsmd/libgsmd_voicecall.c index 25c565d..2a1d6e6 100644 --- a/src/libgsmd/libgsmd_voicecall.c +++ b/src/libgsmd/libgsmd_voicecall.c @@ -1,24 +1,62 @@ - +#include +#include +#include #include #include "lgsm_internals.h" +int lgsm_send_simple(struct lgsm_handle *lh, int type, int sub_type) +{ + struct gsmd_msg_hdr *gmh; + int rc; + + gmh = lgsm_gmh_fill(type, sub_type, 0); + if (!gmh) + return -ENOMEM; + rc = lgsm_send(lh, gmh); + if (rc < gmh->len + sizeof(*gmh)) { + lgsm_gmh_free(gmh); + return -EIO; + } + lgsm_gmh_free(gmh); + + return 0; +} int lgsm_voice_out_init(struct lgsm_handle *lh, const struct lgsm_addr *number) { - /* send ATD command */ - return -EINVAL; + struct gsmd_msg_hdr *gmh; + struct gsmd_addr *ga; + int rc; + + gmh = lgsm_gmh_fill(GSMD_MSG_VOICECALL, + GSMD_VOICECALL_DIAL, sizeof(*ga)); + if (!gmh) + return -ENOMEM; + ga = (struct gsmd_addr *) gmh->data; + ga->type = number->type; /* FIXME: is this correct? */ + memcpy(ga->number, number->addr, sizeof(ga->number)); + ga->number[sizeof(ga->number)-1] = '\0'; + + rc = lgsm_send(lh, gmh); + if (rc < gmh->len + sizeof(*gmh)) { + lgsm_gmh_free(gmh); + return -EIO; + } + + lgsm_gmh_free(gmh); + + return 0; } int lgsm_voice_in_accept(struct lgsm_handle *lh) { - return -EINVAL; + return lgsm_send_simple(lh, GSMD_MSG_VOICECALL, GSMD_VOICECALL_ANSWER); } int lgsm_voice_hangup(struct lgsm_handle *lh) { - /* Send ATH0 */ - return -EINVAL; + return lgsm_send_simple(lh, GSMD_MSG_VOICECALL, GSMD_VOICECALL_HANGUP); } -- cgit v1.2.3