nguyenbahuong / smslib

Automatically exported from code.google.com/p/smslib
0 stars 0 forks source link

edit: Filter out trailing blanks in config files #511

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I am using a Huawei E220 modem. Its parameters of gateway creation curiously 
works even with other hardware manufacturer modems (I already tried LG Phone, 
ONDA and D-Link models).

Anyway, I can activate it ( .startService() ), I can receive messages ( 
.readMessages( ... ) ), but I can not send messages. When I try to send a 
message a get the following error:

java.lang.RuntimeException: java.lang.NumberFormatException: For input string: 
" "
    at org.ajwcc.pduUtils.gsm3040.PduGenerator.generatePduString(PduGenerator.java:520)
    at org.ajwcc.pduUtils.gsm3040.PduGenerator.generatePduList(PduGenerator.java:474)
    at org.smslib.OutboundMessage.getPdus(OutboundMessage.java:521)
...

I tried the following solutions:

[1] Because of stack trace, I tried to set the modem to work with PDU mode, 
since TEXT mode is the default.

gateway.setProtocol(AGateway.Protocols.PDU);

But the problem persisted.

[2] Then, I decided to explicitly set the TEXT mode.

gateway.setProtocol(AGateway.Protocols.TEXT);

But an error was reported during modem initialization ( .startService() )

May you help me with this problem?

Regards 

Fábio

Original issue reported on code.google.com by flbeze...@gmail.com on 25 Sep 2012 at 11:36

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by admin@smslib.org on 27 Sep 2012 at 9:54

GoogleCodeExporter commented 9 years ago
What message are you trying to send? It seems like some parameter is wrong or 
something... Cannot trace it completely.

Can you share the message characteristics? Recipient, text, etc.

Original comment by admin@smslib.org on 27 Sep 2012 at 9:58

GoogleCodeExporter commented 9 years ago

Original comment by admin@smslib.org on 27 Sep 2012 at 9:59

GoogleCodeExporter commented 9 years ago
Hello.

Follows the output after initializing the outbound message

OutboundMessage msg = new OutboundMessage(
                telefone, //Destino
                mensagem);
System.out.println(msg);

===============================================================================
<< OutboundMessage >>
-------------------------------------------------------------------------------
 Gateway Id: *
 Message Id: 1
 Message UUID: a86b3277-4eef-4bbd-9e18-99421cea9dba
 Encoding: 7-bit
 Date: Fri Sep 28 20:57:07 GMT-03:00 2012
 SMSC Ref No: 
 Recipient: 81222689
 Dispatch Date: null
 Message Status: UNSENT
 Failure Cause: NO_ERROR
 Validity Period (Hours): -1
 Status Report: false
 Source / Destination Ports: -1 / -1
 Flash SMS: false
 Text: TEste
 PDU data: D4E29C5E06
 Scheduled Delivery: null
===============================================================================

The same app/example works using the following modems and phone:
- D-Link DWM-156
- ONDA MSA110UP
- LG P350

Thank you for your helping.

Fábio

Original comment by flbeze...@gmail.com on 29 Sep 2012 at 12:01

GoogleCodeExporter commented 9 years ago
Hi,

Cannot reproduce this...

My E220 works fine in PDU mode.
The error you are reporting (java.lang.RuntimeException: 
java.lang.NumberFormatException: For input string: " " blah blah) is an SMSLib 
error and should appear each and every time for the same message and 
independent of which modem is in use.

The only "strange" thing I see is this recipient number: why is it so short? 
Can you test with the complete international number notation?

Original comment by admin@smslib.org on 13 Oct 2012 at 10:09

GoogleCodeExporter commented 9 years ago
Dear supporters.

I think that I've noticed the real problem. 

In the code bellow the this.groups return an empty list, so the execution of 
expandGroup(msg.getRecipient()) returns an empty list of recipients also.

public ArrayList<String> expandGroup(String groupName)
    {
        for (Group a : this.groups)
        {
            if (a.getName().equalsIgnoreCase(groupName)) { return new ArrayList<String>(a.getNumbers()); }
        }
        return new ArrayList<String>();
    }

Can you help me?

Following I am sending you the code that I am using. For my surprise, the 
SendMessage example works. Now I am also testing MODEM DWM-156 D-LINK

Best regards.

Fábio

Original comment by flbeze...@gmail.com on 4 Nov 2012 at 1:45

Attachments:

GoogleCodeExporter commented 9 years ago
Dear supporters.

First, apologize my mistake, but I ave just discovered the problem of sending 
messages. In the config file, the field modem.smscenter was set as following

modem.smscenter = +552181138200 

whose String value was "+552181138200 ", that is, with a single space character 
that was impossible to see "in a hurry". 

Sorry. But at least you have a thread that should help anyone with similar 
problem.

Best regards

Fábio

Original comment by flbeze...@gmail.com on 4 Nov 2012 at 4:20

GoogleCodeExporter commented 9 years ago
No problem! :)
Good to hear you figured this out. I'll keep this issue open in order to filter 
these options and clear out blanks.

Original comment by admin@smslib.org on 11 Nov 2012 at 5:05

GoogleCodeExporter commented 9 years ago

Original comment by admin@smslib.org on 1 Jan 2014 at 9:25

GoogleCodeExporter commented 9 years ago

Original comment by admin@smslib.org on 2 Jan 2014 at 12:35