No, im  not using encrypted messages.
Here is a complete class :

import java.util.ArrayList;
import java.util.List;
import org.smslib.ICallNotification;
import org.smslib.IGatewayStatusNotification;
import org.smslib.IInboundMessageNotification;
import org.smslib.InboundMessage;
import org.smslib.Library;
import org.smslib.Service;
import org.smslib.AGateway.GatewayStatuses;
import org.smslib.AGateway.Protocols;
import org.smslib.InboundMessage.MessageClasses;
import org.smslib.Message.MessageTypes;
import org.smslib.modem.IPModemGateway;
import org.smslib.modem.ModemGateway.IPProtocols;

public class ReadMessages
{
        Service srv;

        public void doIt() throws Exception
        {
                // Define a list which will hold the read messages.
                List<InboundMessage> msgList;

                // Create the notification callback method for inbound & status
report
                // messages.
                InboundNotification inboundNotification = new 
InboundNotification();

                // Create the notification callback method for inbound voice 
calls.
                CallNotification callNotification = new CallNotification();

                //Create the notification callback method for gateway statuses.
                GatewayStatusNotification statusNotification = new
GatewayStatusNotification();

                try
                {
                        System.out.println("Example: Read messages from a 
serial gsm
modem.");
                        System.out.println(Library.getLibraryDescription());
                        System.out.println("Version: " + 
Library.getLibraryVersion());

                        // Create new Service object - the parent of all and 
the main
interface
                        // to you.
                        this.srv = new Service();

                        // Create the Gateway representing the serial GSM modem.
                        IPModemGateway gateway = new 
IPModemGateway("modem.com1",
"172.16.254.122", 5000, "Multitech", "SMSFinder");
                        gateway.setIpProtocol(IPProtocols.BINARY);

                        // Set the modem protocol to PDU (alternative is TEXT). 
PDU is the
default, anyway...
                        gateway.setProtocol(Protocols.PDU);

                        // Do we want the Gateway to be used for Inbound 
messages?
                        gateway.setInbound(true);

                        // Do we want the Gateway to be used for Outbound 
messages?
                        gateway.setOutbound(true);

                        // Let SMSLib know which is the SIM PIN.
                        gateway.setSimPin("0000");

                        // Set up the notification methods.
                        
this.srv.setInboundMessageNotification(inboundNotification);
                        this.srv.setCallNotification(callNotification);
                        
this.srv.setGatewayStatusNotification(statusNotification);

                        // Add the Gateway to the Service object.
                        this.srv.addGateway(gateway);

                        // Similarly, you may define as many Gateway objects, 
representing
                        // various GSM modems, add them in the Service object 
and control
all of them.

                        // Start! (i.e. connect to all defined Gateways)
                        this.srv.startService();

                        // Printout some general information about the modem.
                        System.out.println();
                        System.out.println("Modem Information:");
                        System.out.println("  Manufacturer: " + 
gateway.getManufacturer());
                        System.out.println("  Model: " + gateway.getModel());
                        System.out.println("  Serial No: " + 
gateway.getSerialNo());
                        System.out.println("  SIM IMSI: " + gateway.getImsi());
                        System.out.println("  Signal Level: " + 
gateway.getSignalLevel() +
"%");
                        System.out.println("  Battery Level: " + 
gateway.getBatteryLevel()
+ "%");
                        System.out.println();

                        // Read Messages. The reading is done via the Service 
object and
                        // affects all Gateway objects defined. This can also 
be more
directed to a specific
                        // Gateway - look the JavaDocs for information on the 
Service
method calls.
                        msgList = new ArrayList<InboundMessage>();
                        this.srv.readMessages(msgList, MessageClasses.UNREAD);
                        for (InboundMessage msg : msgList){

                             System.out.println(msg);
                             this.srv.deleteMessage(msg);
                        }

                        // Sleep now. Emulate real world situation and give a 
chance to the
notifications
                        // methods to be called in the event of message or 
voice call
reception.

                        System.out.println("Now Sleeping - Hit <enter> to stop 
service.");
                        System.in.read(); System.in.read();
                }
                catch (Exception e)
                {
                        e.printStackTrace();
                }
                finally
                {
                        this.srv.stopService();
                }
        }

        public class InboundNotification implements
IInboundMessageNotification
        {
                public void process(String gatewayId, MessageTypes msgType,
InboundMessage msg)
                {
                      if (msgType == MessageTypes.INBOUND) {
                      System.out.println(">>> New Inbound message
detected from Gateway: " + gatewayId);
                    } else if (msgType == MessageTypes.STATUSREPORT) {
                        System.out.println(">>> New Inbound Status
Report message detected from Gateway: " + gatewayId);
                    }
                    System.out.println(msg);
                    try {
                        // Uncomment following line if you wish to
delete the message upon arrival.
                        ReadMessages.this.srv.deleteMessage(msg);
                    } catch (Exception e) {
                        System.out.println("Oops!!! Something gone
bad...");
                        e.printStackTrace();
                    }
                }
        }

        public class CallNotification implements ICallNotification
        {
                public void process(String gatewayId, String callerId)
                {
                        System.out.println(">>> New call detected from Gateway: 
" +
gatewayId + " : " + callerId);
                }
        }

        public class GatewayStatusNotification implements
IGatewayStatusNotification
        {
                public void process(String gatewayId, GatewayStatuses oldStatus,
GatewayStatuses newStatus)
                {
                        System.out.println(">>> Gateway Status change for " + 
gatewayId +
", OLD: " + oldStatus + " -> NEW: " + newStatus);
                }
        }

        public static void main(String args[])
        {
                ReadMessages app = new ReadMessages();
                try
                {
                        app.doIt();
                }
                catch (Exception e)
                {
                        e.printStackTrace();
                }
        }
}



Regards






On 1 Mar, 21:57, Thanasis <[email protected]> wrote:
> Hi,
>
> The error is about the KeyManager. Are you using encrypted messages?
> It seems that something is not setup properly...
>
> On Feb 28, 3:27 pm, Luis Fernandes <[email protected]> wrote:
>
>
>
> > Hello guys,
>
> > I got the following error message when a try to read the message :
>
> > 28/Fev/2010 14:18:16 org.smslib.helper.Logger logError
> > SEVERE: GTW: modem.com1: Unhandled SMS in inbox, skipping...
> > java.lang.NullPointerException
> >         at org.smslib.crypto.KeyManager.getKey(KeyManager.java:103)
> >         at
> > org.smslib.modem.ModemGateway.readMessagesPDU(ModemGateway.java:565)
> >         at org.smslib.modem.ModemGateway.readMessages(ModemGateway.java:207)
> >         at
> > org.smslib.modem.AModemDriver$AsyncMessageProcessor.run(AModemDriver.java:8 
> > 58)
> > 28/Fev/2010 14:18:16 org.smslib.helper.Logger logError
> > SEVERE: GTW: modem.com1: ERROR PDU:
> > 000000FF0006B10C914294321466610120821181424001208211
> > 28/Fev/2010 14:18:16 org.smslib.helper.Logger logError
> > SEVERE: GTW: modem.com1: Unhandled SMS in inbox, skipping...
>
> > I try to polling the modem everytime to read new messages, and when i try to
> > read i receive :
> > java.lang.NullPointerException
> >         at org.smslib.crypto.KeyManager.getKey(KeyManager.java:103)
> >         at
> > org.smslib.modem.ModemGateway.readMessagesPDU(ModemGateway.java:565)
> >         at org.smslib.modem.ModemGateway.readMessages(ModemGateway.java:207)
> >         at
> > org.smslib.modem.AModemDriver$AsyncMessageProcessor.run(AModemDriver.java:8 
> > 58)
> > 28/Fev/2010 14:23:04 org.smslib.helper.Logger logError
> > SEVERE: GTW: modem.com1: ERROR PDU:
> > 000000FF0006CB0C914294321466610120824171534001208241
> > 28/Fev/2010 14:23:04 org.smslib.helper.Logger logError
> > SEVERE: GTW: modem.com1: Unhandled SMS in inbox, skipping...
>
> > i use the following method to read message between 60 seconds:
> >     public void lread() {
>
> >         try {
>
> >             List<InboundMessage> msgList = new ArrayList<InboundMessage>();
> >             LeSMS_IP.getSrv().readMessages(msgList, MessageClasses.UNREAD);
>
> >             for (InboundMessage msg : msgList) {
>
> >                 if (msg.getType() == MessageTypes.INBOUND) {
>
> >                     System.out.println(msg);
> >                     ps.printaASMS(msg.getOriginator(), msg.getText());
> >                     LeSMS_IP.getSrv().deleteMessage(msg);
>
> >                 } else if ( msg.getType() == MessageTypes.STATUSREPORT) {
>
> >                     LeSMS_IP.getSrv().deleteMessage(msg);
> >                 }
>
> >             }
>
> >         }catch (Exception ex) {
> >             ex.printStackTrace();
> >         }
>
> >     }
>
> > if a try to send a sms there is no problem.
>
> > What can be the reason for that  ?
>
> > regards
>
> > My operation system : windows server 2008
>
> > SMSLib Version: 3.4.5
>
> > Modem : Ip modem Multitech smsfinder
>
> > --
> > Luis Claudiohttp://agentelu.blogspot.com/
> > +244 923416616

-- 
You received this message because you are subscribed to the Google Groups 
"SMSLib User Group" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/smslib?hl=en.

Reply via email to