Thursday, December 4, 2008

Using AT commands + serial port to control mobile phone from processing

import processing.serial.*;

Serial mobilePort;

void setup(){
println(Serial.list());
mobilePort=new Serial(this, Serial.list()[9], 9600);
size(400, 400);
}

void draw(){
// Expand array size to the number of bytes you expect
byte[] inBuffer = new byte[7];
while (mobilePort.available() > 0) {
inBuffer = mobilePort.readBytes();
mobilePort.readBytes(inBuffer);
if (inBuffer != null) {
String myString = new String(inBuffer);
println(myString);
}
}

}

void mousePressed(){
//make phone calls
//mobilePort.write("ATD+1878200;");
// mobilePort.write("\n\r");

//Anser phone call
mobilePort.write("ATA;");
mobilePort.write("\n\r");
}

No comments: