has anyone tried this? Sony ericsson arduino hack

Guys i need help. i want to try this hack using arduino ans old sony ericsson phone. Here is the link to the videohttp://www.youtube.com/watch?v=5tHlJLQvE1Y

Here is the code.

#include <SoftwareSerial.h> //Software Serial Port
#define RxD 7
#define TxD 8

#define pinOUT1 2



SoftwareSerial ericssonSerial(RxD,TxD);

String phonenum="XYXYXYXYXY";
String phonePDU="YXYXYXYXYX";

String OUT1ON="0C31D98C067A56A931D0D309";
String OUT1OFF="0D31D98C067A56A931D0D36804";
String OUT1FAIL="09CF2A35063206934C";
String OUT1ONOK="0ACF2A35067A3A41CF25";
String OUT1OFFOK="0BCF2A35067A1A8DA0E712";

void setup()
{
 Serial.begin(9600);

 
 pinMode(RxD, INPUT);
 pinMode(TxD, OUTPUT);
 pinMode(pinOUT1, OUTPUT);

 ericssonSerial.begin(9600);
 
 delay(500);
 
 Init();
 
}


void Init(){
  
   while (send_command("AT&F",500) != "&F\r\r\nOK\r\n") {
     delay(1000);
   }
   Serial.println("Modem reset...");
   
   while (send_command("ATE=0",500) != "E=0\r\r\nOK\r\n") {
     delay(1000);
   }
   Serial.println("Echo Off...");
   
   while (send_command("AT+CLIP=1",500) != "\r\nOK\r\n") {
     delay(1000);
   }
   Serial.println("Caller ID enabled...");
   
   while (send_command("AT+CPMS=\"ME\"",500).indexOf("CPMS")==0) {
     delay(1000);
   }
   Serial.println("Phone Memory Selected for SMS...");
   
   while (send_command("AT+CNMI=,1",500) != "\r\nOK\r\n") {
     delay(1000);
   }
   Serial.println("New SMS Indication Activated...");
   
   Serial.println("Ready...");
}


String send_command(String at_cmd, int dly){

  String msg;
  char incomingByte;

  ericssonSerial.println(at_cmd);
  delay(dly);
  while (ericssonSerial.available() > 0) 
  {
    incomingByte = (ericssonSerial.read());
    msg = msg + incomingByte;
  }  
  //delay(1000);

  return msg;
}

void sendSMS(String num,String txt){
  String pduTxt;
  int pduLength;
  
  
   pduTxt="0011000C9103"+num+"0000AA"+txt;  
   pduLength=(pduTxt.length()-2)/2;
   //Serial.println(pduTxt);
   //Serial.println(pduLength);
   ericssonSerial.print("AT+CMGS="+String(pduLength)+"\r");
   delay(5000);
   ericssonSerial.print(pduTxt);
   delay(5000);
   ericssonSerial.write(26);
   delay(1000);
 
}

void loop()
{
 char recvChar;
 String recvStr;
 int ringCount=0;
 String incSMS=0;
 
 while(1){
   recvStr=0;

   while (ericssonSerial.available()>0){
     recvChar = ericssonSerial.read();
     recvStr=recvStr+recvChar;
     //Serial.print(recvChar);
   }


   if (recvStr.indexOf("CLIP")>0){

     if (recvStr.indexOf(phonenum)>0) {
    
       Serial.println(phonenum+" is calling...");
       ringCount=ringCount+1;
       recvStr=0;
       //Serial.println(ringCount);
     }else{
        while (send_command("AT+CHUP",700) != "\r\nOK\r\n"){
        delay(1000);
        }
        Serial.println("Unauthorized caller..");
     } 
   }
   
   if (ringCount==2){
       while (send_command("AT+CHUP",700) != "\r\nOK\r\n"){
         delay(1000);
       }
       digitalWrite(pinOUT1,HIGH);
       Serial.println("OUT1 ON...");
       //delay(5000);
       //digitalWrite(pinOUT1,LOW);
       //Serial.println("LED OFF...");
       ringCount=0;
       Serial.println("Sending SMS <OUT1 ON OK>.....");
       sendSMS(phonePDU, OUT1ONOK);
   }  
   
   if (recvStr.indexOf("CMTI")>0){
     Serial.println("SMS Received...");
     ericssonSerial.println("AT+CMGR=1");
     //delay(500);
   }
   
   if (recvStr.indexOf(phonePDU)>0){
     //Serial.print(recvStr);
     if (recvStr.indexOf(OUT1ON)>0){
       digitalWrite(pinOUT1,HIGH);
       Serial.println("OUT1 ON...");
       delay(1000);
       ericssonSerial.println("AT+CMGD=1");
       delay(1000);
       Serial.println("Sending SMS <OUT1 ON OK>.....");
       sendSMS(phonePDU,OUT1ONOK);
     } else if (recvStr.indexOf(OUT1OFF)>0){
       digitalWrite(pinOUT1,LOW);
       Serial.println("OUT1 OFF...");
       delay(1000);
       ericssonSerial.println("AT+CMGD=1");
       delay(1000);
       Serial.println("Sending SMS <OUT1 OFF OK>.....");
       sendSMS(phonePDU,OUT1OFFOK);
     } else {
         Serial.println("Invalid SMS...");
         delay(1000);
         ericssonSerial.println("AT+CMGD=1");
         delay(1000);
     }
   }
   
   if (recvStr.indexOf("CMGS")>0){
     Serial.println("Message Sent...");
   }
     
   while (Serial.available()){
     recvChar = Serial.read();
     ericssonSerial.print(recvChar);
   }
 }
}

I have tried uploading this code to my arduino and connecting the rx and tx pin and also ground.But nothing appears on my serial monitor... help me fix this code

I see that in the video the phone is connected with 4 wires. Do you know how those are connected?

Do you have the right model of phone?

http://playground.arduino.cc/Main/SonyEricsson
"sending and receiving SMS messages proved to be a little harder. This is partly because each phone seems to work in a slightly different way, and also because some phones will only work using the horrible, horrible, painful PDU method."

I managed to connect all those wires and upload a test sketch to see if the phone is communicating with the arduino. and yes it responses to the AT commands. i also use online PDU converter..
the only problem is this sketch and i want to fix this code to work .

selwynberja:
I have tried uploading this code to my arduino and connecting the rx and tx pin and also ground.But nothing appears on my serial monitor... help me fix this code

Put a Serial.println() statement in setup immediately after the call to Serial.begin(). That will confirm that the Arduino is actually running the code you expect, and that serial output is working.

Then put println calls before and after each interaction with the phone so that you can see which parts of your sketch are actually executing.

If you get a response from the phone which is not what you expect, print it out. This will give you some idea of whether and why the phone is rejecting the commands you send it.