protocol¶
-
class
naz.protocol.
DeliverSmResp
(log_id, message_id, sequence_number, smpp_command='deliver_sm_resp', version=1, hook_metadata='')[source]¶ Bases:
naz.protocol.Message
-
__init__
(log_id, message_id, sequence_number, smpp_command='deliver_sm_resp', version=1, hook_metadata='')[source]¶ - Parameters
log_id (
str
) – a unique identify of this requestsmpp_command (
str
) – any one of the SMSC commands eg deliver_sm_respversion (
int
) – This indicates the current version of the naz message protocol. This version will enable naz to be able to evolve in future; a future version of naz may ship with a different message protocol.hook_metadata (
str
) – a string that to will later on be passed to naz.Client.hook. Your application can use it for correlation.message_id (
str
) – id of this messagesequence_number (
int
) – SMPP sequence_number
- Return type
None
-
-
class
naz.protocol.
EnquireLinkResp
(log_id, sequence_number, smpp_command='enquire_link_resp', version=1, hook_metadata='')[source]¶ Bases:
naz.protocol.Message
-
__init__
(log_id, sequence_number, smpp_command='enquire_link_resp', version=1, hook_metadata='')[source]¶ - Parameters
log_id (
str
) – a unique identify of this requestsmpp_command (
str
) – any one of the SMSC commands eg enquire_link_respversion (
int
) – This indicates the current version of the naz message protocol. This version will enable naz to be able to evolve in future; a future version of naz may ship with a different message protocol.hook_metadata (
str
) – a string that to will later on be passed to naz.Client.hook. Your application can use it for correlation.sequence_number (
int
) – SMPP sequence_number
- Return type
None
-
-
class
naz.protocol.
Message
(version, smpp_command, log_id, hook_metadata='')[source]¶ Bases:
abc.ABC
The message protocol for naz. It is the code representation of what gets queued into a naz broker. This is the interface that must be implemented to satisfy naz’s message protocol.
Users should only ever have to deal with the
SubmitSM
implementation-
abstract
__init__
(version, smpp_command, log_id, hook_metadata='')[source]¶ - Parameters
version (
int
) – This indicates the current version of the naz message protocol. This version will enable naz to be able to evolve in future; a future version of naz may ship with a different message protocol.smpp_command (
str
) – any one of the SMSC commands eg submit_smlog_id (
str
) – a unique identify of this requesthook_metadata (
str
) – a string that to will later on be passed to naz.Client.hook. Your application can use it for correlation.
- Return type
None
-
abstract
-
naz.protocol.
NAZ_MESSAGE_PROTOCOL_VERSION
= 1¶ The messages that are published to a queue by either naz or user application should be versioned. This version will enable naz to be able to evolve in future; eg a future version of naz could add/remove the number of required items in a message. This is a bit similar to: http://docs.celeryproject.org/en/latest/internals/protocol.html
-
class
naz.protocol.
SubmitSM
(short_message, source_addr, destination_addr, log_id, service_type='CMT', source_addr_ton=1, source_addr_npi=1, dest_addr_ton=1, dest_addr_npi=1, esm_class=3, protocol_id=0, priority_flag=0, schedule_delivery_time='', validity_period='', registered_delivery=1, replace_if_present_flag=0, sm_default_msg_id=0, smpp_command='submit_sm', version=1, hook_metadata='', encoding='gsm0338', errors='strict', user_message_reference=None, source_port=None, source_addr_subunit=None, destination_port=None, dest_addr_subunit=None, sar_msg_ref_num=None, sar_total_segments=None, sar_segment_seqnum=None, more_messages_to_send=None, payload_type=None, message_payload=None, privacy_indicator=None, callback_num=None, callback_num_pres_ind=None, callback_num_atag=None, source_subaddress=None, dest_subaddress=None, user_response_code=None, display_time=None, sms_signal=None, ms_validity=None, ms_msg_wait_facilities=None, number_of_messages=None, alert_on_message_delivery=False, language_indicator=None, its_reply_type=None, its_session_info=None, ussd_service_op=None)[source]¶ Bases:
naz.protocol.Message
The code representation of the submit_sm pdu that will get queued into a broker.
Usage:
import os import naz broker = naz.broker.SimpleBroker(maxsize=1000) client = naz.Client( smsc_host="127.0.0.1", smsc_port=2775, system_id="smppclient1", password=os.getenv("password", "password"), broker=broker, ) msg = naz.protocol.SubmitSM( short_message="hello world", source_addr="255700111222", destination_addr="255799000888", log_id="some-id", ms_validity=1, ) await client.send_message(msg)
-
__init__
(short_message, source_addr, destination_addr, log_id, service_type='CMT', source_addr_ton=1, source_addr_npi=1, dest_addr_ton=1, dest_addr_npi=1, esm_class=3, protocol_id=0, priority_flag=0, schedule_delivery_time='', validity_period='', registered_delivery=1, replace_if_present_flag=0, sm_default_msg_id=0, smpp_command='submit_sm', version=1, hook_metadata='', encoding='gsm0338', errors='strict', user_message_reference=None, source_port=None, source_addr_subunit=None, destination_port=None, dest_addr_subunit=None, sar_msg_ref_num=None, sar_total_segments=None, sar_segment_seqnum=None, more_messages_to_send=None, payload_type=None, message_payload=None, privacy_indicator=None, callback_num=None, callback_num_pres_ind=None, callback_num_atag=None, source_subaddress=None, dest_subaddress=None, user_response_code=None, display_time=None, sms_signal=None, ms_validity=None, ms_msg_wait_facilities=None, number_of_messages=None, alert_on_message_delivery=False, language_indicator=None, its_reply_type=None, its_session_info=None, ussd_service_op=None)[source]¶ - Parameters
short_message (
str
) – message to send to SMSCsource_addr (
str
) – the identifier(eg msisdn) of the message senderdestination_addr (
str
) – the identifier(eg msisdn) of the message recipientlog_id (
str
) – a unique identify of this requestversion (
int
) – This indicates the current version of the naz message protocol. This version will enable naz to be able to evolve in future; a future version of naz may ship with a different message protocol.hook_metadata (
str
) – a string that to will later on be passed to naz.Client.hook. Your application can use it for correlation.service_type (
str
) – Indicates the SMS Application service associated with the messagesource_addr_ton (
int
) – Type of Number of message originator.source_addr_npi (
int
) – Numbering Plan Identity of message originator.dest_addr_ton (
int
) – Type of Number for destination.dest_addr_npi (
int
) – Numbering Plan Identity of destinationesm_class (
int
) – Indicates Message Mode & Message Type.protocol_id (
int
) – Protocol Identifier. Network specific field.priority_flag (
int
) – Designates the priority level of the message.schedule_delivery_time (
str
) – The short message is to be scheduled by the SMSC for delivery.validity_period (
str
) – The validity period of this message.registered_delivery (
int
) – Indicator to signify if an SMSC delivery receipt or an SME acknowledgement is required.replace_if_present_flag (
int
) – Flag indicating if submitted message should replace an existing message.sm_default_msg_id (
int
) – Indicates the short message to send from a list of predefined (‘canned’) short messages stored on the SMSCsmpp_command (
str
) – any one of the SMSC commands eg submit_smencoding (
str
) – encoding used to encode messages been sent to SMSC. The encoding should be one of the encodings recognised by the SMPP specification. See section 5.2.19 of SMPP spec. If you want to use your own custom codec implementation for an encoding, make sure to pass it tonaz.Client.custom_codecs
errors (
str
) – same meaning as the errors argument to pythons’ encode methodOptional SMPP parameters. (#) –
user_message_reference (
Union
[None
,int
]) – ESME assigned message reference number.source_port (
Union
[None
,int
]) – It is used to indicate the application port number associated with the source address of the messagesource_addr_subunit (
Union
[None
,int
]) – It is used to indicate where a message originated in the mobile station, for example a smart card in the mobile station or an external device connected to the mobile station.destination_port (
Union
[None
,int
]) – It is used to indicate the application port number associated with the destination address of the message.dest_addr_subunit (
Union
[None
,int
]) – It is used to route messages when received by a mobile station, for example to a smart card in the mobile station or to an external device connected to the mobile station.sar_msg_ref_num (
Union
[None
,int
]) – It is used to indicate the reference number for a particular concatenated short message.sar_total_segments (
Union
[None
,int
]) – It is used to indicate the total number of short messages within the concatenated short message.sar_segment_seqnum (
Union
[None
,int
]) – It is used to indicate the sequence number of a particular short message within the concatenated short message.more_messages_to_send (
Union
[None
,int
]) – It is used by the ESME in the submit_sm and data_sm operations to indicate to the SMSC that there are further messages for the same destination SME.payload_type (
Union
[None
,int
]) – It defines the higher layer PDU type contained in the message payload.message_payload (
Union
[None
,str
]) – It contains the user data.privacy_indicator (
Union
[None
,int
]) – It indicates the privacy level of the message.callback_num (
Union
[None
,str
]) – It associates a call back number with the message.callback_num_pres_ind (
Union
[None
,int
]) – It controls the presentation indication and screening of the callback number at the mobile station. If present, thecallback_num
parameter must also be present.callback_num_atag (
Union
[None
,str
]) – It associates an alphanumeric display with the call back numbersource_subaddress (
Union
[None
,str
]) – It specifies a subaddress associated with the originator of the message.dest_subaddress (
Union
[None
,str
]) – It specifies a subaddress associated with the destination of the message.user_response_code (
Union
[None
,int
]) – It is a response code set by the user in a User Acknowledgement/Reply message.display_time (
Union
[None
,int
]) – It is used to associate a display time of the short message on the MS.sms_signal (
Union
[None
,int
]) – It is used to provide a TDMA MS with alert tone information associated with the received short message.ms_validity (
Union
[None
,int
]) – It is used to provide an MS with validity information associated with the received short message.ms_msg_wait_facilities (
Union
[None
,int
]) – It allows an indication to be provided to an MS that there are messages waiting for the subscriber on systems on the PLMN.number_of_messages (
Union
[None
,int
]) – It is used to indicate the number of messages stored in a mailbox.alert_on_message_delivery (
bool
) – It is set to instruct a MS to alert the user (in a MS implementation specific manner) when the short message arrives at the MS.language_indicator (
Union
[None
,int
]) – It is used to indicate the language of the short message.its_reply_type (
Union
[None
,int
]) – It indicates and controls the MS user’s reply method to an SMS delivery message received from the ESME. It is a required parameter for the CDMA Interactive Teleservice as defined by the Korean PCS carriers [KORITS].its_session_info (
Union
[None
,str
]) – It contains control information for the interactive session between an MS and an ESME. It is a required parameter for the CDMA Interactive Teleservice as defined by the Korean PCS carriers [KORITS].ussd_service_op (
Union
[None
,str
]) – It is required to define the USSD service operation when SMPP is being used as an interface to a (GSM) USSD system.
- Return type
None
-
-
naz.protocol.
json_to_Message
(json_message)[source]¶ Utility function to deserialize the message protocol from json. You can use this method if you would like to return the Message from a broker like redis/rabbitmq/postgres etc.
- Parameters
json_message (
str
) – naz.protocol.Message in json format.- Return type