summaryrefslogtreecommitdiff
path: root/src/libgsmd
diff options
context:
space:
mode:
authorlaforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-08-17 08:29:08 +0000
committerlaforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-08-17 08:29:08 +0000
commit348c9af2fce8d0d53341d9861494b5c13f9796f1 (patch)
treedbd6253c09e77e9c72ff082f2284ed0b6ba9165b /src/libgsmd
parent1c4526b52edc7c245cb76ba801bbbe9da1a3b5ae (diff)
From: Andrzej Zaborowski <balrog@zabor.org>
Date: Thu, 26 Jul 2007 00:32:38 +0200 Subject: [PATCH] SMSC and Preferred Storage operations. This adds setting and retrieval of SMS storage stats (memory type, used entries, all entries), and of the default service centre (SMSC) number for outgoing messages. The operation of setting a new SMSC number is untested because my SIM doesn't seem to allow this (that or I did something wrong). New "libgmsd-tool -m shell" commands for testing are also added. Other changes in this patch: * The third, optional, parameter to +CMGL: is a string, not an integer as I wrongly assumed earlier, this is now corrected. * Rename libgsmd API functions starting with lgsmd_.. to lgsm_.. for consistency with all other identifiers. * Move lgsm_send_simple() to libgsmd.c and add a prototype in lgsm_internals.h, this eliminates some compile-time warnings. git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@2720 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'src/libgsmd')
-rw-r--r--src/libgsmd/lgsm_internals.h1
-rw-r--r--src/libgsmd/libgsmd.c17
-rw-r--r--src/libgsmd/libgsmd_sms.c68
-rw-r--r--src/libgsmd/libgsmd_voicecall.c18
4 files changed, 79 insertions, 25 deletions
diff --git a/src/libgsmd/lgsm_internals.h b/src/libgsmd/lgsm_internals.h
index 94421fa..c826723 100644
--- a/src/libgsmd/lgsm_internals.h
+++ b/src/libgsmd/lgsm_internals.h
@@ -11,6 +11,7 @@ struct lgsm_handle {
};
int lgsm_send(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh);
+int lgsm_send_simple(struct lgsm_handle *lh, int type, int sub_type);
struct gsmd_msg_hdr *lgsm_gmh_fill(int type, int subtype, int payload_len);
#define lgsm_gmh_free(x) free(x)
diff --git a/src/libgsmd/libgsmd.c b/src/libgsmd/libgsmd.c
index 11760b4..37a50e6 100644
--- a/src/libgsmd/libgsmd.c
+++ b/src/libgsmd/libgsmd.c
@@ -207,3 +207,20 @@ struct gsmd_msg_hdr *lgsm_gmh_fill(int type, int subtype, int payload_len)
return gmh;
}
+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;
+}
diff --git a/src/libgsmd/libgsmd_sms.c b/src/libgsmd/libgsmd_sms.c
index 9ac9bf2..29b92fb 100644
--- a/src/libgsmd/libgsmd_sms.c
+++ b/src/libgsmd/libgsmd_sms.c
@@ -57,7 +57,7 @@ int lgsm_sms_read(struct lgsm_handle *lh, int index)
return 0;
}
-int lgsmd_sms_delete(struct lgsm_handle *lh,
+int lgsm_sms_delete(struct lgsm_handle *lh,
const struct lgsm_sms_delete *sms_del)
{
struct gsmd_msg_hdr *gmh;
@@ -83,7 +83,7 @@ int lgsmd_sms_delete(struct lgsm_handle *lh,
return 0;
}
-int lgsmd_number2addr(struct gsmd_addr *dst, const char *src)
+int lgsm_number2addr(struct gsmd_addr *dst, const char *src, int skipplus)
{
char *ch;
@@ -94,7 +94,7 @@ int lgsmd_number2addr(struct gsmd_addr *dst, const char *src)
GSMD_TOA_NPI_ISDN |
GSMD_TOA_TON_INTERNATIONAL |
GSMD_TOA_RESERVED;
- strcpy(dst->number, src + 1);
+ strcpy(dst->number, src + skipplus);
} else {
dst->type =
GSMD_TOA_NPI_ISDN |
@@ -109,7 +109,7 @@ int lgsmd_number2addr(struct gsmd_addr *dst, const char *src)
return 0;
}
-int lgsmd_sms_send(struct lgsm_handle *lh,
+int lgsm_sms_send(struct lgsm_handle *lh,
const struct lgsm_sms *sms)
{
/* FIXME: only support PDU mode */
@@ -123,7 +123,7 @@ int lgsmd_sms_send(struct lgsm_handle *lh,
return -ENOMEM;
gss = (struct gsmd_sms_submit *) gmh->data;
- if (lgsmd_number2addr(&gss->addr, sms->addr))
+ if (lgsm_number2addr(&gss->addr, sms->addr, 1))
return -EINVAL;
gss->payload.has_header = 0;
@@ -142,7 +142,7 @@ int lgsmd_sms_send(struct lgsm_handle *lh,
return 0;
}
-int lgsmd_sms_write(struct lgsm_handle *lh,
+int lgsm_sms_write(struct lgsm_handle *lh,
const struct lgsm_sms_write *sms_write)
{
/* FIXME: only support PDU mode */
@@ -158,7 +158,7 @@ int lgsmd_sms_write(struct lgsm_handle *lh,
gsw->stat = sms_write->stat;
- if (lgsmd_number2addr(&gsw->sms.addr, sms_write->sms.addr))
+ if (lgsm_number2addr(&gsw->sms.addr, sms_write->sms.addr, 1))
return -EINVAL;
gsw->sms.payload.has_header = 0;
@@ -178,6 +178,60 @@ int lgsmd_sms_write(struct lgsm_handle *lh,
return 0;
}
+int lgsm_sms_get_storage(struct lgsm_handle *lh)
+{
+ return lgsm_send_simple(lh, GSMD_MSG_SMS, GSMD_SMS_GET_MSG_STORAGE);
+}
+
+int lgsm_sms_set_storage(struct lgsm_handle *lh, enum ts0705_mem_type mem1,
+ enum ts0705_mem_type mem2, enum ts0705_mem_type mem3)
+{
+ struct gsmd_msg_hdr *gmh =
+ lgsm_gmh_fill(GSMD_MSG_SMS, GSMD_SMS_SET_MSG_STORAGE,
+ 3 * sizeof(enum ts0705_mem_type));
+ if (!gmh)
+ return -ENOMEM;
+
+ ((enum ts0705_mem_type *) gmh->data)[0] = mem1;
+ ((enum ts0705_mem_type *) gmh->data)[1] = mem2;
+ ((enum ts0705_mem_type *) gmh->data)[2] = mem3;
+
+ if (lgsm_send(lh, gmh) < gmh->len + sizeof(*gmh)) {
+ lgsm_gmh_free(gmh);
+ return -EIO;
+ }
+
+ lgsm_gmh_free(gmh);
+ return 0;
+}
+
+int lgsm_sms_get_smsc(struct lgsm_handle *lh)
+{
+ return lgsm_send_simple(lh, GSMD_MSG_SMS, GSMD_SMS_GET_SERVICE_CENTRE);
+}
+
+int lgsm_sms_set_smsc(struct lgsm_handle *lh, const char *number)
+{
+ struct gsmd_msg_hdr *gmh =
+ lgsm_gmh_fill(GSMD_MSG_SMS, GSMD_SMS_SET_SERVICE_CENTRE,
+ sizeof(struct gsmd_addr));
+ if (!gmh)
+ return -ENOMEM;
+
+ if (lgsm_number2addr((struct gsmd_addr *) gmh->data, number, 0)) {
+ lgsm_gmh_free(gmh);
+ return -EINVAL;
+ }
+
+ if (lgsm_send(lh, gmh) < gmh->len + sizeof(*gmh)) {
+ lgsm_gmh_free(gmh);
+ return -EIO;
+ }
+
+ lgsm_gmh_free(gmh);
+ return 0;
+}
+
int packing_7bit_character(const char *src, struct lgsm_sms *dest)
{
int i,j = 0;
diff --git a/src/libgsmd/libgsmd_voicecall.c b/src/libgsmd/libgsmd_voicecall.c
index d6965fa..d78fb3d 100644
--- a/src/libgsmd/libgsmd_voicecall.c
+++ b/src/libgsmd/libgsmd_voicecall.c
@@ -28,24 +28,6 @@
#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)
{
personal git repositories of Harald Welte. Your mileage may vary