summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/src/mobile/script_lua.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2017-12-26 12:46:30 +0800
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2017-12-27 10:07:17 +0800
commita8130aba91247e07df83d2612f14d58d9a45eaa7 (patch)
treec72730d9c1edb60e2716b70a4b5a1fbca383a9be /src/host/layer23/src/mobile/script_lua.c
parentf02c04f4441ae0d05f46f5fdfd1aa8181ede57a8 (diff)
mobile: Send SMS through the primitive interface
Make this symmetric and send the SMS through the primitive interface. Construct and copy the sms into the prim, store the SCA in the prim as well. In 04.11 we see we can store 2*10 digits in the destination address and a NUL. Change-Id: I91d7537f4f6ce5ba00218c58f3456947ec7bc662
Diffstat (limited to 'src/host/layer23/src/mobile/script_lua.c')
-rw-r--r--src/host/layer23/src/mobile/script_lua.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/host/layer23/src/mobile/script_lua.c b/src/host/layer23/src/mobile/script_lua.c
index 1b80c485..14ab58fd 100644
--- a/src/host/layer23/src/mobile/script_lua.c
+++ b/src/host/layer23/src/mobile/script_lua.c
@@ -372,7 +372,9 @@ static int lua_ms_shutdown(lua_State *L)
static int lua_ms_sms_send_simple(lua_State *L)
{
const char *sms_sca, *number, *text;
- int msg_ref, rc;
+ struct mobile_prim *prim;
+ struct gsm_sms *sms;
+ int msg_ref;
luaL_argcheck(L, lua_isnumber(L, -1), 4, "msg_ref needs to be a number");
luaL_argcheck(L, lua_isstring(L, -2), 3, "text must be a string");
@@ -384,8 +386,21 @@ static int lua_ms_sms_send_simple(lua_State *L)
number = lua_tostring(L, -3);
sms_sca = lua_tostring(L, -4);
- rc = sms_send(get_primitive(L)->ms, sms_sca, number, text, msg_ref);
- lua_pushinteger(L, rc);
+ prim = mobile_prim_alloc(PRIM_MOB_SMS, PRIM_OP_REQUEST);
+
+ sms = sms_from_text(number, 0, text);
+ if (!sms) {
+ lua_pushinteger(L, -ENOMEM);
+ msgb_free(prim->hdr.msg);
+ return 1;
+ }
+
+ prim->u.sms.sms = *sms;
+ prim->u.sms.sms.msg_ref = msg_ref;
+ osmo_strlcpy(prim->u.sms.sca, sms_sca, sizeof(prim->u.sms.sca));
+ mobile_prim_intf_req(get_primitive(L), prim);
+
+ lua_pushinteger(L, 0);
return 1;
}