diff options
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)); |