Total members 11894 |It is currently Thu Nov 21, 2024 1:07 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





hie guys i need some help with this code below. i sometimes send and receive sms using this code but its very unreliable sometimes it refuses to connect. this is my undergraduate project. I want to receive and send sms using gsm. I'm using a huawei modem. pls help.below is the code:

SENDING SMS:
// jSMSEngine API.
// An open-source API package for sending and receiving SMS via a GSM device.
// Copyright (C) 2002-2006, Thanasis Delenikas, Athens/GREECE
// Web Site: http://www.jsmsengine.org
//
// jSMSEngine is a package which can be used in order to add SMS processing
// capabilities in an application. jSMSEngine is written in Java. It allows you
// to communicate with a compatible mobile phone or GSM Modem, and
// send / receive SMS messages.
//
// jSMSEngine is distributed under the LGPL license.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//

//
// SendMessage.java - Sample application.
//
// This application shows you the basic procedure needed for sending
// an SMS messages from your GSM device.
//

// Include the necessary package.
import java.util.Date;

import org.jsmsengine.*;

class SendMessage2
{
public SendMessage2()
{

}
public SendMessage2(String phoneNumber, String smsMessage)
{
int status;


CService srv = new CService("COM7", 9600, "E156G", "CD27TCPU");
//temp = new CService("",455,"","");
//MessageFormat mt = new MessageFormat(null);
System.out.println();
System.out.println("SendMessage(): sample application.");
System.out.println(" Using " + srv._name + " " + srv._version);
System.out.println();
try
{
srv.setSimPin("0000");
srv.connect();

srv.setSmscNumber("");

System.out.println("Mobile Device Information: ");
System.out.println(" Manufacturer : " + srv.getDeviceInfo().getManufacturer());
System.out.println(" Model : " + srv.getDeviceInfo().getModel());
System.out.println(" Serial No : " + srv.getDeviceInfo().getSerialNo());
System.out.println(" IMSI : " + srv.getDeviceInfo().getImsi());
System.out.println(" S/W Version : " + srv.getDeviceInfo().getSwVersion());
System.out.println(" Battery Level : " + srv.getDeviceInfo().getBatteryLevel() + "%");
System.out.println(" Signal Level : " + srv.getDeviceInfo().getSignalLevel() + "%");




COutgoingMessage msg = new COutgoingMessage(phoneNumber, smsMessage);


CIncomingMessage msgReceived = new CIncomingMessage(new Date(), "", "", 1);
msg.setMessageEncoding(CMessage.MESSAGE_ENCODING_7BIT);

srv.sendMessage(msg);

srv.disconnect();
}
catch (Exception e)
{
e.printStackTrace();
}
}


public static void main(String[] args)
{
SendMessage2 sms = new SendMessage2("+263772316794", "HIE Test");
System.exit(0);
}
}

READING SMS:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.Caret;

import java.io.*;
import java.util.*;
import java.util.Date;
import java.sql.*;


import javax.swing.border.*;

import org.jsmsengine.CIncomingMessage;
import org.jsmsengine.CService;

import java.text.*;

class ReadMessage extends JInternalFrame
{
Locale local[];
String s[];
ReadMessage()
{
super("Read Message",false,true,false,false);
setSize((FBRMSMain.x/2)-200,FBRMSMain.y/2);
setLocation((FBRMSMain.x/4)+400,(FBRMSMain.y/4)-190);

Container c=getContentPane();
c.setLayout(new BorderLayout());
JPanel north=new JPanel();
Date nd = new Date();
JLabel l=new JLabel("Today's date:"+ nd);
l.setForeground(new Color(255,255,255));
north.setBackground(Color.blue);
l.setFont(new Font("Arial",Font.BOLD,20));
north.add(l);
c.add(north,"North");


//reading messages

int status;
LinkedList msgList = new LinkedList();

CService srv = new CService("COM7", 9600, "E156G", "CD27TCPU");
CIncomingMessage msg = null;

System.out.println();
System.out.println("ReadMessages(): sample application.");
System.out.println(" Using " + srv._name + " " + srv._version);
System.out.println();

try
{
srv.setSimPin("0000");
srv.connect();

System.out.println("Mobile Device Information: ");
System.out.println(" Manufacturer : " + srv.getDeviceInfo().getManufacturer());
System.out.println(" Model : " + srv.getDeviceInfo().getModel());
System.out.println(" Serial No : " + srv.getDeviceInfo().getSerialNo());
System.out.println(" IMSI : " + srv.getDeviceInfo().getImsi());
System.out.println(" S/W Version : " + srv.getDeviceInfo().getSwVersion());
System.out.println(" Battery Level : " + srv.getDeviceInfo().getBatteryLevel() + "%");
System.out.println(" Signal Level : " + srv.getDeviceInfo().getSignalLevel() + "%");

srv.readMessages(msgList, CIncomingMessage.CLASS_ALL);
for (int i = 0; i < msgList.size(); i ++)
{
msg = (CIncomingMessage) msgList.get(i);
//String sms = (String)msg;
System.out.println(msg);
}

srv.disconnect();
}
catch (Exception e)
{
e.printStackTrace();
}
//System.exit(0);




emp_NameText=new JTextField();
emp_NameText.setBounds(0, 0, (FBRMSMain.x/2), (FBRMSMain.y/2)-70);

emp_NameText.setCaret((Caret) msg);

west=new JPanel()
{
public void paintComponent(Graphics g)
{
Toolkit kit = Toolkit.getDefaultToolkit();
Image img =kit.getImage("Image/BACK5.jpg");
MediaTracker t=new MediaTracker(this);
t.addImage(img,0);
while(true)
{
try
{
t.waitForAll();
break;
}
catch(Exception ee)
{}
}
g.drawImage(img,0,0,FBRMSMain.x/2,FBRMSMain.y/2,null);
}
};

//west.setBorder(BorderFactory.createRaisedBevelBorder());
west.setLayout(null);

west.add(emp_NameText);


c.add(west);


}
public static void main(String []args)
{
ReadMessage p =new ReadMessage();
p.setVisible(true);
}


private JTextField emp_NameText;

private JPanel west,south;


}

THIS IS THE ERROR MESSAGE BELOW FOR BOTH OF THEM:
gnu.io.NoSuchPortException
at gnu.io.CommPortIdentifier.getPortIdentifier(CommPortIdentifier.java:218)
at org.jsmsengine.CSerialDriver.open(CSerialDriver.java:80)
at org.jsmsengine.CService.connect(CService.java:331)
at SendMessage2.<init>(SendMessage2.java:59)
at SendMessage2.main(SendMessage2.java:94)




Author:
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : interminert connection to gsm network using virtual ports
 Write data to ports     -  
 Read input from SWITCHES and PORTS     -  
 Read input from ports and print it on the LEDs     -  
 What are Virtual Functions?     -  
 Need help about Enhanced Virtual Executor (EVE)     -  
 Virtual Reality Applications     -  
 softwares of virtual reality     -  
 transferring presentation on virtual classroom     -  
 database connection     -  
 Closing connection in jsp     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com