diff options
author | Christoph Krey <c@ckrey.de> | 2018-04-16 10:45:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-16 10:45:11 +0200 |
commit | 3a602dd133b533cc69d5986d64a00fb3ed670f75 (patch) | |
tree | 97ff753db310a49ae7e53240b1db07fb8475679e /src/org/traccar/smpp/SmppClient.java | |
parent | 232de5f0daef98f31b28d177d991fdbfa191f195 (diff) | |
parent | 6d4b8df25c7e942b9ad594db9444fe15bcb16be9 (diff) | |
download | trackermap-server-3a602dd133b533cc69d5986d64a00fb3ed670f75.tar.gz trackermap-server-3a602dd133b533cc69d5986d64a00fb3ed670f75.tar.bz2 trackermap-server-3a602dd133b533cc69d5986d64a00fb3ed670f75.zip |
Merge pull request #4 from traccar/master
upgrade to current master
Diffstat (limited to 'src/org/traccar/smpp/SmppClient.java')
-rw-r--r-- | src/org/traccar/smpp/SmppClient.java | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/org/traccar/smpp/SmppClient.java b/src/org/traccar/smpp/SmppClient.java index 122bbaea1..bf395f90e 100644 --- a/src/org/traccar/smpp/SmppClient.java +++ b/src/org/traccar/smpp/SmppClient.java @@ -1,6 +1,6 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) + * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2018 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import com.cloudhopper.smpp.impl.DefaultSmppClient; import com.cloudhopper.smpp.impl.DefaultSmppSessionHandler; import com.cloudhopper.smpp.pdu.SubmitSm; import com.cloudhopper.smpp.pdu.SubmitSmResp; +import com.cloudhopper.smpp.tlv.Tlv; import com.cloudhopper.smpp.type.Address; import com.cloudhopper.smpp.type.RecoverablePduException; import com.cloudhopper.smpp.type.SmppChannelException; @@ -61,6 +62,8 @@ public class SmppClient { private String sourceAddress; private String commandSourceAddress; private int submitTimeout; + private boolean requestDlr; + private boolean detectDlrByOpts; private String notificationsCharsetName; private byte notificationsDataCoding; private String commandsCharsetName; @@ -82,6 +85,7 @@ public class SmppClient { sessionConfig.setHost(Context.getConfig().getString("sms.smpp.host", "localhost")); sessionConfig.setPort(Context.getConfig().getInteger("sms.smpp.port", 2775)); sessionConfig.setSystemId(Context.getConfig().getString("sms.smpp.username", "user")); + sessionConfig.setSystemType(Context.getConfig().getString("sms.smpp.systemType", null)); sessionConfig.setPassword(Context.getConfig().getString("sms.smpp.password", "password")); sessionConfig.getLoggingOptions().setLogBytes(false); sessionConfig.getLoggingOptions().setLogPdu(Context.getConfig().getBoolean("sms.smpp.logPdu")); @@ -90,6 +94,9 @@ public class SmppClient { commandSourceAddress = Context.getConfig().getString("sms.smpp.commandSourceAddress", sourceAddress); submitTimeout = Context.getConfig().getInteger("sms.smpp.submitTimeout", 10000); + requestDlr = Context.getConfig().getBoolean("sms.smpp.requestDlr"); + detectDlrByOpts = Context.getConfig().getBoolean("sms.smpp.detectDlrByOpts"); + notificationsCharsetName = Context.getConfig().getString("sms.smpp.notificationsCharset", CharsetUtil.NAME_UCS_2); notificationsDataCoding = (byte) Context.getConfig().getInteger("sms.smpp.notificationsDataCoding", @@ -149,6 +156,10 @@ public class SmppClient { } } + public boolean getDetectDlrByOpts() { + return detectDlrByOpts; + } + protected synchronized void reconnect() { try { disconnect(); @@ -209,7 +220,16 @@ public class SmppClient { byte[] textBytes; textBytes = CharsetUtil.encode(message, command ? commandsCharsetName : notificationsCharsetName); submit.setDataCoding(command ? commandsDataCoding : notificationsDataCoding); - submit.setShortMessage(textBytes); + if (requestDlr) { + submit.setRegisteredDelivery(SmppConstants.REGISTERED_DELIVERY_SMSC_RECEIPT_REQUESTED); + } + + if (textBytes != null && textBytes.length > 255) { + submit.addOptionalParameter(new Tlv(SmppConstants.TAG_MESSAGE_PAYLOAD, textBytes, "message_payload")); + } else { + submit.setShortMessage(textBytes); + } + submit.setSourceAddress(command ? new Address(commandSourceTon, commandSourceNpi, commandSourceAddress) : new Address(sourceTon, sourceNpi, sourceAddress)); submit.setDestAddress(new Address(destTon, destNpi, destAddress)); |