Skip to content

Commit

Permalink
Change to using modulus instead of bitmask for rollover
Browse files Browse the repository at this point in the history
  • Loading branch information
rudigiesler committed May 11, 2017
1 parent e34b3b7 commit c6b9a87
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions vumi/transports/smpp/processors/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,9 @@ class SubmitShortMessageProcessorConfig(Config):
"of smaller messages with the user data headers. Default is `False`.",
default=False, static=True)
multipart_sar_reference_rollover = ConfigInt(
"The maximum value to set for the reference number of a multi part "
"SMS. When this value is reached, the number will rollover to 0.",
default=0xFFFF, static=True)
"The value at which the reference number of a multi part SMS will "
"roll over. eg. a value of 2 will result in a series 0, 1, 0, 1 ...",
default=0x10000, static=True)

def post_validate(self):
long_message_params = (
Expand Down
8 changes: 4 additions & 4 deletions vumi/transports/smpp/smpp_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ def csm_split_message(self, message):

@inlineCallbacks
def submit_csm_sar(
self, vumi_message_id, destination_addr, reference_rollover=0xFFFF,
**pdu_params):
self, vumi_message_id, destination_addr,
reference_rollover=0x10000, **pdu_params):
"""
Submit a concatenated SMS to the SMSC using the optional
SAR parameter names in the various PDUS.
Expand All @@ -340,8 +340,8 @@ def submit_csm_sar(
for i, msg in enumerate(split_msg):
pdu_params = pdu_params.copy()
optional_parameters.update({
# Reference number must be between 00 & FFFF
'sar_msg_ref_num': (ref_num & reference_rollover),
# Reference number must be between 00 & the configure value
'sar_msg_ref_num': (ref_num % reference_rollover),
'sar_total_segments': len(split_msg),
'sar_segment_seqnum': i + 1,
})
Expand Down
2 changes: 1 addition & 1 deletion vumi/transports/smpp/tests/test_smpp_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def test_submit_csm_sar_ref_num_custom_limit(self):
long_message = 'This is a long message.' * 20
seq_nums = yield service.submit_csm_sar(
'abc123', 'dest_addr', short_message=long_message,
reference_rollover=0xFF)
reference_rollover=0x100)
pdus = yield self.fake_smsc.await_pdus(4)
msg_parts = []
msg_refs = []
Expand Down

0 comments on commit c6b9a87

Please sign in to comment.