Holger Freyther has uploaded this change for review. ( 
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/gsm322.h
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
4 files changed, 32 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/88/10688/1

diff --git a/src/host/layer23/include/osmocom/bb/mobile/gsm322.h 
b/src/host/layer23/include/osmocom/bb/mobile/gsm322.h
index 66bc852..d4caac9 100644
--- a/src/host/layer23/include/osmocom/bb/mobile/gsm322.h
+++ b/src/host/layer23/include/osmocom/bb/mobile/gsm322.h
@@ -1,6 +1,11 @@
 #ifndef _GSM322_H
 #define _GSM322_H

+#include <osmocom/bb/common/sysinfo.h>
+
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/timer.h>
+
 /* 4.3.1.1 List of states for PLMN slection process (automatic mode) */
 #define GSM322_A0_NULL                 0
 #define        GSM322_A1_TRYING_RPLMN          1
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: newchange
Gerrit-Change-Id: I096233a2ca9dd7daa358cebed0523cb8c0dbf593
Gerrit-Change-Number: 10688
Gerrit-PatchSet: 1
Gerrit-Owner: Holger Freyther <[email protected]>

Reply via email to