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.9 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. /**************************************************************
  2. *
  3. * DO NOT USE THIS - this is just a compilation test!
  4. *
  5. **************************************************************/
  6. // #define TINY_GSM_MODEM_SIM800
  7. // #define TINY_GSM_MODEM_SIM808
  8. // #define TINY_GSM_MODEM_A6
  9. // #define TINY_GSM_MODEM_M590
  10. // #define TINY_GSM_MODEM_ESP8266
  11. // #define TINY_GSM_MODEM_XBEE
  12. #include <TinyGsmClient.h>
  13. TinyGsm modem(Serial);
  14. TinyGsmClient client(modem);
  15. char server[] = "somewhere";
  16. char resource[] = "something";
  17. void setup() {
  18. Serial.begin(115200);
  19. delay(3000);
  20. modem.restart();
  21. }
  22. void loop() {
  23. // Test the start/restart functions
  24. modem.restart();
  25. modem.begin();
  26. modem.autoBaud();
  27. modem.factoryDefault();
  28. // Test the SIM card functions
  29. #if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590) || defined(TINY_GSM_MODEM_XBEE)
  30. modem.getSimCCID();
  31. modem.getIMEI();
  32. modem.getSimStatus();
  33. modem.getRegistrationStatus();
  34. modem.getOperator();
  35. #endif
  36. // Test the Networking functions
  37. modem.getSignalQuality();
  38. #if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
  39. modem.waitForNetwork();
  40. modem.gprsConnect("YourAPN", "", "");
  41. #else
  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_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
  59. modem.gprsDisconnect();
  60. #else
  61. modem.networkDisconnect();
  62. #endif
  63. }