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.

80 lines
1.7 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  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. #if defined(TINY_GSM_MODEM_HAS_SSL)
  10. TinyGsmClientSecure client_secure(modem);
  11. #endif
  12. char server[] = "somewhere";
  13. char resource[] = "something";
  14. void setup() {
  15. Serial.begin(115200);
  16. delay(3000);
  17. modem.restart();
  18. }
  19. void loop() {
  20. // Test the start/restart functions
  21. modem.restart();
  22. modem.begin();
  23. modem.testAT();
  24. modem.factoryDefault();
  25. // Test the SIM card functions
  26. #if defined(TINY_GSM_MODEM_HAS_GPRS)
  27. modem.getSimCCID();
  28. modem.getIMEI();
  29. modem.getSimStatus();
  30. modem.getRegistrationStatus();
  31. modem.getOperator();
  32. #endif
  33. // Test the Networking functions
  34. modem.getSignalQuality();
  35. #if defined(TINY_GSM_MODEM_HAS_GPRS)
  36. modem.waitForNetwork();
  37. modem.gprsConnect("YourAPN", "", "");
  38. #endif
  39. #if defined(TINY_GSM_MODEM_HAS_WIFI)
  40. modem.networkConnect("YourSSID", "YourPWD");
  41. modem.waitForNetwork();
  42. #endif
  43. client.connect(server, 80);
  44. // Make a HTTP GET request:
  45. client.print(String("GET ") + resource + " HTTP/1.0\r\n");
  46. client.print(String("Host: ") + server + "\r\n");
  47. client.print("Connection: close\r\n\r\n");
  48. unsigned long timeout = millis();
  49. while (client.connected() && millis() - timeout < 10000L) {
  50. while (client.available()) {
  51. client.read();
  52. timeout = millis();
  53. }
  54. }
  55. client.stop();
  56. #if defined(TINY_GSM_MODEM_HAS_GPRS)
  57. modem.gprsDisconnect();
  58. #endif
  59. #if defined(TINY_GSM_MODEM_HAS_WIFI)
  60. modem.networkDisconnect();
  61. #endif
  62. }