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.

96 lines
2.1 KiB

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. }
  19. void loop() {
  20. // Test the basic functions
  21. // modem.init();
  22. modem.begin();
  23. modem.setBaud(115200);
  24. modem.testAT();
  25. modem.factoryDefault();
  26. modem.getModemInfo();
  27. modem.getModemName();
  28. modem.maintain();
  29. modem.hasSSL();
  30. modem.hasWifi();
  31. modem.hasGPRS();
  32. // Test Power functions
  33. modem.restart();
  34. // modem.sleepEnable();
  35. modem.radioOff();
  36. modem.poweroff();
  37. // Test the SIM card functions
  38. #if defined(TINY_GSM_MODEM_HAS_GPRS)
  39. modem.getSimCCID();
  40. modem.getIMEI();
  41. modem.getSimStatus();
  42. modem.getOperator();
  43. #endif
  44. // Test the Networking functions
  45. modem.getRegistrationStatus();
  46. modem.getSignalQuality();
  47. modem.localIP();
  48. #if defined(TINY_GSM_MODEM_HAS_GPRS)
  49. modem.waitForNetwork();
  50. modem.gprsConnect("YourAPN", "", "");
  51. #endif
  52. #if defined(TINY_GSM_MODEM_HAS_WIFI)
  53. modem.networkConnect("YourSSID", "YourWiFiPass");
  54. modem.waitForNetwork();
  55. #endif
  56. client.connect(server, 80);
  57. // Make a HTTP GET request:
  58. client.print(String("GET ") + resource + " HTTP/1.0\r\n");
  59. client.print(String("Host: ") + server + "\r\n");
  60. client.print("Connection: close\r\n\r\n");
  61. uint32_t timeout = millis();
  62. while (client.connected() && millis() - timeout < 10000L) {
  63. while (client.available()) {
  64. client.read();
  65. timeout = millis();
  66. }
  67. }
  68. client.stop();
  69. #if defined(TINY_GSM_MODEM_HAS_GPRS)
  70. modem.gprsDisconnect();
  71. #endif
  72. #if defined(TINY_GSM_MODEM_HAS_WIFI)
  73. modem.networkDisconnect();
  74. #endif
  75. // Test battery and temperature functions
  76. // modem.getBattVoltage();
  77. // modem.getBattPercent();
  78. // modem.getTemperature();
  79. }