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.

79 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_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. #if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590) || defined(TINY_GSM_MODEM_XBEE)
  29. modem.getSimCCID();
  30. modem.getIMEI();
  31. modem.getSimStatus();
  32. modem.getRegistrationStatus();
  33. modem.getOperator();
  34. #endif
  35. // Test the Networking functions
  36. modem.getSignalQuality();
  37. #if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
  38. modem.waitForNetwork();
  39. modem.gprsConnect("YourAPN", "", "");
  40. #else
  41. modem.networkConnect("YourSSID", "YourPWD");
  42. modem.waitForNetwork();
  43. #endif
  44. client.connect(server, 80);
  45. // Make a HTTP GET request:
  46. client.print(String("GET ") + resource + " HTTP/1.0\r\n");
  47. client.print(String("Host: ") + server + "\r\n");
  48. client.print("Connection: close\r\n\r\n");
  49. unsigned long timeout = millis();
  50. while (client.connected() && millis() - timeout < 10000L) {
  51. while (client.available()) {
  52. client.read();
  53. timeout = millis();
  54. }
  55. }
  56. client.stop();
  57. #if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
  58. modem.gprsDisconnect();
  59. #else
  60. modem.networkDisconnect()
  61. #endif
  62. }