ecimd2 connects erlang applications to Nokia SMSCs via the CIMD2 protocol.
- login
- submit
- deliver_message
- deliver_status_report
- alive
Other commands will be supported in the future versions.
Required: OTP 18 and later
ecimd2 can be added as a dependency via hex.pm
{deps, [
{ecimd2, "0.0.8"}
]}.
Then include ecimd2 in your application's .app.src
file
{applications, [
kernel,
stdlib,
ecimd2
]}.
Calling ecimd2:start_link/1
will start a connection to the SMSC. The following options are available inside a map as a parameter:
name
- If provided, the internalgen_server
will be registered with this name. seegen_server:start_link/4
callback_mo
- Module and function tuple to be executed when a mobile originating message has been receivedcallback_dr
- Module and function tuple to be executed when a delivery receipt has been receivedhost
- Hostname or IP address of the Nokia MCport
- Port of the Nokia MCusername
- Username of the account to loginpassword
- Password used to authenticate with the username
{ok, C} = ecimd2:start_link(#{
host => "127.0.0.1",
port => 16001,
username => "cimd2client",
password => "password",
callback_dr => {mymodule, myfunction}
}).
SMS messages are sent by calling ecimd2:send_sms/6
. The function parameters are as follows:
Connection
- Process identifier of theecimd2
gen_server
returned byecimd2:start_link/1
AccessCode
- Access code assigned to the remote SMSC. This will serve as the originating address if there's noSender
definedSender
- Number or alphanumeric mask to be set as the sender of the messageDestination
- MSISDN that will be receiving the messageMessage
- UTF-8 encoded messageOptions
- An optional map with the following keys:cancellable
- Determines if the message can be cancelled or nottariff_class
- Tariff code to be used for the message. This is usually MC specificservice_desc
- Service description to be used for the message. This is usually MC specificstatus_report
- Flag of the cases when the status report should be returned0
- No status reports1
- Temporary error2
- Validity period expired4
- Delivery failed8
- Delivery successful16
- Message cancelled32
- Message deleted by operator64
- First temporary result
priority
- Priorty of the message (0-9). Lower value means higher priority
Ids = ecimd2:send_sms(C, <<"12345">>, <<"TestSender">>, <<"+639473371390">>, <<"Hello">>).
The send_sms
function will return a list of message id tuples:
[{message_id, MessageId}]
MessageId
is a (binary) string that was associated to the submitted message in the SMSC. Since CIMD2 lacks a message identifier in it's protocol, the MessageId
returned in the function is a combination of timestamp and destination address from the submit
operation response parameters.
Messages that are outside the standard GSM 03.38 character set are automatically detected and encoded with UTF-16. This includes emojis.
Long messages are automatically concatenated when they exceed the standard 140 byte limit.