ok my last post for today...

i decided to go all-for-nothing style uninstalled everything and made
it my own way, to see if i let this nice group of developers to rest,
installing rxtx instead of javaCommv2 (in installation said "you
should use it for win32", yeah, rigth...) after that changed the jcl
for the simple in slf4j, added everything, double checked running an
old aplication of mine in rxtx, worked, after that i measurred with
this awesome package called smslib

and oh my God it was trying to connect to the com i needed (Nokia 3500
classic USB (COM7)), but it failed after time:

Results here;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
run:
Set default port to COM7
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7
Found port: COM7
0 [main] INFO smslib - SMSLib: A Java API library for sending and
receiving SMS via a GSM modem or other supported gateways.
This software is distributed under the terms of the Apache v2.0
License.
Web Site: http://smslib.org
0 [main] INFO smslib - Version: 3.4.3
0 [main] INFO smslib - JRE Version: 1.6.0_16
0 [main] INFO smslib - JRE Impl Version: 14.2-b01
0 [main] INFO smslib - O/S: Windows XP / x86 / 5.1
111111111111111111111111111111
2222222222222222222222222222222
0 [Thread-3] INFO smslib - GTW: modem.com7: Starting gateway, using
Generic AT Handler.
0 [Thread-3] INFO smslib - GTW: modem.com7: Opening: COM7 @57600
139391 [Thread-3] INFO smslib - GTW: modem.com7: Closing: COM7 @57600
140000 [main] INFO smslib - GTW: modem.com7: Stopping gateway...
140000 [main] INFO smslib - GTW: modem.com7: Closing: COM7 @57600
140000 [main] INFO smslib - GTW: modem.com7: Gateway stopped.
org.smslib.TimeoutException: No response from device.
        at org.smslib.modem.AModemDriver$CharQueue.get
(AModemDriver.java:503)
        at org.smslib.modem.AModemDriver.getResponse(AModemDriver.java:
295)
        at org.smslib.modem.athandler.ATHandler.getSimStatus
(ATHandler.java:132)
        at org.smslib.modem.AModemDriver.connect(AModemDriver.java:
129)
        at org.smslib.modem.ModemGateway.startGateway
(ModemGateway.java:182)
        at org.smslib.Service$1Starter.run(Service.java:257)
BUILD SUCCESSFUL (total time: 2 minutes 20 seconds)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

code here
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package examples.modem;

// derived from SUN's examples in the javax.comm package
import java.io.*;
import java.util.*;
//import javax.comm.*; // for SUN's serial/parallel port libraries
import gnu.io.*; // for rxtxSerial library

import java.util.ArrayList;
import java.util.List;
import javax.crypto.spec.SecretKeySpec;
import org.smslib.ICallNotification;
import org.smslib.IGatewayStatusNotification;
import org.smslib.IInboundMessageNotification;
import org.smslib.IOrphanedMessageNotification;
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.crypto.AESKey;
import org.smslib.modem.SerialModemGateway;



public class nulltest implements Runnable, SerialPortEventListener {
   static CommPortIdentifier portId;
   static CommPortIdentifier saveportId;
   static Enumeration        portList;
   static InboundNotification inboundNotification= new
InboundNotification();;
static CallNotification callNotification = new CallNotification();

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

static OrphanedMessageNotification orphanedMessageNotification = new
OrphanedMessageNotification();

   InputStream           inputStream;
   SerialPort           serialPort;
   Thread           readThread;
    List<InboundMessage> msgList;

   static Service srv;

   static String        messageString = "Hello, world!";
   static OutputStream      outputStream;
   static boolean        outputBufferEmptyFlag = false;

   public static void main(String[] args) {
      boolean           portFound = false;
      String           defaultPort;
      // determine the name of the serial port on several operating
systems
      String osname = System.getProperty("os.name","").toLowerCase();
      if ( osname.startsWith("windows") ) {
         // windows
         defaultPort = "COM7";
      } else if (osname.startsWith("linux")) {
         // linux
        defaultPort = "/dev/ttyS0";
      } else if ( osname.startsWith("mac") ) {
         // mac
         defaultPort = "????";
      } else {
         System.out.println("Sorry, your operating system is not
supported");
         return;
      }

      if (args.length > 0) {
         defaultPort = args[0];
      }

      System.out.println("Set default port to "+defaultPort);

                // parse ports and if the default port is found, initialized the
reader
      portList = CommPortIdentifier.getPortIdentifiers();
      while (portList.hasMoreElements()) {
         portId = (CommPortIdentifier) portList.nextElement();
         if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
            if (portId.getName().equals(defaultPort)) {
               System.out.println("Found port: "+defaultPort);
               portFound = true;
               SerialModemGateway gateway = new SerialModemGateway
("modem.com7", "COM7", 57600, "Nokia", "3500");
               srv= new Service();
                                // 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.
/*                      srv.setInboundMessageNotification(inboundNotification);
                        srv.setCallNotification(callNotification);
                        srv.setGatewayStatusNotification(statusNotification);
                        
srv.setOrphanedMessageNotification(orphanedMessageNotification);
*/
                        // Add the Gateway to the Service object.


                        // 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)



               try{
                   System.out.println
("111111111111111111111111111111");
                   srv.addGateway(gateway);
                   System.out.println
("2222222222222222222222222222222");
                   srv.startService();
                   System.out.println
("3333333333333333333333333333333");
                   System.out.println("  Model: " + gateway.getModel
());
                   System.out.println
("4444444444444444444444444444444");
               }
               catch(Exception e){
                e.printStackTrace();
               }
               // init reader thread
              // nulltest reader = new nulltest();
            }
         }

      }
      if (!portFound) {
         System.out.println("port " + defaultPort + " not found.");
      }

   }


        static 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);
                }
        }

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

        static 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);
                }
        }

        static public class OrphanedMessageNotification implements
IOrphanedMessageNotification
        {
                public boolean process(String gatewayId, InboundMessage msg)
                {
                        System.out.println(">>> Orphaned message part detected 
from " +
gatewayId);
                        System.out.println(msg);
                        // Since we are just testing, return FALSE and keep the 
orphaned
message part.
                        return false;
                }
        }
   public void initwritetoport() {
      // initwritetoport() assumes that the port has already been
opened and
      //    initialized by "public nulltest()"

      try {
         // get the outputstream
         outputStream = serialPort.getOutputStream();
      } catch (IOException e) {}

      try {
         // activate the OUTPUT_BUFFER_EMPTY notifier
         serialPort.notifyOnOutputEmpty(true);
      } catch (Exception e) {
         System.out.println("Error setting event notification");
         System.out.println(e.toString());
         System.exit(-1);
      }

   }

   public void writetoport() {
      System.out.println("Writing \""+messageString+"\" to
"+serialPort.getName());
      try {
         // write string to serial port
         outputStream.write(messageString.getBytes());
      } catch (IOException e) {}
   }

   public nulltest() {


       // initalize serial port
      try {
         serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
      } catch (PortInUseException e) {}

      try {
         inputStream = serialPort.getInputStream();
      } catch (IOException e) {}

      try {
         serialPort.addEventListener(this);
      } catch (TooManyListenersException e) {}

      // activate the DATA_AVAILABLE notifier
      serialPort.notifyOnDataAvailable(true);

      try {
         // set port parameters
         serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
                     SerialPort.STOPBITS_1,
                     SerialPort.PARITY_NONE);
      } catch (UnsupportedCommOperationException e) {}

      // start the read thread
      readThread = new Thread(this);
      readThread.start();

   }

   public void run() {
      // first thing in the thread, we initialize the write operation
      initwritetoport();
      try {
         while (true) {
            // write string to port, the serialEvent will read it
            writetoport();
            Thread.sleep(1000);
         }
      } catch (InterruptedException e) {}
   }

   public void serialEvent(SerialPortEvent event) {
      switch (event.getEventType()) {
      case SerialPortEvent.BI:
      case SerialPortEvent.OE:
      case SerialPortEvent.FE:
      case SerialPortEvent.PE:
      case SerialPortEvent.CD:
      case SerialPortEvent.CTS:
      case SerialPortEvent.DSR:
      case SerialPortEvent.RI:
      case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
         break;
      case SerialPortEvent.DATA_AVAILABLE:
         // we get here if data has been received
         byte[] readBuffer = new byte[20];
         try {
            // read data
            while (inputStream.available() > 0) {
               int numBytes = inputStream.read(readBuffer);
            }
            // print data
            String result  = new String(readBuffer);
            System.out.println("Read: "+result);
         } catch (IOException e) {}

         break;
      }
   }



}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Note: the sim pin of the cell is 9310, tried changing it no luck.

Plis help, im not lazy, is just that i cant find the solution in the
1.000 ways i've tried...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SMSLib for Java 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