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.

77 lines
1.7 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_A6
  8. // #define TINY_GSM_MODEM_M590
  9. #define TINY_GSM_MODEM_ESP8266
  10. // #define TINY_GSM_MODEM_XBEE
  11. #include <TinyGsmClient.h>
  12. TinyGsm modem(Serial);
  13. TinyGsmClient client(modem);
  14. char server[] = "somewhere";
  15. char resource[] = "something";
  16. void setup() {
  17. Serial.begin(115200);
  18. delay(3000);
  19. modem.restart();
  20. }
  21. void loop() {
  22. // Test the start/restart functions
  23. modem.restart();
  24. modem.begin();
  25. modem.autoBaud();
  26. modem.factoryDefault();
  27. // Test the SIM card functions
  28. modem.getSimCCID();
  29. modem.getIMEI();
  30. modem.getSimStatus();
  31. modem.getRegistrationStatus();
  32. modem.getOperator();
  33. // Test the Networking functions
  34. modem.getSignalQuality();
  35. #if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
  36. modem.waitForNetwork();
  37. modem.gprsConnect("YourAPN", "", "");
  38. #else
  39. modem.networkConnect("YourSSID", "YourPWD");
  40. modem.waitForNetwork();
  41. #endif
  42. client.connect(server, 80);
  43. // Make a HTTP GET request:
  44. client.print(String("GET ") + resource + " HTTP/1.0\r\n");
  45. client.print(String("Host: ") + server + "\r\n");
  46. client.print("Connection: close\r\n\r\n");
  47. unsigned long timeout = millis();
  48. while (client.connected() && millis() - timeout < 10000L) {
  49. while (client.available()) {
  50. client.read();
  51. timeout = millis();
  52. }
  53. }
  54. client.stop();
  55. #if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
  56. modem.gprsDisconnect();
  57. #else
  58. networkDisconnect()
  59. #endif
  60. }