smalltalk
/
osmo-st-gsm
Archived
1
0
Fork 0

streams: IEMessage is now working on streams all the way.

This commit is contained in:
Holger Hans Peter Freyther 2012-03-25 18:35:42 +02:00
parent 73f8b9a05c
commit 7b43f3eed2
3 changed files with 9 additions and 12 deletions

View File

@ -68,15 +68,12 @@ Object subclass: IEMessage [
^ Exception signal: 'Unsupported IE type: ', type asString.
]
IEMessage class >> decode: aByteArray with: aIEBase [
| msg dat |
msg := IEMessage initWith: (aByteArray at: 1).
IEMessage class >> decode: aStream with: aIEBase [
| msg |
msg := IEMessage initWith: aStream next.
dat := aByteArray copyFrom: 2.
[dat isEmpty not] whileTrue: [
| consumed |
consumed := self findIE: dat readStream from: aIEBase on: msg.
dat := dat copyFrom: consumed + 1.
[aStream atEnd] whileFalse: [
self findIE: aStream from: aIEBase on: msg.
].
^ msg

View File

@ -348,15 +348,15 @@ Object subclass: MSGParser [
bssap data: (GSM48MSG decode: bssap data)
]
ifFalse: [
bssap data: (self decodeBSSMAP: bssap data).
bssap data: (self decodeBSSMAP: bssap data readStream).
].
^ bssap
]
MSGParser class >> decodeBSSMAP: aData [
MSGParser class >> decodeBSSMAP: aStream [
| bssmap |
bssmap := IEMessage decode: aData with: GSM0808IE.
bssmap := IEMessage decode: aStream with: GSM0808IE.
bssmap findIE: (GSMLayer3Info elementId) ifPresent: [:each |
each data: (GSM48MSG decode: each data).
].

View File

@ -91,7 +91,7 @@ TestCase subclass: GSM0808Test [
inp := #(16r57 16r05 16r08 16r00 16r72 16rF4 16r80 16r20 16r12
16r75 16r30 16r17 16r03 16r01 16r02 16r03) asByteArray.
res := IEMessage decode: inp with: GSM0808IE.
res := IEMessage decode: inp readStream with: GSM0808IE.
self assert: res type = GSM0808Helper msgComplL3.
self assert: res ies size = 2.
]