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.

155 lines
3.6 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();
  31. modem.radioOff();
  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. modem.callAnswer();
  44. modem.callHangup();
  45. #endif
  46. // Test the SMS functions
  47. #if defined(TINY_GSM_MODEM_HAS_SMS)
  48. modem.sendUSSD("*111#");
  49. modem.sendSMS(String("+380000000000"), String("Hello from "));
  50. modem.sendSMS_UTF16("+380000000000", "Hello", 5);
  51. #endif
  52. // Test the GSM location functions
  53. #if defined(TINY_GSM_MODEM_HAS_GSM_LOCATION)
  54. modem.getGsmLocation();
  55. #endif
  56. // Test the Network time function
  57. #if defined(TINY_GSM_MODEM_HAS_TIME)
  58. modem.getGSMDateTime(DATE_FULL);
  59. #endif
  60. // Test the GPS functions
  61. #if defined(TINY_GSM_MODEM_HAS_GPS)
  62. modem.enableGPS();
  63. modem.getGPSraw();
  64. float latitude = -9999;
  65. float longitude = -9999;
  66. modem.getGPS(&latitude, &longitude);
  67. #endif
  68. // Test Battery functions
  69. #if defined(TINY_GSM_MODEM_HAS_BATTERY)
  70. uint8_t chargeState = 0;
  71. int8_t chargePercent = 0;
  72. uint16_t milliVolts = 0;
  73. modem.getBattStats(chargeState, chargePercent, milliVolts);
  74. #endif
  75. // Test the temperature function
  76. #if defined(TINY_GSM_MODEM_HAS_TEMPERATURE)
  77. modem.getTemperature();
  78. #endif
  79. // Test the Networking functions
  80. modem.getRegistrationStatus();
  81. modem.getSignalQuality();
  82. modem.localIP();
  83. #if defined(TINY_GSM_MODEM_HAS_GPRS)
  84. modem.waitForNetwork();
  85. modem.gprsConnect("YourAPN", "", "");
  86. #endif
  87. #if defined(TINY_GSM_MODEM_HAS_WIFI)
  88. modem.networkConnect("YourSSID", "YourWiFiPass");
  89. modem.waitForNetwork();
  90. #endif
  91. client.connect(server, 80);
  92. // Make a HTTP GET request:
  93. client.print(String("GET ") + resource + " HTTP/1.0\r\n");
  94. client.print(String("Host: ") + server + "\r\n");
  95. client.print("Connection: close\r\n\r\n");
  96. uint32_t timeout = millis();
  97. while (client.connected() && millis() - timeout < 10000L) {
  98. while (client.available()) {
  99. client.read();
  100. timeout = millis();
  101. }
  102. }
  103. client.stop();
  104. #if defined(TINY_GSM_MODEM_HAS_SSL)
  105. client_secure.connect(server, 443);
  106. // Make a HTTP GET request:
  107. client_secure.print(String("GET ") + resource + " HTTP/1.0\r\n");
  108. client_secure.print(String("Host: ") + server + "\r\n");
  109. client_secure.print("Connection: close\r\n\r\n");
  110. timeout = millis();
  111. while (client_secure.connected() && millis() - timeout < 10000L) {
  112. while (client_secure.available()) {
  113. client_secure.read();
  114. timeout = millis();
  115. }
  116. }
  117. client_secure.stop();
  118. #endif
  119. #if defined(TINY_GSM_MODEM_HAS_GPRS)
  120. modem.gprsDisconnect();
  121. #endif
  122. #if defined(TINY_GSM_MODEM_HAS_WIFI)
  123. modem.networkDisconnect();
  124. #endif
  125. // Test battery and temperature functions
  126. // modem.getBattVoltage();
  127. // modem.getBattPercent();
  128. // modem.getTemperature();
  129. }