radhwa.blogg.se

Java rxtx serial port example
Java rxtx serial port example




While sending the SMS message, send it to the same mobile number that you are using as a GSM modem to send the message. Then use the same device as the GSM modem. Though I have suggested the use of two Nokia 6600 mobile sets (one to be used as GSM modem, another to be used as the Java ME client), you can test the behavior with only one.

  • SMSLib uses the Java Communications API or RxTx, which makes native calls to interact with the operating system.
  • Using a GSM modem, the speed of sending an SMS message is not fast (depends on GSM modem you have chosen and the SMS service provider).
  • But while making any decision, keep in mind the following two points: I have just mentioned one possible approach you can choose any design that fits best for your architecture.

    java rxtx serial port example

    Write a message-driven bean to pick up the message, and then it will make a Web service call to the service (which embeds the SMS sending code). For example, when you try to send a message to a device, put it inside a Java Message Service queue with the required information (mobile number, port, message, etc.). But, since we're using a GSM modem, the SMS sending speed is slow so if we call the interface (RMI or Web service) directly, it is better to use an asynchronous design. An alternate solution embeds such code in a separate standalone, vanilla RMI (remote method invocation) server or Web service server, and accesses it from the application server. Point to note: Since SMSLib uses the Java Communications API, or RxTx, which makes native calls to the operating system, I suggest not embedding such code directly in the application server or Web server. In Step 11, make sure while running the SendMessageWithPortsSMSLib, you have the recently built JAR (the changes for RxTx) in your classpath and that it is using RXTXcomm.jar and the rxtxSerial.dll file instead of the Java Communications API's comm.jar and corresponding dll file.

  • Now follow the steps starting from Step 3 in the previous list.
  • Specifically, find the line outStream.flush(), comment it out, and then rebuild.

    java rxtx serial port example

    To eliminate those errors, I commented out some lines in CSerialDriver. Now, in my case, I received some errors while sending the SMS message because I have a virtual port mapping for infrared connections.

    java rxtx serial port example

    But in a real-world scenario, you will not use a mobile phone as a modem, but a real GSM modem, which connects through a real COM (serial) port. As I write this article, RxTx supports physical serial connections well, but shows some exceptions for "virtual" serial ports, i.e., emulated serial ports via Bluetooth/infrared/USB connections. For SMSLib to work with RxTx, edit CSerialDriver.java and remove line m.*.

  • SMSLib is packaged for use with the Java Communications API, but with a little code change, we can use it with RxTx also.
  • Copy RXTXComm.jar to the (JDKDIR)\jre\lib\ext directory and copy the rxtxSerial.dll file to the (JDKDIR)\jre\bin directory.





  • Java rxtx serial port example