aboutsummaryrefslogtreecommitdiffstats
path: root/OsmoCore.st
blob: dda42567676372a033fb40564594769f3340fbce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
"Copyright placeholder"

Eval [
    "Handle reloading the OsmoCore.st file for updates"
    Namespace current at: #OSMOCore ifPresent: [ :each |
        OSMOCore logNotice: 'OSMOCore is getting updated.' area: #osmocore.
        OSMOCore stopProcess
    ].
]

Object subclass: OSMOCore [
    <comment: 'I provide lowlevel access libosmocore.so.0'>
    <category: 'libosmocore'>

    Process := nil.

    OSMOCore class >> initialize [
        DLD addLibrary: 'libosmocore.so.0'.
        ObjectMemory addDependent: self.
    ]

    OSMOCore class >> poll [
        | delay |
        delay := Delay forMilliseconds: 50.

        [true] whileTrue: [
            self bsc_select_main: 1.
            delay wait.
        ].
    ]

    OSMOCore class >> startProcess [
        "I start a new polling process"

        Process := [
            self poll.
        ] fork.
    ]

    OSMOCore class >> stopProcess [
        "I will terminate the process"
        Process ifNotNil: [
            Process terminate.
            Process := nil.
        ]
    ]

    OSMOCore class >> update: aSymbol [
        "Check if the BSC Symbols are there again?"
    ]

    OSMOCore class >> bsc_select_main: poll [
        self logDebug: '#>>bsc_select_main: called' area: #osmocore
        <cCall: 'bsc_select_main' returning: #int args: #(#int) >
    ]

    OSMOCore class >> processEvents [
        self bsc_select_main: 1
    ]

    OSMOCore class >> msgb_length: aMsg [
        self logDebug: '#>>msgb_length: called' area: #osmocore
        <cCall: 'msgb_length' returning: #uInt args: #(#cObject) >
    ]

    OSMOCore class >> msgb_data: aMsg [
        self logDebug: '#>>msgb_data: called' area: #osmocore
        <cCall: 'msgb_data' returning: #cObject args: #(#cObject) >
    ]

    OSMOCore class >> msgb_free: aMsg [
        self logDebug: '#>>msgb_free: called' area: #osmocore
        <cCall: 'msgb_free' returning: #void args: #(#cObject) >
    ]

    OSMOCore class >> gsm0480_create_ussd_resp: invokeId trans: transId text: aText [
        self logDebug: '#>>gsm0480_create_ussd_resp: called' area: #osmocore
        <cCall: 'gsm0480_create_ussd_resp' returning: #cObject args: #(#int #int #string) >
    ]

    OSMOCore class >> gsm0808_prepend_dtap_header: msg linkId: aId [
        self logDebug: '#>>gsm0808_prepend_dtap_header: called' area: #osmocore
        <cCall: 'gsm0808_prepend_dtap_header' returning: #void args: #(#cObject #uInt) >
    ]
]

Eval [
    OSMOCore initialize.
]