attachGPRS



Açıklama

GPRS iletişimini başlatmak için belirtilen Erişim Noktası Adı'na (APN) bağlanır.

Her hücresel sağlayıcı, hücresel ağ ve internet arasında bir köprü görevi gören bir Erişim Noktası Adı'na (APN) sahiptir. Bazen bağlantı noktasıyla ilişkilendirilmiş bir kullanıcı adı ve parola vardır. Örneğin, Bluevia APN bluevia.movistar.es'dir, ancak şifresi veya giriş adı yoktur.

Bu sayfa bir dizi operatörün bilgilerini listeliyor, ancak güncel olmayabilir. Bu bilgileri servis sağlayıcınızdan almanız gerekebilir.

Sözdizimi

.attachGPRS GRP'ler (APN, kullanıcı, şifre)

Parametreler

  • APN: char dizisi, mobil operatör tarafından sağlanan Erişim Noktası Adı (APN)
  • user: char dizisi, APN için kullanıcı adı
  • password: char dizisi, APN'ye erişmek için kullanılan parola

İadeler

HATA, BOŞTA, BAĞLANTI, GSM_READY, GPRS_READY, TRANSPARENT_CONNECTED

Misal

#include <GSM.h>

// PIN Number
#define PINNUMBER ""

// APN data
#define GPRS_APN       "GPRS_APN" // replace your GPRS APN
#define GPRS_LOGIN     "login"    // replace with your GPRS login
#define GPRS_PASSWORD  "password" // replace with your GPRS password


// initialize the library instance
GPRS gprs;
GSM gsmAccess;     // include a 'true' parameter for debug enabled
GSMServer server(80); // port 80 (http default)

// timeout
const unsigned long __TIMEOUT__ = 10*1000;

void setup()
{
  // initialize serial communications
  Serial.begin(9600);

  // connection state
  boolean notConnected = true;

  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while(notConnected)
  {
    if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
        (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("Connected to GPRS network");

  // start server
  server.begin();

  //Get IP.
  IPAddress LocalIP = gprs.getIPAddress();
  Serial.println("Server IP address=");
  Serial.println(LocalIP);
}

void loop() {


  // listen for incoming clients
  GSM3MobileClientService client = server.available();



  if (client)
  {  
    while (client.connected())
    {
      if (client.available())
      {
        Serial.println("Receiving request!");
        bool sendResponse = false;
        while(char c=client.read()) {
          if (c == '\n') sendResponse = true;
        }

     // if you've gotten to the end of the line (received a newline
     // character)
       if (sendResponse)
       {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<html>");
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("<br />");      
          }
          client.println("</html>");
          //necessary delay
          delay(1000);
          client.stop();
        }
      }
    }
  }
}

 

See Also