From e2372f67e89a863b69343dc2097eac949397bb2a Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sun, 9 Feb 2014 22:05:15 +0100 Subject: [PATCH] sms: Fix the round-trip test for RP handling. Fix the round-trip handling. This is still missing for message types in other directions as this would require me writing test cases first. I will get to that. --- GSM411.st | 38 +++++++++++++++++++++++++++++++++++++- SMSTests.st | 5 ++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/GSM411.st b/GSM411.st index 7bccadc..2ecc6f1 100644 --- a/GSM411.st +++ b/GSM411.st @@ -195,7 +195,6 @@ Object subclass: GSMRpInformationElement [ len printNl. ^self new readFrom: (aStream next: len); - inspect; yourself. ] ] @@ -212,6 +211,12 @@ GSMRpInformationElement subclass: GSMRpOrigantorAddress [ readFrom: anArray [ data := anArray ] + + writeOn: aMessage with: anAttribute [ + aMessage + putByte: data size; + putByteArray: data + ] ] GSMRpInformationElement subclass: GSMRpDestinationAddress [ @@ -226,6 +231,12 @@ GSMRpInformationElement subclass: GSMRpDestinationAddress [ readFrom: anArray [ data := anArray ] + + writeOn: aMessage with: anAttribute [ + aMessage + putByte: data size; + putByteArray: data + ] ] GSMRpInformationElement subclass: GSMRpUserData [ @@ -240,6 +251,12 @@ GSMRpInformationElement subclass: GSMRpUserData [ readFrom: anArray [ data := anArray ] + + writeOn: aMessage with: anAttribute [ + aMessage + putByte: data size; + putByteArray: data + ] ] Osmo.TLVParserBase subclass: GSMRpMessage [ @@ -274,6 +291,13 @@ Osmo.TLVParserBase subclass: GSMRpMessage [ [self parseOptional: attr tag: aStream peek stream: aStream]. ]. ] + + writeHeaderOn: aMessage [ + direction = #msn + ifTrue: [aMessage putByte: self class messageTypeToNetwork] + ifFalse: [aMessage putByte: self class messageTypeToMS]. + aMessage putByte: reference. + ] ] GSMRpMessage subclass: GSMRpData [ @@ -281,6 +305,14 @@ GSMRpMessage subclass: GSMRpData [ + GSMRpData class >> messageTypeToNetwork [ + ^2r000 + ] + + GSMRpData class >> messageTypeToMS [ + ^2r001 + ] + GSMRpData class >> tlvDescription [ ^OrderedCollection new add: GSMRpOrigantorAddress asTLVDescription; @@ -309,6 +341,10 @@ GSMRpMessage subclass: GSMRpAck [ add: GSMRpUserData asTLVDescription beOptional yourself; yourself. ] + + GSMRpAck class >> messageTypeToNetwork [ + ^2r010 + ] ] diff --git a/SMSTests.st b/SMSTests.st index 47e33c8..0ba290d 100644 --- a/SMSTests.st +++ b/SMSTests.st @@ -35,7 +35,7 @@ TestCase subclass: GSM411Test [ assert: dec toMessage asByteArray = inp. self - assert: dec rpMessage toMessage asByteArray = dec userData data. + assert: dec rpMessage toMessage asByteArray equals: dec userData data. ] testCPData2 [ @@ -46,5 +46,8 @@ TestCase subclass: GSM411Test [ self assert: dec type = GSMCpData messageType; assert: dec toMessage asByteArray = inp. + + self + assert: dec rpMessage toMessage asByteArray equals: dec userData data. ] ]