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

Messages: Introduce a ChosenChannel IE, the first TV

Make GSM0808IE>>#length: return the length of the payload
including the length field if it is present. This is done
to be able to support a Tag only IE in the future.
This commit is contained in:
Holger Hans Peter Freyther 2010-11-27 14:05:28 +01:00
parent a57c26261c
commit 892d4d19ab
2 changed files with 29 additions and 3 deletions

View File

@ -3,7 +3,7 @@ IEBase subclass: GSM0808IE [
<comment: 'Base class of IEs for GSM0808'>
GSM0808IE class >> length: aByteArray [
^ (aByteArray at: 2).
^ (aByteArray at: 2) + 1.
]
]
@ -241,3 +241,29 @@ GSM0808IE subclass: GSMCauseIE [
aMsg putByte: cause.
]
]
GSM0808IE subclass: GSM0808ChosenChannel [
| channel |
GSM0808ChosenChannel class >> elementId [ ^ 33 ]
GSM0808ChosenChannel class >> initWith: aChannel [
^ self new
channel: aChannel;
yourself
]
GSM0808ChosenChannel class >> length: aByteArray [
^ 1
]
GSM0808ChosenChannel class >> parseFrom: aByteArray [
^ self initWith: (aByteArray at: 2).
]
channel [ ^ channel ]
channel: aChannel [ channel := aChannel ]
writeOnDirect: aMsg [
aMsg putByte: channel
]
]

View File

@ -41,9 +41,9 @@ Object subclass: IEMessage [
ifTrue: [
| enc size |
size := each length: data.
enc := data copyFrom: 1 to: 2 + size.
enc := data copyFrom: 1 to: 1 + size.
aMsg addIe: (each parseFrom: enc).
^ 2 + size
^ 1 + size
].
].