toofast1227
toofast1227

Reputation: 160

using php to send AT commands to a mobile phone over bluetooth

I'm using windows 7 and connected my phone using bluetooth. This connection uses a virtual COM port for communication, which I've configured to specified baud rate, flow control, word length, etc. before I call my php function


function sendmsg($str = 'AT\r\n', $device = 'COM5'){
  $handle = fopen($device, "w+b");
  stream_set_blocking($handle, 0);
  fwrite($handle, $str);
  fclose($handle);
  return true;
}

Now the problem is fopen() throws me an error saying that it is an invalid argument and it has failed to opened stream and all else fails. But my phone says it is connected to my computer and then flashes an alert that bluetooth connection has failed. When I tried the same configuration parameters over PuTTY I was able to do what I wanted to do. I've also tried it on C# but that too ended up with the same result :(

Upvotes: 2

Views: 4343

Answers (2)

garzanti
garzanti

Reputation: 2190

I have done something similar but in Python and it worked - Windows Vista talking with a Nokia N70 phone. The phone was paired over bluetooth and the communication it was done using a COM port created along with pairing. It was based on a open source project called pySerial

Upvotes: 0

rik
rik

Reputation: 8612

http://code.google.com/p/php-serial/

Upvotes: 1

Related Questions