diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2018-08-29 08:27:03 +0100 |
---|---|---|
committer | Holger Freyther <holger@freyther.de> | 2018-09-16 13:51:29 +0000 |
commit | b4294471684b6b56c4c93479be7e7771f5d8a676 (patch) | |
tree | e4da5d4ffd292e1047dc8e2c9e38a235c3028e6a /src/host | |
parent | 6b8fd006d4f3f0e28f8f8b185ac2b28659faf4c0 (diff) |
lua: Expose API to trigger a network reselection
Same as the "network search" VTY command but implemented as primitive
and exposed to LUA.
Change-Id: I096233a2ca9dd7daa358cebed0523cb8c0dbf593
Diffstat (limited to 'src/host')
-rw-r--r-- | src/host/layer23/include/osmocom/bb/mobile/primitives.h | 1 | ||||
-rw-r--r-- | src/host/layer23/src/mobile/primitives.c | 15 | ||||
-rw-r--r-- | src/host/layer23/src/mobile/script_lua.c | 11 |
3 files changed, 27 insertions, 0 deletions
diff --git a/src/host/layer23/include/osmocom/bb/mobile/primitives.h b/src/host/layer23/include/osmocom/bb/mobile/primitives.h index 034b2029..f07ae244 100644 --- a/src/host/layer23/include/osmocom/bb/mobile/primitives.h +++ b/src/host/layer23/include/osmocom/bb/mobile/primitives.h @@ -20,6 +20,7 @@ enum mobile_prims { PRIM_MOB_SHUTDOWN, PRIM_MOB_SMS, PRIM_MOB_MM, + PRIM_MOB_NETWORK_RESELECT, }; struct mobile_prim_intf { diff --git a/src/host/layer23/src/mobile/primitives.c b/src/host/layer23/src/mobile/primitives.c index aa467128..f562466a 100644 --- a/src/host/layer23/src/mobile/primitives.c +++ b/src/host/layer23/src/mobile/primitives.c @@ -20,6 +20,7 @@ #include <inttypes.h> +#include <osmocom/bb/mobile/gsm322.h> #include <osmocom/bb/mobile/primitives.h> #include <osmocom/bb/common/logging.h> @@ -191,6 +192,17 @@ static int send_sms(struct mobile_prim_intf *intf, struct mobile_sms_param *para return gsm411_tx_sms_submit(intf->ms, param->sca, sms); } +static int network_reselect(struct mobile_prim_intf *intf) +{ + struct msgb *nmsg; + + nmsg = gsm322_msgb_alloc(GSM322_EVENT_USER_RESEL); + if (!nmsg) + return -1; + gsm322_plmn_sendmsg(intf->ms, nmsg); + return 0; +} + int mobile_prim_intf_req(struct mobile_prim_intf *intf, struct mobile_prim *prim) { int rc = 0; @@ -205,6 +217,9 @@ int mobile_prim_intf_req(struct mobile_prim_intf *intf, struct mobile_prim *prim case OSMO_PRIM(PRIM_MOB_SMS, PRIM_OP_REQUEST): rc = send_sms(intf, &prim->u.sms); break; + case OSMO_PRIM(PRIM_MOB_NETWORK_RESELECT, PRIM_OP_REQUEST): + rc = network_reselect(intf); + break; default: LOGP(DPRIM, LOGL_ERROR, "Unknown primitive: %d\n", OSMO_PRIM_HDR(&prim->hdr)); break; diff --git a/src/host/layer23/src/mobile/script_lua.c b/src/host/layer23/src/mobile/script_lua.c index 924ed6ec..9117cdd4 100644 --- a/src/host/layer23/src/mobile/script_lua.c +++ b/src/host/layer23/src/mobile/script_lua.c @@ -425,6 +425,16 @@ static int lua_ms_name(lua_State *L) return 1; } +static int lua_reselect_network(lua_State *L) +{ + struct mobile_prim *prim; + + prim = mobile_prim_alloc(PRIM_MOB_NETWORK_RESELECT, PRIM_OP_REQUEST); + mobile_prim_intf_req(get_primitive(L), prim); + + return 1; +} + /* Expect a fd on the stack and enable SO_PASSCRED */ static int lua_unix_passcred(lua_State *L) { @@ -546,6 +556,7 @@ static const struct luaL_Reg ms_funcs[] = { { "stop", lua_ms_shutdown }, { "sms_send_simple", lua_ms_sms_send_simple }, { "number", lua_ms_name }, + { "reselect_network", lua_reselect_network }, { NULL, NULL }, }; |