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

قراءة رسائل من الجوال باستخدام لغة الجافا و At Command

بدأه عمر35 في 1 مايو 2009 · 1 رد · 1,432 مشاهدة · في 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

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

هذا رابط ممكن يفيدك

http://www.option.com/en/support/knowledge...th-at-commands/

وهذا روابط ممكن تفيدك ايضاً

http://vb4arab.com/vb/showthread.php?t=5488&page=2

http://www.vb4arab.com/vb/showthread.php?t=10258

واذا اتوصلت لحل في استقبال المسج اتمنى منك تفيدني لأني اتعقدت شويتين وراح اعرض موضوعي في المنتدا...

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

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…