Holger Freyther has submitted this change and it was merged. ( https://gerrit.osmocom.org/10688 )
Change subject: lua: Expose API to trigger a network reselection ...................................................................... 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 --- M src/host/layer23/include/osmocom/bb/mobile/primitives.h M src/host/layer23/src/mobile/primitives.c M src/host/layer23/src/mobile/script_lua.c 3 files changed, 27 insertions(+), 0 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/host/layer23/include/osmocom/bb/mobile/primitives.h b/src/host/layer23/include/osmocom/bb/mobile/primitives.h index 034b202..f07ae24 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 @@ 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 aa46712..f562466 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 @@ 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 @@ 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 924ed6e..9117cdd 100644 --- a/src/host/layer23/src/mobile/script_lua.c +++ b/src/host/layer23/src/mobile/script_lua.c @@ -425,6 +425,16 @@ 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 @@ { "stop", lua_ms_shutdown }, { "sms_send_simple", lua_ms_sms_send_simple }, { "number", lua_ms_name }, + { "reselect_network", lua_reselect_network }, { NULL, NULL }, }; -- To view, visit https://gerrit.osmocom.org/10688 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: I096233a2ca9dd7daa358cebed0523cb8c0dbf593 Gerrit-Change-Number: 10688 Gerrit-PatchSet: 3 Gerrit-Owner: Holger Freyther <hol...@freyther.de> Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org> Gerrit-Reviewer: Holger Freyther <hol...@freyther.de> Gerrit-Reviewer: Jenkins Builder (1000002) Gerrit-CC: Vadim Yanitskiy <axilira...@gmail.com>