bool UbirchSIM800::shutdown() { PRINTLN("!!! SIM800 shutdown"); disableGPRS(); expect_AT_OK(F("+CPOWD=1")); expect(F("NORMAL POWER DOWN"), 5000); if (urc_status != 12 && digitalRead(SIM800_PS) == HIGH) { PRINTLN("!!! SIM800 shutdown using PWRKEY"); pinMode(SIM800_KEY, OUTPUT); pinMode(SIM800_PS, INPUT); digitalWrite(SIM800_KEY, LOW); for (uint8_t s = 30; s > 0 && digitalRead(SIM800_PS) != LOW; --s) delay(1000); digitalWrite(SIM800_KEY, HIGH); pinMode(SIM800_KEY, INPUT); pinMode(SIM800_KEY, INPUT_PULLUP); } PRINTLN("!!! SIM800 shutdown ok"); return true; }
void GM862::requestHTTP() { char buf[100]; byte i = 0; initGPRS(); // setup of GPRS context enableGPRS(); // switch GPRS on openHTTP("search.twitter.com"); // open a socket Serial.println("sending request ..."); send("GET /search.atom?q=gm862 HTTP/1.1\r\n"); // search twitter for gm862 send("HOST: search.twitter.com port\r\n"); // write on the socket send("\r\n"); Serial.println("receiving ..."); while (i++ < 10) { // try to read for 10s receive(buf); // read from the socket, timeout 1s if (strlen(buf) > 0) { // we received something Serial.print("buf:"); Serial.println(buf); i--; // reset the timeout } } Serial.println("done"); disableGPRS(); // switch GPRS off }