Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions smpplib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ def _enquire_link_received(self):
self.send_pdu(ler)
logger.debug("Link Enquiry...")

def _alert_notification(self, p):
"""Handler for alert notifiction event"""
self.message_received_handler(pdu=p)

def set_message_received_handler(self, func):
"""Set new function to handle message receive event"""
self.message_received_handler = func
Expand Down Expand Up @@ -295,6 +299,8 @@ def listen(self, ignore_error_codes=None):
self._enquire_link_received()
elif p.command == 'enquire_link_resp':
pass
elif p.command == 'alert_notification':
self._alert_notification(p)
else:
logger.warning('Unhandled SMPP command "%s"', p.command)
except exceptions.PDUError, e:
Expand Down
53 changes: 53 additions & 0 deletions smpplib/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def factory(command_name, **kwargs):
'unbind_resp': UnbindResp,
'enquire_link': EnquireLink,
'enquire_link_resp': EnquireLinkResp,
'alert_notification': AlertNotification,
}[command_name](command_name, **kwargs)
except KeyError:
raise exceptions.UnknownCommandError(
Expand Down Expand Up @@ -873,3 +874,55 @@ def __init__(self, command, **kwargs):
"""Initialize"""
super(EnquireLinkResp, self).__init__(command, need_sequence=False,
**kwargs)

class AlertNotification(Command):
"""alert_notification command class
"""


# Type of Number for source address
source_addr_ton = None

# Numbering Plan Indicator for source address
source_addr_npi = None

# Address of SME which originated this message
source_addr = None

# TON for destination
esme_addr_ton = None

# NPI for destination
esme_addr_npi = None

# Destination address for this message
esme_addr = None

# Optional are taken from params list and are set dynamically when
# __init__ is called.
params = {
'source_addr_ton': Param(type=int, size=1),
'source_addr_npi': Param(type=int, size=1),
'source_addr': Param(type=str, max=21),
'esme_addr_ton': Param(type=int, size=1),
'esme_addr_npi': Param(type=int, size=1),
'esme_addr': Param(type=str, max=21),

# Optional params
'ms_availability_status' : Param(type=int, size=1),
}

params_order = ('source_addr_ton', 'source_addr_npi',
'source_addr', 'esme_addr_ton', 'esme_addr_npi',
'esme_addr',

# Optional params
'ms_availability_status')

def __init__(self, command, **kwargs):
"""Initialize"""
super(AlertNotification, self).__init__(command, **kwargs)
self._set_vars(**(dict.fromkeys(self.params)))

def prep(self):
Copy link
Member

Choose a reason for hiding this comment

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

do you need this method?

Copy link
Member

Choose a reason for hiding this comment

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

yep, remove it, check if it works and I'll merge it

"""Prepare to generate binary data"""