From 23dfcf4ff925f61bcb2c3bdd712ff0f70bde4fcb Mon Sep 17 00:00:00 2001 From: laforge Date: Tue, 24 Oct 2006 13:07:08 +0000 Subject: - clean up header files (all in include/gmsd now) - finish vendor plugin support - add call progress indicator and signal quality unsolicited support to vendor_ti.c git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@120 99fdad57-331a-0410-800a-d7fa5415bdb3 --- include/gsmd/atcmd.h | 17 +++++++++ include/gsmd/gsmd.h | 88 +++++++++++++++++++++++++++++++++++++++++++++ include/gsmd/select.h | 26 ++++++++++++++ include/gsmd/unsolicited.h | 18 ++++++++++ include/gsmd/usock.h | 41 ++++++++++++++++++++- include/gsmd/vendorplugin.h | 27 ++++++++++++++ 6 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 include/gsmd/atcmd.h create mode 100644 include/gsmd/select.h create mode 100644 include/gsmd/unsolicited.h create mode 100644 include/gsmd/vendorplugin.h (limited to 'include') diff --git a/include/gsmd/atcmd.h b/include/gsmd/atcmd.h new file mode 100644 index 0000000..0d6c62a --- /dev/null +++ b/include/gsmd/atcmd.h @@ -0,0 +1,17 @@ +#ifndef __GSMD_ATCMD_H +#define __GSMD_ATCMD_H + +#ifdef __GSMD__ + +#include + +typedef int atcmd_cb_t(struct gsmd_atcmd *cmd, void *ctx, char *resp); + +extern struct gsmd_atcmd *atcmd_fill(const char *cmd, int rlen, atcmd_cb_t *cb, void *ctx, u_int16_t id); +extern int atcmd_submit(struct gsmd *g, struct gsmd_atcmd *cmd); +extern int atcmd_init(struct gsmd *g, int sockfd); +extern void atcmd_drain(int fd); + +#endif /* __GSMD__ */ + +#endif diff --git a/include/gsmd/gsmd.h b/include/gsmd/gsmd.h index f5b61d5..9b99a15 100644 --- a/include/gsmd/gsmd.h +++ b/include/gsmd/gsmd.h @@ -1,4 +1,92 @@ #ifndef _GSMD_H #define _GSMD_H +#ifdef __GSMD__ + +#include + +#include + +#include +#include + +/* Refer to 3GPP TS 07.07 v 7.8.0, Chapter 4.1 */ +#define LGSM_ATCMD_F_EXTENDED 0x01 /* as opposed to basic */ +#define LGSM_ATCMD_F_PARAM 0x02 /* as opposed to action */ + +struct gsmd_atcmd { + struct llist_head list; + void *ctx; + int (*cb)(struct gsmd_atcmd *cmd, void *ctx, char *resp); + char *resp; + int32_t ret; + u_int32_t buflen; + u_int16_t id; + u_int8_t flags; + char buf[]; +}; + +enum llparse_state { + LLPARSE_STATE_IDLE, /* idle, not parsing a response */ + LLPARSE_STATE_IDLE_CR, /* CR before response (V1) */ + LLPARSE_STATE_IDLE_LF, /* LF before response (V1) */ + LLPARSE_STATE_RESULT, /* within result payload */ + LLPARSE_STATE_RESULT_CR, /* CR after result */ + LLPARSE_STATE_ERROR, /* something went wrong */ + /* ... idle again */ +}; + +/* we can't take any _single_ response bigger than this: */ +#define LLPARSE_BUF_SIZE 256 + +struct llparser { + enum llparse_state state; + unsigned int len; + unsigned int flags; + void *ctx; + int (*cb)(const char *buf, int len, void *ctx); + char *cur; + char buf[LLPARSE_BUF_SIZE]; +}; + +struct gsmd; + +#define GSMD_FLAG_V0 0x0001 /* V0 responses to be expected from TA */ + +struct gsmd { + unsigned int flags; + struct gsmd_fd gfd_uart; + struct gsmd_fd gfd_sock; + struct llparser llp; + struct llist_head users; + struct llist_head pending_atcmds; /* our busy gsmd_atcmds */ + struct llist_head busy_atcmds; /* our busy gsmd_atcmds */ + struct gsmd_vendor_plugin *vendorpl; +}; + +struct gsmd_user { + struct llist_head list; /* our entry in the global list */ + struct llist_head finished_ucmds; /* our busy gsmd_ucmds */ + struct gsmd *gsmd; + struct gsmd_fd gfd; /* the socket */ + u_int32_t subscriptions; /* bitmaks of subscribed event groups */ +}; + +#define GSMD_DEBUG 1 /* debugging information */ +#define GSMD_INFO 3 +#define GSMD_NOTICE 5 /* abnormal/unexpected condition */ +#define GSMD_ERROR 7 /* error condition, requires user action */ +#define GSMD_FATAL 8 /* fatal, program aborted */ + +extern int gsmdlog_init(const char *path); +/* write a message to the daemons' logfile */ +void __gsmd_log(int level, const char *file, int line, const char *function, const char *message, ...); +/* macro for logging including filename and line number */ +#define gsmd_log(level, format, args ...) \ + __gsmd_log(level, __FILE__, __LINE__, __FUNCTION__, format, ## args) + +#define DEBUGP(x, args ...) gsmd_log(GSMD_DEBUG, x, ## args) + +#endif /* __GSMD__ */ + #endif /* _GSMD_H */ diff --git a/include/gsmd/select.h b/include/gsmd/select.h new file mode 100644 index 0000000..b75c338 --- /dev/null +++ b/include/gsmd/select.h @@ -0,0 +1,26 @@ +#ifndef __GSMD_SELECT_H +#define __GSMD_SELECT_H + +#ifdef __GSMD__ + +#include + +#define GSMD_FD_READ 0x0001 +#define GSMD_FD_WRITE 0x0002 +#define GSMD_FD_EXCEPT 0x0004 + +struct gsmd_fd { + struct llist_head list; + int fd; /* file descriptor */ + unsigned int when; + int (*cb)(int fd, unsigned int what, void *data); + void *data; /* void * to pass to callback */ +}; + +extern int gsmd_register_fd(struct gsmd_fd *ufd); +extern void gsmd_unregister_fd(struct gsmd_fd *ufd); +extern int gsmd_select_main(void); + +#endif /* __GSMD__ */ + +#endif diff --git a/include/gsmd/unsolicited.h b/include/gsmd/unsolicited.h new file mode 100644 index 0000000..e7f17c5 --- /dev/null +++ b/include/gsmd/unsolicited.h @@ -0,0 +1,18 @@ +#ifndef __GSMD_UNSOLICITED_H +#define __GSMD_UNSOLICITED_H + +#ifdef __GSMD__ + +#include + +struct gsmd_unsolicit { + const char *prefix; + int (*parse)(char *unsol, int len, const char *param, struct gsmd *gsmd); +}; + +extern int unsolicited_parse(struct gsmd *g, char *buf, int len, const char *param); +extern int generate_event_from_cme(struct gsmd *g, unsigned int cme_error); + +#endif /* __GSMD__ */ + +#endif diff --git a/include/gsmd/usock.h b/include/gsmd/usock.h index 2eaa6cf..94e8c37 100644 --- a/include/gsmd/usock.h +++ b/include/gsmd/usock.h @@ -53,6 +53,9 @@ enum gsmd_msg_phone { enum gsmd_msg_network { GSMD_NETWORK_REGISTER = 1, + GSMD_NETWORK_SIGQ_GET = 2, + GSMD_NETWORK_VMAIL_GET = 3, + GSMD_NETWORK_VMAIL_SET = 4, }; /* Length from 3GPP TS 04.08, Clause 10.5.4.7 */ @@ -61,7 +64,17 @@ enum gsmd_msg_network { struct gsmd_addr { u_int8_t type; char number[GSMD_ADDR_MAXLEN+1]; -}; +} __attribute__ ((packed)); + +struct gsmd_signal_quality { + u_int8_t rssi; + u_int8_t ber; +} __attribute__ ((packed)); + +struct gsmd_voicemail { + u_int8_t enable; + struct gsmd_addr addr; +} __attribute__ ((packed)); struct gsmd_evt_auxdata { union { @@ -89,6 +102,9 @@ struct gsmd_evt_auxdata { struct { u_int8_t tz; } timezone; + struct { + struct gsmd_signal_quality sigq; + } signal; } u; } __attribute__((packed)); @@ -103,4 +119,27 @@ struct gsmd_msg_hdr { } __attribute__((packed)); +#ifdef __GSMD__ + +#include + +#include +#include + +struct gsmd_user; + +struct gsmd_ucmd { + struct llist_head list; + struct gsmd_msg_hdr hdr; + char buf[]; +} __attribute__ ((packed)); + +extern int usock_init(struct gsmd *g); +extern void usock_cmd_enqueue(struct gsmd_ucmd *ucmd, struct gsmd_user *gu); +extern struct gsmd_ucmd *usock_build_event(u_int8_t type, u_int8_t subtype, u_int8_t len); +extern int usock_evt_send(struct gsmd *gsmd, struct gsmd_ucmd *ucmd, u_int32_t evt); + +#endif /* __GSMD__ */ + #endif + diff --git a/include/gsmd/vendorplugin.h b/include/gsmd/vendorplugin.h new file mode 100644 index 0000000..c3843b2 --- /dev/null +++ b/include/gsmd/vendorplugin.h @@ -0,0 +1,27 @@ +#ifndef _GSMD_VENDORPLUGIN_H +#define _GSMD_VENDORPLUGIN_H + +#ifdef __GSMD__ + +#include +#include + +struct gsmd; +struct gsmd_unsolicit; + +struct gsmd_vendor_plugin { + struct llist_head list; + unsigned char *name; + unsigned int num_unsolicit; + const struct gsmd_unsolicit *unsolicit; + int (*detect)(struct gsmd *g); + int (*initsettings)(struct gsmd *g); +}; + +extern int gsmd_vendor_plugin_register(struct gsmd_vendor_plugin *pl); +extern void gsmd_vendor_plugin_unregister(struct gsmd_vendor_plugin *pl); +extern int gsmd_vendor_plugin_find(struct gsmd *g); + +#endif /* __GSMD__ */ + +#endif -- cgit v1.2.3