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.

156 lines
3.8 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. #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. }
  18. void loop() {
  19. // Test the basic functions
  20. // modem.init();
  21. modem.begin();
  22. modem.setBaud(115200);
  23. modem.testAT();
  24. modem.factoryDefault();
  25. modem.getModemInfo();
  26. modem.getModemName();
  27. modem.maintain();
  28. // Test Power functions
  29. modem.restart();
  30. // modem.sleepEnable(); // Not available for all modems
  31. // modem.radioOff(); // Not available for all modems
  32. modem.poweroff();
  33. // Test the SIM card functions
  34. #if defined(TINY_GSM_MODEM_HAS_GPRS)
  35. modem.getSimCCID();
  36. modem.getIMEI();
  37. modem.getSimStatus();
  38. modem.getOperator();
  39. #endif
  40. // Test the calling functions
  41. #if defined(TINY_GSM_MODEM_HAS_CALLING)
  42. modem.callNumber(String("+380000000000"));
  43. #if not defined(TINY_GSM_MODEM_SEQUANS_MONARCH)
  44. modem.callAnswer();
  45. #endif
  46. modem.callHangup();
  47. #endif
  48. // Test the SMS functions
  49. #if defined(TINY_GSM_MODEM_HAS_SMS)
  50. #if not defined(TINY_GSM_MODEM_XBEE) && not defined(TINY_GSM_MODEM_SARAR4)
  51. modem.sendUSSD("*111#");
  52. #endif
  53. modem.sendSMS(String("+380000000000"), String("Hello from "));
  54. #if not defined(TINY_GSM_MODEM_XBEE) && not defined(TINY_GSM_MODEM_M590) && not defined(TINY_GSM_MODEM_SARAR4)
  55. modem.sendSMS_UTF16("+380000000000", "Hello", 5);
  56. #endif
  57. #endif
  58. // Test the GSM location functions
  59. #if defined(TINY_GSM_MODEM_HAS_GSM_LOCATION)
  60. modem.getGsmLocation();
  61. #endif
  62. // Test the Network time function
  63. #if defined(TINY_GSM_MODEM_HAS_TIME)
  64. modem.getGSMDateTime(DATE_FULL);
  65. #endif
  66. // Test the GPS functions
  67. #if defined(TINY_GSM_MODEM_HAS_GPS)
  68. modem.enableGPS();
  69. modem.getGPSraw();
  70. float latitude = -9999;
  71. float longitude = -9999;
  72. modem.getGPS(&latitude, &longitude);
  73. #endif
  74. // Test Battery functions
  75. #if defined(TINY_GSM_MODEM_HAS_BATTERY)
  76. uint8_t chargeState = 0;
  77. int8_t chargePercent = 0;
  78. uint16_t milliVolts = 0;
  79. modem.getBattStats(chargeState, chargePercent, milliVolts);
  80. #endif
  81. // Test the temperature function
  82. #if defined(TINY_GSM_MODEM_HAS_TEMPERATURE)
  83. modem.getTemperature();
  84. #endif
  85. // Test the Networking functions
  86. modem.getRegistrationStatus();
  87. modem.getSignalQuality();
  88. modem.localIP();
  89. #if defined(TINY_GSM_MODEM_HAS_GPRS)
  90. modem.waitForNetwork();
  91. modem.gprsConnect("YourAPN", "", "");
  92. #endif
  93. #if defined(TINY_GSM_MODEM_HAS_WIFI)
  94. modem.networkConnect("YourSSID", "YourWiFiPass");
  95. modem.waitForNetwork();
  96. #endif
  97. client.connect(server, 80);
  98. // Make a HTTP GET request:
  99. client.print(String("GET ") + resource + " HTTP/1.0\r\n");
  100. client.print(String("Host: ") + server + "\r\n");
  101. client.print("Connection: close\r\n\r\n");
  102. uint32_t timeout = millis();
  103. while (client.connected() && millis() - timeout < 10000L) {
  104. while (client.available()) {
  105. client.read();
  106. timeout = millis();
  107. }
  108. }
  109. client.stop();
  110. #if defined(TINY_GSM_MODEM_HAS_SSL)
  111. client_secure.connect(server, 443);
  112. // Make a HTTP GET request:
  113. client_secure.print(String("GET ") + resource + " HTTP/1.0\r\n");
  114. client_secure.print(String("Host: ") + server + "\r\n");
  115. client_secure.print("Connection: close\r\n\r\n");
  116. timeout = millis();
  117. while (client_secure.connected() && millis() - timeout < 10000L) {
  118. while (client_secure.available()) {
  119. client_secure.read();
  120. timeout = millis();
  121. }
  122. }
  123. client_secure.stop();
  124. #endif
  125. #if defined(TINY_GSM_MODEM_HAS_GPRS)
  126. modem.gprsDisconnect();
  127. #endif
  128. #if defined(TINY_GSM_MODEM_HAS_WIFI)
  129. modem.networkDisconnect();
  130. #endif
  131. }