aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/smpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/smpp')
-rw-r--r--src/org/traccar/smpp/ClientSmppSessionHandler.java22
-rw-r--r--src/org/traccar/smpp/SmppClient.java26
2 files changed, 36 insertions, 12 deletions
diff --git a/src/org/traccar/smpp/ClientSmppSessionHandler.java b/src/org/traccar/smpp/ClientSmppSessionHandler.java
index 77f75273e..3585f8376 100644
--- a/src/org/traccar/smpp/ClientSmppSessionHandler.java
+++ b/src/org/traccar/smpp/ClientSmppSessionHandler.java
@@ -25,6 +25,7 @@ import com.cloudhopper.smpp.impl.DefaultSmppSessionHandler;
import com.cloudhopper.smpp.pdu.DeliverSm;
import com.cloudhopper.smpp.pdu.PduRequest;
import com.cloudhopper.smpp.pdu.PduResponse;
+import com.cloudhopper.smpp.util.SmppUtil;
public class ClientSmppSessionHandler extends DefaultSmppSessionHandler {
@@ -44,16 +45,19 @@ public class ClientSmppSessionHandler extends DefaultSmppSessionHandler {
PduResponse response = null;
try {
if (request instanceof DeliverSm) {
- if (request.getOptionalParameters() != null) {
- Log.debug("SMS Message Delivered: "
- + request.getOptionalParameter(SmppConstants.TAG_RECEIPTED_MSG_ID).getValueAsString()
- + ", State: "
- + request.getOptionalParameter(SmppConstants.TAG_MSG_STATE).getValueAsByte());
+ String sourceAddress = ((DeliverSm) request).getSourceAddress().getAddress();
+ String message = CharsetUtil.decode(((DeliverSm) request).getShortMessage(),
+ smppClient.mapDataCodingToCharset(((DeliverSm) request).getDataCoding()));
+ Log.debug("SMS Message Received: " + message.trim() + ", Source Address: " + sourceAddress);
+
+ boolean isDeliveryReceipt = false;
+ if (smppClient.getDetectDlrByOpts()) {
+ isDeliveryReceipt = request.getOptionalParameters() != null;
} else {
- String sourceAddress = ((DeliverSm) request).getSourceAddress().getAddress();
- String message = CharsetUtil.decode(((DeliverSm) request).getShortMessage(),
- smppClient.mapDataCodingToCharset(((DeliverSm) request).getDataCoding()));
- Log.debug("SMS Message Received: " + message.trim() + ", Source Address: " + sourceAddress);
+ isDeliveryReceipt = SmppUtil.isMessageTypeAnyDeliveryReceipt(((DeliverSm) request).getEsmClass());
+ }
+
+ if (!isDeliveryReceipt) {
TextMessageEventHandler.handleTextMessage(sourceAddress, message);
}
}
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));