Interfacing gsm modem and arduino

Hi everyone,
here I am with another question. I first explain what I could achieve:

  1. connect my android device (galaxy s3) with the laptop and communicate with the gsm modem (exchanging AT commands) of the S3 through hyperterminal/putty

  2. connect the arduino mega adk with the S3 and send commands to android shell from the board

My problem: Now, what I want to do, is connect the S3 and the mega adk through usb and exchange at commands between S3's gsm modem and the arduino board.

I tried as suggested in this thread

but it does not work...Any idea of how I can do?

basically I would need to transform the arduino mega adk in a sort of hyperterminal or putty...

c'mon guys no ideas at all?
let's find a solution to this :slight_smile:

but it does not work...Any idea of how I can do?

Here's a clue-by-four. Whack yourself with it a few times.

The code you are using, which you haven't bothered to post, does something. You haven't bothered to say what.
You expect it to do something. You haven't bothered to say what.
You haven't bothered to describe how your phone is connected to your Arduino.

Get a clue, if you really expect help. Otherwise, quit complaining.

Well I posted the link that provides the code I am using…I thought it was better to provide the link with the full code rather than copy it here…

In any case the code I am using is the one below (copied from the link). Basically the problem is that Acm.isReady() never returns true. I tried to substitute it with “Usb.getUsbTaskState() == USB_STATE_RUNNING” but I get same problem.

I have connected the Arduino to an external power supply. It is also connected to the desktop through the serial line. Finally, it is connected with the phone through the USB host that is available on the mega ADK board.

I am using the USB_HOST_SHIELD library downloaded from

https://github.com/felis/USB_Host_Shield_2.0

Here is the main code to interface the arduino with the GSM modem of the S3.

#include <cdcacm.h>
#include <usbhub.h>

#include "pgmstrings.h"

// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif

class ACMAsyncOper : public CDCAsyncOper
{
public:
    virtual uint8_t OnInit(ACM *pacm);
};

uint8_t ACMAsyncOper::OnInit(ACM *pacm)
{
    uint8_t rcode;
    // Set DTR = 1 RTS=1
    rcode = pacm->SetControlLineState(3);

    if (rcode)
    {
        ErrorMessage<uint8_t>(PSTR("SetControlLineState"), rcode);
        return rcode;
    }

    LINE_CODING	lc;
    lc.dwDTERate	= 115200;
    lc.bCharFormat	= 0;
    lc.bParityType	= 0;
    lc.bDataBits	= 8;

    rcode = pacm->SetLineCoding(&lc);

    if (rcode)
        ErrorMessage<uint8_t>(PSTR("SetLineCoding"), rcode);

    return rcode;
}

USB     Usb;
//USBHub     Hub(&Usb);
ACMAsyncOper  AsyncOper;
ACM           Acm(&Usb, &AsyncOper);

void setup()
{
  Serial.begin( 115200 );
  while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
  Serial.println("Start");

  if (Usb.Init() == -1)
      Serial.println("OSCOKIRQ failed to assert");

  delay( 200 );
}

void loop()
{
    Usb.Task();

    if( Acm.isReady()) {
       uint8_t rcode;

       /* reading the keyboard */
       if(Serial.available()) {
         uint8_t data= Serial.read();
         /* sending to the phone */
         rcode = Acm.SndData(1, &data);
         if (rcode)
            ErrorMessage<uint8_t>(PSTR("SndData"), rcode);
       }//if(Serial.available()...

       delay(50);

        /* reading the phone */
        /* buffer size must be greater or equal to max.packet size */
        /* it it set to 64 (largest possible max.packet size) here, can be tuned down
        for particular endpoint */
        uint8_t  buf[64];
        uint16_t rcvd = 64;
        rcode = Acm.RcvData(&rcvd, buf);
         if (rcode && rcode != hrNAK)
            ErrorMessage<uint8_t>(PSTR("Ret"), rcode);

            if( rcvd ) { //more than zero bytes received
              for(uint16_t i=0; i < rcvd; i++ ) {
                Serial.print((char)buf[i]); //printing on the screen
              }
            }
        delay(10);
    }//if( Usb.getUsbTaskState() == USB_STATE_RUNNING..
}