Trying to use Arduino mega 1280 to send AT command so that the Sony phone can send sms to alert another user .
#define num_to_char(number) ((number) < 10 ?
('0' + (number)) :
(('A' - 10) + (number)) )
#define first_four(byte) (0x0F & (byte))
#define last_four(byte) ((0xF0 & (byte)) >> 4)
#define hexdump_a(byte) num_to_char( last_four(byte))
#define hexdump_b(byte) num_to_char(first_four(byte))
int timesToSend = 1;
int count = 0;
void setup(){
Serial.begin(9600); // the GPRS baud rate
}
void loop(){
while (count < timesToSend){
send_sms("Hello World");
count++;
}
}
void hexdump_byte(unsigned char byte)
{
Serial.print(hexdump_a(byte), BYTE);
Serial.print(hexdump_b(byte), BYTE);
}
void send_sms(char *data)
{
size_t data_length, x;
char c, l;
long i;
long n;
data_length = strlen(data);
i = data_length * 7;
if (i & 0x07) i = (i & ~0x07) + 0x08;
i = i / 8;
Serial.println("AT+CMGF=0");
delay(1500);
delay(1500);
Serial.println(i + 14);
delay(1500);
Serial.print("0011000B91195289940000AA");
hexdump_byte(data_length & 0xFF);
l = 0;
n = 0;
for (x = 0; x < data_length; x++)
{
if (data[x] == '$') data[x] = 0x02;
n |= (data[x] & 0x7F) << l;
l += 7;
if (l >= 8)
{
hexdump_byte(n & 0xFF);
l -= 8;
n >>= 8;
}
}
if (l != 0)
{
hexdump_byte(n & 0xFF);
}
Serial.println(0x1A, BYTE);
}
Complied and uploaded to Arduino Mega 1280 with no error. But no reaction seems to be happening to the phone.
Hardware Detail
Arduino Mega 1280
Sony Ericsson T68I
Connection Detail
T68I pin 4 RX to Phone Pin 1 TX
T68I pin 5 TX to Phone Pin 0 RX
T68I pin 10 to GND
T68I pin 11 to 5V
What could be the problem ?