From 1584a74a4acdfb17aab0d6a2b13b18a7799aa37d Mon Sep 17 00:00:00 2001 From: laforge Date: Sat, 2 Sep 2006 10:32:06 +0000 Subject: first compiling (unfinished, not-working) version of userspace gsm infrastructure git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@40 99fdad57-331a-0410-800a-d7fa5415bdb3 --- src/libgsmd/lgsm_internals.h | 4 +++ src/libgsmd/libgsmd.c | 69 +++++++++++++++++++++++++++++++++++++++++ src/libgsmd/libgsmd_input.c | 13 ++++++++ src/libgsmd/libgsmd_voicecall.c | 24 ++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 src/libgsmd/lgsm_internals.h create mode 100644 src/libgsmd/libgsmd.c create mode 100644 src/libgsmd/libgsmd_input.c create mode 100644 src/libgsmd/libgsmd_voicecall.c (limited to 'src/libgsmd') diff --git a/src/libgsmd/lgsm_internals.h b/src/libgsmd/lgsm_internals.h new file mode 100644 index 0000000..66fd5fe --- /dev/null +++ b/src/libgsmd/lgsm_internals.h @@ -0,0 +1,4 @@ + +struct lgsm_handle { + int fd; +}; diff --git a/src/libgsmd/libgsmd.c b/src/libgsmd/libgsmd.c new file mode 100644 index 0000000..e514617 --- /dev/null +++ b/src/libgsmd/libgsmd.c @@ -0,0 +1,69 @@ + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "lgsm_internals.h" + +static int lgsm_open_backend(struct lgsm_handle *lh, const char *device) +{ + int rc; + + if (!strcmp(device, "gsmd")) { + struct sockaddr_un sun; + + /* use unix domain socket to gsm daemon */ + lh->fd = socket(PF_UNIX, GSMD_UNIX_SOCKET_TYPE, 0); + if (lh->fd < 0) + return lh->fd; + + sun.sun_family = AF_UNIX; + memcpy(sun.sun_path, GSMD_UNIX_SOCKET, sizeof(GSMD_UNIX_SOCKET)); + + rc = connect(lh->fd, (struct sockaddr *)&sun, sizeof(sun)); + if (rc < 0) { + close(lh->fd); + lh->fd = -1; + return rc; + } + } else { + /* use direct access to device node ([virtual] tty device) */ + lh->fd = open(device, O_RDWR); + if (lh->fd < 0) + return lh->fd; + } + + return 0; +} + +struct lgsm_handle *lgsm_init(const char *device) +{ + struct lgsm_handle *lh = malloc(sizeof(*lh)); + + memset(lh, 0, sizeof(*lh)); + lh->fd = -1; + + if (lgsm_open_backend(lh, device) < 0) { + free(lh); + return NULL; + } + + /* send some initial commands, such as ATV1 (verbose response) + * and +CRC=1 (which we currently require!) */ + + return lh; +} + +int lgsm_exit(struct lgsm_handle *lh) +{ + free(lh); + + return 0; +} diff --git a/src/libgsmd/libgsmd_input.c b/src/libgsmd/libgsmd_input.c new file mode 100644 index 0000000..134cfea --- /dev/null +++ b/src/libgsmd/libgsmd_input.c @@ -0,0 +1,13 @@ + +#include +#include +#include +#include + +#include + +#include + +#include "lgsm_internals.h" + + diff --git a/src/libgsmd/libgsmd_voicecall.c b/src/libgsmd/libgsmd_voicecall.c new file mode 100644 index 0000000..f59bdff --- /dev/null +++ b/src/libgsmd/libgsmd_voicecall.c @@ -0,0 +1,24 @@ + + +#include + +#include "libgsmd/internals.h" + + +int lgsm_voice_out_init(struct lgsm_handle *lh, + const struct lgsm_addr *number) +{ + /* send ATD command */ + return -EINVAL; +} + +int lgsm_voice_in_accept(struct lgsm_handle *lh) +{ + return -EINVAL; +} + +int lgsm_voice_hangup(struct lgsm_handle *lh) +{ + /* Send ATH0 */ + return -EINVAL; +} -- cgit v1.2.3