الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

How To Read Sms From Mobile Using Java Programm With Javax.comm

بدأه عمر35 في 30 أبريل 2009 · 1 رد · 985 مشاهدة · في JavaME
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

بســم الله الـرحمــن الرحيــم

السلام عليكــم ورحمـة الله وبركاتــه

نريد مساعدة في موضوع برمجة جافا

لدينا برنامج simple read واستخدمنا طبعا بعد تثبيت javax.comm

وقد تعرف على البورت المتصل بالجوال

الآن كيف ممكن أبعث AT command لقراءة رسائل الجوال

أرجو الإفادة سواء بمواقع مفيدة أو ملفات مرفقة أو برنامج مع شرحه

ملاحظة كل عملنا على بيئة vista

وهذا كود البرنامج

import java.io.*;

import java.util.*;

import javax.comm.*;

public class SimpleRead implements Runnable, SerialPortEventListener {

static CommPortIdentifier portId;

static Enumeration portList;

InputStream inputStream;

SerialPort serialPort;

Thread readThread;

public static void main(String[] args) {

portList = CommPortIdentifier.getPortIdentifiers();

while (portList.hasMoreElements()) {

portId = (CommPortIdentifier) portList.nextElement();

if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {

// if (portId.getName().equals("COM1")) {

if (portId.getName().equals("/dev/term/a")) {

SimpleRead reader = new SimpleRead();

}

}

}

}

public SimpleRead() {

try {

serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);

} catch (PortInUseException e) {}

try {

inputStream = serialPort.getInputStream();

} catch (IOException e) {}

try {

serialPort.addEventListener(this);

} catch (TooManyListenersException e) {}

serialPort.notifyOnDataAvailable(true);

try {

serialPort.setSerialPortParams(9600,

SerialPort.DATABITS_8,

SerialPort.STOPBITS_1,

SerialPort.PARITY_NONE);

} catch (UnsupportedCommOperationException e) {}

readThread = new Thread(this);

readThread.start();

}

public void run() {

try {

Thread.sleep(20000);

} 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:

byte[] readBuffer = new byte[20];

try {

while (inputStream.available() > 0) {

int numBytes = inputStream.read(readBuffer);

}

System.out.print(new String(readBuffer));

} catch (IOException e) {}

break;

}

}

}

وكذلك كود ل simple write

import java.io.*;

import java.util.*;

import javax.comm.*;

public class SimpleWrite {

static Enumeration portList;

static CommPortIdentifier portId;

static String messageString = "Hello, world!\n";

static SerialPort serialPort;

static OutputStream outputStream;

public static void main(String[] args) {

portList = CommPortIdentifier.getPortIdentifiers();

while (portList.hasMoreElements()) {

portId = (CommPortIdentifier) portList.nextElement();

if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {

// if (portId.getName().equals("COM1")) {

if (portId.getName().equals("/dev/term/a")) {

try {

serialPort = (SerialPort)

portId.open("SimpleWriteApp", 2000);

} catch (PortInUseException e) {}

try {

outputStream = serialPort.getOutputStream();

} catch (IOException e) {}

try {

serialPort.setSerialPortParams(9600,

SerialPort.DATABITS_8,

SerialPort.STOPBITS_1,

SerialPort.PARITY_NONE);

} catch (UnsupportedCommOperationException e) {}

try {

outputStream.write(messageString.getBytes());

} catch (IOException e) {}

}

}

}

}

}

نرجو المساعدة وجزاكم الله خيرا

#2

اكتب بالعربي حتى العنوان

تحياتي

حزمة المحرك الإصدارة 0.8

أي أحد يجد أني ظلمته فليراسلني

وبإذن الله لو كان له حق سيأخذه

728x90.png

مواضيع مشابهة