     return 1;
   }
 
+  if (!gsmSendCommand_P(F("AT+CMGF=1"))) {
+    return 2;
+  }
+
+  if (!gsmSendCommand_P(F("AT+CPMS=\"SM\",\"SM\",\"SM\""))) {
+    return 3;
+  }
+
+  gsmCheckSMS();
+
+  eeprom_read_block((void*)&apn, (const void*)&apn_E, sizeof(apn) - 1);
+  Serial.print(F("Using APN: "));
+  Serial.println(apn);
+
   if (!gsmSendCommand_P(F("AT+CGATT?"))) {
-    return 2;
+    return 4;
   }
 
   if (!gsmSendCommand_P(F("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\""))) {
-    return 3;
+    return 5;
   }
 
   gsmSerial.listen();

  };
}

int16_t gsmGetSignalQuality() {
  gsmSendCommand_P(F("AT+CSQ"));

  char* p = strstr(gsmSerialBuffer, "CSQ: ");

  if (p) {
    p += 5;
    uint8_t i = 0;
    char buffer[3];

    while (*p != ',') {
      buffer[i++] = *(p++);
    }

    int n = atoi(buffer);
    if (n == 99 || n == -1) return 0;
    return n * 2 - 114;
  }

  return 0;

  if (!gsmSendCommand_P(F("AT"))) {
    return 1;
  }

  if (!gsmSendCommand_P(F("AT+IPR=9600"))) {
    return 2;
  }

  if (!gsmSendCommand_P(F("ATE0"))) {
    return 3;
  }

  if (!gsmSendCommand_P(F("AT+CFUN=1"))) {
    return 4;
  }

  return 0;
}

uint8_t gsmSetup() {
  bool success = false;

  for (uint8_t n = 0; n < 30; n++) {
