Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to support alternative configuration settings #7

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion rapidsms_multimodem/views.py
Expand Up @@ -70,9 +70,20 @@ def receive_multimodem_message(request, server_slug):
from_number = message.find('ModemNumber').text

# ModemNumber is simply 1 for single-port modems and it's a string of
# 'port_numer:phone_number' for multiport modems.
# 'port_number:phone_number' for multiport modems.

# RR: This gets a little more complicated than that. If the modem is not set up correctly,
# this field will be only the index of the number. The possible values are:
# <ModemNumber>[Index]:[Configured Phone Number]</ModemNumber> -- for multi-port and configured
# <ModemNumber>[Configured Phone Number]</ModemNumber> -- for single port and configured
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this part is unfortunately not quite right. Single Port Modems only put their modemnumber in there, no phone number. The only valid ModemNumber sent by our 1-port modem is: <ModemNumber>1</ModemNumber>.

Given that, I don't think there's a good way of differentiating a properly configured single-port modem from an improperly-configured multiport modem, aside from adding a setting to the configuration (yuck...)

# <ModemNumber>[Index]</ModemNumber> -- for multi-port and not configured
# <ModemNumber> ????? </ModemNumber> -- for single port and not configured

if ':' in from_number:
modem_number, phone_number = from_number.split(':')[0:2]
elif len(from_number) == 1:
# Not properly configured
modem_number = from_number
else:
# This is a single port modem
modem_number = from_number
Expand Down