From fe2e57bc800448703208ab52688b34ffb65bb386 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Tue, 1 Nov 2011 16:29:18 +0100 Subject: host/mobile: Mobile will use SMS Service Center Address from SIM In case the SMS Service Center Address is not set in the config, the Address from the SIM card is used. The mobile checks if either one is defined, otherwise it will refuse sending SMS. Since records of SIM are read, this patch includes fixes to talk correctly with the SIM client. Written-by: Andreas Eversberg Signed-off-by: Sylvain Munaut --- src/host/layer23/src/mobile/gsm411_sms.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/host/layer23/src/mobile/gsm411_sms.c') diff --git a/src/host/layer23/src/mobile/gsm411_sms.c b/src/host/layer23/src/mobile/gsm411_sms.c index a08984d1..4347e86a 100644 --- a/src/host/layer23/src/mobile/gsm411_sms.c +++ b/src/host/layer23/src/mobile/gsm411_sms.c @@ -210,7 +210,7 @@ fail: fp = fopen(sms_file, "a"); if (!fp) goto fail; - fprintf(fp, "[SMS %s]\n%s\n", gsms->address, gsms->text); + fprintf(fp, "[SMS from %s]\n%s\n", gsms->address, gsms->text); fclose(fp); talloc_free(sms_file); @@ -617,9 +617,9 @@ static int gsm340_gen_tpdu(struct msgb *msg, struct gsm_sms *sms) } /* Take a SMS in gsm_sms structure and send it. */ -int gsm411_tx_sms_submit(struct osmocom_ms *ms, struct gsm_sms *sms) +static int gsm411_tx_sms_submit(struct osmocom_ms *ms, const char *sms_sca, + struct gsm_sms *sms) { - struct gsm_settings *set = &ms->settings; struct msgb *msg; struct gsm_trans *trans; uint8_t *data, *rp_ud_len; @@ -668,11 +668,11 @@ int gsm411_tx_sms_submit(struct osmocom_ms *ms, struct gsm_sms *sms) /* Destination Address */ sca[1] = 0x80; /* no extension */ - sca[1] |= ((set->sms_sca[0] == '+') ? 0x01 : 0x00) << 4; /* type */ + sca[1] |= ((sms_sca[0] == '+') ? 0x01 : 0x00) << 4; /* type */ sca[1] |= 0x1; /* plan*/ rc = gsm48_encode_bcd_number(sca, sizeof(sca), 1, - set->sms_sca + (set->sms_sca[0] == '+')); + sms_sca + (sms_sca[0] == '+')); if (rc < 0) { error: gsm411_sms_report(ms, sms, GSM411_RP_CAUSE_SEMANT_INC_MSG); @@ -700,14 +700,15 @@ error: } /* create and send SMS */ -int sms_send(struct osmocom_ms *ms, const char *number, const char *text) +int sms_send(struct osmocom_ms *ms, const char *sms_sca, const char *number, + const char *text) { struct gsm_sms *sms = sms_from_text(number, 0, text); if (!sms) return -ENOMEM; - return gsm411_tx_sms_submit(ms, sms); + return gsm411_tx_sms_submit(ms, sms_sca, sms); } /* -- cgit v1.2.3