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.

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