99 lines
2.4 KiB
Smalltalk
99 lines
2.4 KiB
Smalltalk
|
Object subclass: GSM0808IE [
|
||
|
<comment: 'Base class of IEs for GSM0808'>
|
||
|
]
|
||
|
|
||
|
Object subclass: GSM0808Helper [
|
||
|
GSM0808Helper class >> msgComplL3 [ ^ 16r57 ]
|
||
|
GSM0808Helper class >> msgReset [ ^ 16r30 ]
|
||
|
GSM0808Helper class >> msgResetAck [ ^ 16r31 ]
|
||
|
GSM0808Helper class >> msgClear [ ^ 16r20 ]
|
||
|
GSM0808Helper class >> msgClearComp [ ^ 16r21 ]
|
||
|
]
|
||
|
|
||
|
Object subclass: BCD [
|
||
|
BCD class >> encode: aNumber [
|
||
|
| col num |
|
||
|
col := OrderedCollection new.
|
||
|
|
||
|
num := aNumber.
|
||
|
1 to: 3 do: [:each |
|
||
|
col add: num \\ 10.
|
||
|
num := num // 10.
|
||
|
].
|
||
|
|
||
|
^ col reverse asByteArray
|
||
|
]
|
||
|
]
|
||
|
|
||
|
Object subclass: LAI [
|
||
|
LAI class >> generateLAI: mcc mnc: mnc [
|
||
|
| mcc_bcd mnc_bcd lai_0 lai_1 lai_2 |
|
||
|
mcc_bcd := BCD encode: mcc.
|
||
|
mnc_bcd := BCD encode: mnc.
|
||
|
|
||
|
lai_0 := (mcc_bcd at: 1) bitOr: ((mcc_bcd at: 2) bitShift: 4).
|
||
|
lai_1 := mcc_bcd at: 3.
|
||
|
|
||
|
mnc > 99
|
||
|
ifTrue: [
|
||
|
lai_1 := lai_1 bitOr: ((mnc_bcd at: 3) bitShift: 4).
|
||
|
lai_2 := (mnc_bcd at: 1) bitOr: ((mnc_bcd at: 2) bitShift: 4)
|
||
|
]
|
||
|
ifFalse: [
|
||
|
lai_1 := lai_1 bitOr: (16rF bitShift: 4).
|
||
|
lai_2 := (mnc_bcd at: 2) bitOr: ((mnc_bcd at: 3) bitShift: 4)
|
||
|
].
|
||
|
|
||
|
^ ByteArray with: lai_0 with: lai_1 with: lai_2
|
||
|
]
|
||
|
]
|
||
|
|
||
|
GSM0808IE subclass: GSMCellIdentifier [
|
||
|
| mcc mnc lac ci |
|
||
|
GSMCellIdentifier class >> elementId [ ^ 5 ]
|
||
|
GSMCellIdentifier class >> initWith: mcc mnc: mnc lac: lac ci: ci [
|
||
|
^ (self new)
|
||
|
mcc: mcc mnc: mnc lac: lac ci: ci;
|
||
|
yourself
|
||
|
]
|
||
|
|
||
|
mcc: aMcc mnc: aMnc lac: aLac ci: aCi [
|
||
|
mcc := aMcc.
|
||
|
mnc := aMnc.
|
||
|
lac := aLac.
|
||
|
ci := aCi.
|
||
|
]
|
||
|
|
||
|
storeOn: aMsg [
|
||
|
| lai |
|
||
|
lai := LAI generateLAI: mcc mnc: mnc.
|
||
|
|
||
|
aMsg putByte: self class elementId.
|
||
|
aMsg putByte: 1 + lai size + 2 + 2.
|
||
|
aMsg putByte: 0.
|
||
|
aMsg putByteArray: lai.
|
||
|
aMsg putLen16: lac.
|
||
|
aMsg putLen16: ci.
|
||
|
]
|
||
|
]
|
||
|
|
||
|
GSM0808IE subclass: GSMLayer3Info [
|
||
|
| data |
|
||
|
GSMLayer3Info class >> elementId [ ^ 23 ]
|
||
|
GSMLayer3Info class >> initWith: data [
|
||
|
^ (self new)
|
||
|
data: data;
|
||
|
yourself
|
||
|
]
|
||
|
|
||
|
data: aData [
|
||
|
data := aData
|
||
|
]
|
||
|
|
||
|
storeOn: aMsg [
|
||
|
aMsg putByte: self class elementId.
|
||
|
aMsg putByte: data size.
|
||
|
aMsg putByteArray: data.
|
||
|
]
|
||
|
]
|