You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.7 KiB

  1. /**************************************************************
  2. *
  3. * DO NOT USE THIS - this is just a compilation test!
  4. *
  5. **************************************************************/
  6. #include <TinyGsmClient.h>
  7. TinyGsm modem(Serial);
  8. TinyGsmClient client(modem);
  9. char server[] = "somewhere";
  10. char resource[] = "something";
  11. void setup() {
  12. Serial.begin(115200);
  13. delay(3000);
  14. modem.restart();
  15. }
  16. void loop() {
  17. // Test the start/restart functions
  18. modem.restart();
  19. modem.begin();
  20. modem.autoBaud();
  21. modem.factoryDefault();
  22. // Test the SIM card functions
  23. #if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590) || defined(TINY_GSM_MODEM_XBEE)
  24. modem.getSimCCID();
  25. modem.getIMEI();
  26. modem.getSimStatus();
  27. modem.getRegistrationStatus();
  28. modem.getOperator();
  29. #endif
  30. // Test the Networking functions
  31. modem.getSignalQuality();
  32. #if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
  33. modem.waitForNetwork();
  34. modem.gprsConnect("YourAPN", "", "");
  35. #else
  36. modem.networkConnect("YourSSID", "YourPWD");
  37. modem.waitForNetwork();
  38. #endif
  39. client.connect(server, 80);
  40. // Make a HTTP GET request:
  41. client.print(String("GET ") + resource + " HTTP/1.0\r\n");
  42. client.print(String("Host: ") + server + "\r\n");
  43. client.print("Connection: close\r\n\r\n");
  44. unsigned long timeout = millis();
  45. while (client.connected() && millis() - timeout < 10000L) {
  46. while (client.available()) {
  47. client.read();
  48. timeout = millis();
  49. }
  50. }
  51. client.stop();
  52. #if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
  53. modem.gprsDisconnect();
  54. #else
  55. modem.networkDisconnect();
  56. #endif
  57. }