aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2018-01-24 15:05:39 +0500
committerAbyss777 <abyss@fox5.ru>2018-01-24 15:05:39 +0500
commit4fae45e28106aede04c7524d89a45a94c281576c (patch)
treecaf287a07962b73dc0fefc580c518fa2aec95252 /src
parent00534cbfde4883dc6264aef1d7a913b89a712fb1 (diff)
downloadtrackermap-server-4fae45e28106aede04c7524d89a45a94c281576c.tar.gz
trackermap-server-4fae45e28106aede04c7524d89a45a94c281576c.tar.bz2
trackermap-server-4fae45e28106aede04c7524d89a45a94c281576c.zip
Improve incoming SMS handling
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/smpp/ClientSmppSessionHandler.java17
-rw-r--r--src/org/traccar/smpp/SmppClient.java6
2 files changed, 13 insertions, 10 deletions
diff --git a/src/org/traccar/smpp/ClientSmppSessionHandler.java b/src/org/traccar/smpp/ClientSmppSessionHandler.java
index 77f75273e..69ef9af41 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,12 @@ 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());
- } 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);
+ 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);
+
+ if (!SmppUtil.isMessageTypeAnyDeliveryReceipt(((DeliverSm) request).getEsmClass())) {
TextMessageEventHandler.handleTextMessage(sourceAddress, message);
}
}
diff --git a/src/org/traccar/smpp/SmppClient.java b/src/org/traccar/smpp/SmppClient.java
index 122bbaea1..7add1d97c 100644
--- a/src/org/traccar/smpp/SmppClient.java
+++ b/src/org/traccar/smpp/SmppClient.java
@@ -61,6 +61,7 @@ public class SmppClient {
private String sourceAddress;
private String commandSourceAddress;
private int submitTimeout;
+ private boolean requestDrl;
private String notificationsCharsetName;
private byte notificationsDataCoding;
private String commandsCharsetName;
@@ -90,6 +91,8 @@ public class SmppClient {
commandSourceAddress = Context.getConfig().getString("sms.smpp.commandSourceAddress", sourceAddress);
submitTimeout = Context.getConfig().getInteger("sms.smpp.submitTimeout", 10000);
+ requestDrl = Context.getConfig().getBoolean("sms.smpp.requestDrl");
+
notificationsCharsetName = Context.getConfig().getString("sms.smpp.notificationsCharset",
CharsetUtil.NAME_UCS_2);
notificationsDataCoding = (byte) Context.getConfig().getInteger("sms.smpp.notificationsDataCoding",
@@ -209,6 +212,9 @@ public class SmppClient {
byte[] textBytes;
textBytes = CharsetUtil.encode(message, command ? commandsCharsetName : notificationsCharsetName);
submit.setDataCoding(command ? commandsDataCoding : notificationsDataCoding);
+ if (requestDrl) {
+ submit.setRegisteredDelivery(SmppConstants.REGISTERED_DELIVERY_SMSC_RECEIPT_REQUESTED);
+ }
submit.setShortMessage(textBytes);
submit.setSourceAddress(command ? new Address(commandSourceTon, commandSourceNpi, commandSourceAddress)
: new Address(sourceTon, sourceNpi, sourceAddress));