From 854d244d695d63f13716c091ac52d015220a0f57 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 20 Jun 2014 18:34:45 +0200 Subject: [PATCH 1/6] gsm: Be able to parse a GSM CC Progress message --- GSM48.st | 17 +++++++++++++++++ Tests.st | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/GSM48.st b/GSM48.st index feafb45..b0163dc 100644 --- a/GSM48.st +++ b/GSM48.st @@ -2847,6 +2847,22 @@ GSM48CCMessage subclass: GSM48CCEmergencySetup [ ] ] +GSM48CCMessage subclass: GSM48CCProgress [ + + + GSM48CCProgress class >> messageType [ ^self msgProgress ] + GSM48CCProgress class >> tlvDescription [ + + ^OrderedCollection new + add: GSMProgress asTLVDescription; + add: (GSMUserUser asTLVDescription + beOptional; + minSize: 1 maxSize: 129; + yourself); + yourself + ] +] + GSM48RRMessage subclass: GSM48RRAssignmentComplete [ @@ -3177,6 +3193,7 @@ Eval [ GSM48CCReleaseCompl initialize. GSM48CCStatus initialize. GSM48CCEmergencySetup initialize. + GSM48CCProgress initialize. GSM48RRAssignmentComplete initialize. GSM48RRHandoverCommand initialize. diff --git a/Tests.st b/Tests.st index 56e67ec..550f9e2 100644 --- a/Tests.st +++ b/Tests.st @@ -463,6 +463,14 @@ TestCase subclass: GSM48Test [ dec := GSM48MSG decode: inp readStream. self assert: dec toMessage asByteArray = inp. ] + + testCCProgress [ + | dec inp | + + inp := #[16r83 16r03 16r02 16rEA 16r81]. + dec := GSM48MSG decode: inp readStream. + self assert: dec toMessage asByteArray = inp. + ] ] SCCPHandler subclass: TestSCCPHandler [ From 18c4ddfd7bb95b403eaf953ebdf3b2100bcae9d4 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 24 Jul 2014 15:42:51 +0200 Subject: [PATCH 2/6] misc: Ease porting and use "self basicNew initialize" for init self basicNew initialize will work on Pharo and various versions of GST and will make sure to call initialize exactly once. --- SCCPHandler.st | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SCCPHandler.st b/SCCPHandler.st index 0d1613f..e96c30d 100644 --- a/SCCPHandler.st +++ b/SCCPHandler.st @@ -39,7 +39,7 @@ Object subclass: SCCPConnectionState [ SCCPConnectionState class >> on: aHandler [ - ^ super new + ^(self basicNew) initialize; conManager: aHandler; yourself @@ -463,7 +463,7 @@ deadlocks should not occur.'> SCCPHandler class >> new [ - ^ super new initialize; yourself + ^self basicNew initialize ] initialize [ From 77d1ac2eabfb594af4e84acef58c8632870c3190 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 29 Jul 2014 17:04:06 +0200 Subject: [PATCH 3/6] misc: Ease porting to pharo In Pharo ByteArray does not inherit from Array but directly from the ArrayedCollection class. Move the extensions one level up. --- GSMEncoding.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GSMEncoding.st b/GSMEncoding.st index 33da4fa..2bcac10 100644 --- a/GSMEncoding.st +++ b/GSMEncoding.st @@ -16,7 +16,7 @@ along with this program. If not, see . " -Array extend [ +ArrayedCollection extend [ decodeGSM7Bit [ ^ (OsmoGSM at: #GSMDecoding) decode: self. From 9bd9a9e3b6826f99ec330ec0086321a599e470f6 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 29 Jul 2014 17:13:27 +0200 Subject: [PATCH 4/6] Add a routine to just expand from 7bit packing to unpacked Modernize the tests. Use #[] if we want a ByteArray and use >>#asert:equals: to see what is going on. --- GSMEncoding.st | 4 ++++ Tests.st | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/GSMEncoding.st b/GSMEncoding.st index 2bcac10..34f2fac 100644 --- a/GSMEncoding.st +++ b/GSMEncoding.st @@ -69,6 +69,10 @@ can be subclassed to deal with specifics for USSD and other systems.'> ^ self handleBytes: bytes from: bits ] + GSMDecoding class >> expand: aByteArray [ + ^self convertToBytes: (self convertFromBytes: aByteArray) + ] + GSMDecoding class >> handleBytes: bytes from: bits [ ^ bytes asString ] diff --git a/Tests.st b/Tests.st index 550f9e2..a14d867 100644 --- a/Tests.st +++ b/Tests.st @@ -858,9 +858,16 @@ TestCase subclass: GSMEncodingTest [ | wanted res | wanted := 'Your remaining balance is:1704 min,expiring on:10-07-2010'. - res := #(16rD9 16r77 16r5D 16r0E 16r92 16r97 16rDB 16rE1 16rB4 16r3B 16rED 16r3E 16r83 16rC4 16r61 16r76 16rD8 16r3D 16r2E 16r83 16rD2 16r73 16r5D 16rEC 16r06 16rA3 16r81 16rDA 16r69 16r37 16rAB 16r8C 16r87 16rA7 16rE5 16r69 16rF7 16r19 16rF4 16r76 16rEB 16r62 16rB0 16r16 16rEC 16rD6 16r92 16rC1 16r62 16r30) asByteArray decodeGSM7Bit. + res := #[16rD9 16r77 16r5D 16r0E 16r92 16r97 16rDB 16rE1 16rB4 16r3B 16rED 16r3E 16r83 16rC4 16r61 16r76 16rD8 16r3D 16r2E 16r83 16rD2 16r73 16r5D 16rEC 16r06 16rA3 16r81 16rDA 16r69 16r37 16rAB 16r8C 16r87 16rA7 16rE5 16r69 16rF7 16r19 16rF4 16r76 16rEB 16r62 16rB0 16r16 16rEC 16rD6 16r92 16rC1 16r62 16r30] decodeGSM7Bit. - self assert: res = wanted. + self assert: res equals: wanted. + ] + + testExpand [ + | wanted res | + wanted := 'Your remaining balance is:1704 min,expiring on:10-07-2010' asByteArray. + res := GSMDecoding expand: #[217 119 93 14 146 151 219 225 180 59 237 62 131 196 97 118 216 61 46 131 210 115 93 236 6 163 129 218 105 55 171 140 135 167 229 105 247 25 244 118 235 98 176 22 236 214 146 193 98 48]. + self assert: res equals: wanted ] testUSSDEncode [ From fb5ddd43bb1383e5e2d7f9c4f38df422fa98e647 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 20 Aug 2014 23:14:42 +0200 Subject: [PATCH 5/6] gsm: Use "self error:" instead of Exception signal The issue is that [] on: Error do: [] will not handle the Exception. Use the plain self error handling. --- GSM48.st | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GSM48.st b/GSM48.st index b0163dc..18b5f34 100644 --- a/GSM48.st +++ b/GSM48.st @@ -2093,8 +2093,8 @@ Osmo.TLVParserBase subclass: GSM48MSG [ ]. ]. - Exception signal: 'No one handles: ', classType asString, - ' and: ', messageType asString. + ^self error: 'No one handles: ', classType asString, + ' and: ', messageType asString. ] GSM48MSG class >> parseFrom: aStream [ From ab3b8e23fdf2cf40847bdcc854e14207908d1391 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 20 Aug 2014 23:21:29 +0200 Subject: [PATCH 6/6] messages: Use self error: here as well --- Messages.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Messages.st b/Messages.st index 82d4bfc..b5be3ce 100644 --- a/Messages.st +++ b/Messages.st @@ -65,7 +65,7 @@ Object subclass: IEMessage [ ]. ]. - ^ Exception signal: 'Unsupported IE type: ', type asString. + ^self error: 'Unsupported IE type: ', type asString. ] IEMessage class >> decode: aStream with: aIEBase [