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. modem.localIP();
  36. #if defined(TINY_GSM_MODEM_HAS_GPRS)
  37. modem.waitForNetwork();
  38. modem.gprsConnect("YourAPN", "", "");
  39. #endif
  40. #if defined(TINY_GSM_MODEM_HAS_WIFI)
  41. modem.networkConnect("YourSSID", "YourPWD");
  42. modem.waitForNetwork();
  43. #endif
  44. client.connect(server, 80);
  45. // Make a HTTP GET request:
  46. client.print(String("GET ") + resource + " HTTP/1.0\r\n");
  47. client.print(String("Host: ") + server + "\r\n");
  48. client.print("Connection: close\r\n\r\n");
  49. unsigned long timeout = millis();
  50. while (client.connected() && millis() - timeout < 10000L) {
  51. while (client.available()) {
  52. client.read();
  53. timeout = millis();
  54. }
  55. }
  56. client.stop();
  57. #if defined(TINY_GSM_MODEM_HAS_GPRS)
  58. modem.gprsDisconnect();
  59. #endif
  60. #if defined(TINY_GSM_MODEM_HAS_WIFI)
  61. modem.networkDisconnect();
  62. #endif
  63. }