summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/src/mobile/gsm411_sms.c
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2011-11-01 16:29:18 +0100
committerSylvain Munaut <tnt@246tNt.com>2011-11-13 20:25:20 +0100
commitfe2e57bc800448703208ab52688b34ffb65bb386 (patch)
treebe456cb7e25ce2f1d3d2f5cfc54ad67be2436c21 /src/host/layer23/src/mobile/gsm411_sms.c
parentfb7be589e6f2a7e8dcbd560a0b0fdbda7d1fd316 (diff)
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 <jolly@eversberg.eu> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src/host/layer23/src/mobile/gsm411_sms.c')
-rw-r--r--src/host/layer23/src/mobile/gsm411_sms.c15
1 files changed, 8 insertions, 7 deletions
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);
}
/*