diff options
Diffstat (limited to 'doc/examples')
-rw-r--r-- | doc/examples/mobile/default.cfg | 62 | ||||
-rw-r--r-- | doc/examples/mobile/lua_helloworld.lua | 9 | ||||
-rw-r--r-- | doc/examples/mobile/lua_ms_on_off.lua | 23 | ||||
-rw-r--r-- | doc/examples/mobile/lua_sms_on_attach.lua | 32 | ||||
-rw-r--r-- | doc/examples/mobile/lua_sms_receive.lua | 15 | ||||
-rw-r--r-- | doc/examples/mobile/lua_timer.lua | 12 | ||||
-rw-r--r-- | doc/examples/mobile/multi_ms.cfg | 112 |
7 files changed, 265 insertions, 0 deletions
diff --git a/doc/examples/mobile/default.cfg b/doc/examples/mobile/default.cfg new file mode 100644 index 00000000..cc816305 --- /dev/null +++ b/doc/examples/mobile/default.cfg @@ -0,0 +1,62 @@ +! +! OsmocomBB example configuration for mobile application +!! +! +line vty + no login +! +gps device /dev/ttyACM0 +gps baudrate default +no gps enable +! +no hide-default +! +ms 1 + layer2-socket /tmp/osmocom_l2 + sap-socket /tmp/osmocom_sap + sim reader + network-selection-mode auto + imei 000000000000000 0 + imei-fixed + no emergency-imsi + no sms-service-center + no call-waiting + no auto-answer + no force-rekey + no clip + no clir + tx-power auto + no simulated-delay + no stick + location-updating + neighbour-measurement + codec full-speed prefer + codec half-speed + no abbrev + support + sms + a5/1 + a5/2 + p-gsm + e-gsm + r-gsm + no gsm-850 + dcs + no pcs + class-900 4 + class-850 4 + class-dcs 1 + class-pcs 1 + channel-capability sdcch+tchf+tchh + full-speech-v1 + full-speech-v2 + half-speech-v1 + min-rxlev -106 + dsc-max 90 + no skip-max-per-band + test-sim + imsi 001010000000000 + ki comp128 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + no barred-access + rplmn 001 01 + no shutdown diff --git a/doc/examples/mobile/lua_helloworld.lua b/doc/examples/mobile/lua_helloworld.lua new file mode 100644 index 00000000..fd5abccc --- /dev/null +++ b/doc/examples/mobile/lua_helloworld.lua @@ -0,0 +1,9 @@ +-- See https://www.lua.org/manual/5.3/ for Lua +-- See http://ftp.osmocom.org/docs/latest/osmocombb-usermanual.pdf -- Scripting with Lua + +-- Standard print and log_* are forwarded to the Osmocom logging framework +print("Hellp from Lua"); +log_notice("Notice from lua"); +log_debug("Debug from Lua"); +log_error("Error from Lua"); +log_fatal("Fatal from Lua"); diff --git a/doc/examples/mobile/lua_ms_on_off.lua b/doc/examples/mobile/lua_ms_on_off.lua new file mode 100644 index 00000000..57e492d9 --- /dev/null +++ b/doc/examples/mobile/lua_ms_on_off.lua @@ -0,0 +1,23 @@ +-- See https://www.lua.org/manual/5.3/ for Lua +-- See http://ftp.osmocom.org/docs/latest/osmocombb-usermanual.pdf -- Scripting with Lua + + +-- Switch the MS on/off but this can only be done if the MS +-- is in the right state. This assumes that the MS is fully +-- connected and doesn't stall. + +local start = false +osmo.ms().start() +function toggle_ms_state() + timer = osmo.timeout(20, function() + if start then + print("STARTING", osmo.ms().start()) + start = false + else + print("STOPPING", osmo.ms().stop(true)) + start = true + end + toggle_ms_state() + end) +end +toggle_ms_state() diff --git a/doc/examples/mobile/lua_sms_on_attach.lua b/doc/examples/mobile/lua_sms_on_attach.lua new file mode 100644 index 00000000..8d73f2fc --- /dev/null +++ b/doc/examples/mobile/lua_sms_on_attach.lua @@ -0,0 +1,32 @@ +-- See https://www.lua.org/manual/5.3/ for Lua +-- See http://ftp.osmocom.org/docs/latest/osmocombb-usermanual.pdf -- Scripting with Lua + + +-- State change +local sent_sms = false +function mm_cb(new_state, new_substate, old_substate) + -- The system has attached and returned to idle. Send a SMS the first time + -- it happens. + if new_state == 19 and new_substate == 1 then + if not sent_sms then + sent_sms = true + osmo.ms():sms_send_simple("1234", "21321324", "fooooooo", 23) + end + end +end + +-- Called when a new SMS arrives or status for delivery +-- is updated. Check the msg_ref field. +function sms_cb(sms, cause, valid) + print("SMS data cb", sms, cause, valid) + for i, v in pairs(sms) do + print(i, v) + end +end + +-- We need to register a callback +local cbs = { + Sms=sms_cb, + Mm=mm_cb +} +osmo.ms():register(cbs) diff --git a/doc/examples/mobile/lua_sms_receive.lua b/doc/examples/mobile/lua_sms_receive.lua new file mode 100644 index 00000000..4be4e0a5 --- /dev/null +++ b/doc/examples/mobile/lua_sms_receive.lua @@ -0,0 +1,15 @@ +-- See https://www.lua.org/manual/5.3/ for Lua +-- See http://ftp.osmocom.org/docs/latest/osmocombb-usermanual.pdf -- Scripting with Lua + +function sms_cb(sms, cause, valid) + print("SMS data cb", sms, cause, valid) + for i, v in pairs(sms) do + print(i, v) + end +end + +local cbs = { + Sms=sms_cb, +} + +osmo.ms():register(cbs) diff --git a/doc/examples/mobile/lua_timer.lua b/doc/examples/mobile/lua_timer.lua new file mode 100644 index 00000000..1119af81 --- /dev/null +++ b/doc/examples/mobile/lua_timer.lua @@ -0,0 +1,12 @@ +-- See https://www.lua.org/manual/5.3/ for Lua +-- See http://ftp.osmocom.org/docs/latest/osmocombb-usermanual.pdf -- Scripting with Lua + +-- Start and stop timer with callback. Schedule a timeout and +-- resume execution then. + +-- Timeout in 10 seconds +local timer = osmo.timeout(10, function() + print("Timeout occurred"); +end) +-- We can cancel it. The callback will not be called +timer:cancel() diff --git a/doc/examples/mobile/multi_ms.cfg b/doc/examples/mobile/multi_ms.cfg new file mode 100644 index 00000000..bef2406e --- /dev/null +++ b/doc/examples/mobile/multi_ms.cfg @@ -0,0 +1,112 @@ +! +! OsmocomBB example configuration for mobile application +!! +! +line vty + no login +! +gps device /dev/ttyACM0 +gps baudrate default +no gps enable +! +no hide-default +! +ms one + layer2-socket /tmp/osmocom_l2.one + sap-socket /tmp/osmocom_sap.one + sim reader + network-selection-mode auto + imei 000000000000000 0 + imei-fixed + no emergency-imsi + no sms-service-center + no call-waiting + no auto-answer + no force-rekey + no clip + no clir + tx-power auto + no simulated-delay + no stick + location-updating + neighbour-measurement + codec full-speed prefer + codec half-speed + no abbrev + support + sms + a5/1 + a5/2 + p-gsm + e-gsm + r-gsm + no gsm-850 + dcs + no pcs + class-900 4 + class-850 4 + class-dcs 1 + class-pcs 1 + channel-capability sdcch+tchf+tchh + full-speech-v1 + full-speech-v2 + half-speech-v1 + min-rxlev -106 + dsc-max 90 + no skip-max-per-band + test-sim + imsi 001010000000001 + ki comp128 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + no barred-access + rplmn 001 01 + no shutdown +! +ms two + layer2-socket /tmp/osmocom_l2.two + sap-socket /tmp/osmocom_sap.two + sim reader + network-selection-mode auto + imei 000000000000000 0 + imei-fixed + no emergency-imsi + no sms-service-center + no call-waiting + no auto-answer + no force-rekey + no clip + no clir + tx-power auto + no simulated-delay + no stick + location-updating + neighbour-measurement + codec full-speed prefer + codec half-speed + no abbrev + support + sms + a5/1 + a5/2 + p-gsm + e-gsm + r-gsm + no gsm-850 + dcs + no pcs + class-900 4 + class-850 4 + class-dcs 1 + class-pcs 1 + channel-capability sdcch+tchf+tchh + full-speech-v1 + full-speech-v2 + half-speech-v1 + min-rxlev -106 + dsc-max 90 + no skip-max-per-band + test-sim + imsi 001010000000002 + ki comp128 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + no barred-access + rplmn 001 01 + no shutdown |