1

I am using Windows 7 as OS on my PC. I am looking to create an application wherein I shall send AT commands to Mobile, programatically. As of now I am looking towards achieving this with USB data cable connection between PC and Mobile. My initial approach was to use JAVA. Though I soon realized that most API development for communication between JAVA and USB port is dead for windows, and none of these APIs support Windows 7. Can someone please suggest which language would be best for doing this?

Thanks, Ishan Aggarwal

  • 1
    you didn't reveal what type of device. – Maxim Shoustin Jan 22 '13 at 08:51
  • The device I am looking to connect to PC is Cell phones. I want no limitation on brand, though I want to start with Blackberry. – Ishan Aggarwal Jan 23 '13 at 12:20
  • Maybe it a little bit late but currently I work with http://theiphonewiki.com/wiki/MobileDevice_Library That one should support windows side (its written in C but you can create a C++ project in VS) and I know it possible to integrate it to C#. Let me know if it may help and I Will post more accurate answer. – Mike.R Jul 26 '13 at 07:34
  • See my answer in this post http://stackoverflow.com/a/25015990/216057 – Rémy DAVID Jul 29 '14 at 14:58

1 Answers1

2

For Android to create connection with PC, you need forward the same port by using adb command (Android SDK), like:

adb forward tcp:7612 tcp:7612 

In Java it seems like:

private int port = 7612;
....

/**
 * Runs the android debug bridge command of forwarding the ports
 *
 */
private void execAdb() {
    // run the adb bridge
    try {
        String runP = "adb forward tcp:" + port + " tcp:" + port + "";

        System.out.println("Run command through cmd: " + runP);



        Process p=Runtime.getRuntime().exec(runP);
        Scanner sc = new Scanner(p.getErrorStream());
        if (sc.hasNext()) {
            while (sc.hasNext()) System.out.println(sc.next());
            System.out.println("Cannot start the Android debug bridge");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

After that you can implement any TCP client/server code since the port is defined and you can use default IP like: 127.0.0.1

For iOS use Objective C lang.

Maxim Shoustin
  • 77,483
  • 27
  • 203
  • 225