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

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