Last active
November 26, 2016 16:56
-
-
Save reginaldojunior/2d48e47ec5fbc43382ccb587c4a455f2 to your computer and use it in GitHub Desktop.
connectiongsm-api.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Programa: Arduino GSM Shield SIM900 - Acesso internet | |
//Autor: Arduino e Cia | |
//#include "SIM900.h" | |
#include <SoftwareSerial.h> | |
#include "InetGSM.h" | |
InetGSM inet; | |
boolean started = false; | |
char smsbuffer[160]; | |
char n[20]; | |
byte valor; | |
void setup() | |
{ | |
Serial.begin(9600); | |
powerUpOrDown(); | |
Serial.println(F("Testando GSM Shield SIM900")); | |
if (gsm.begin(2400)) | |
{ | |
Serial.println(F("\nstatus=READY")); | |
started = true; | |
} | |
else Serial.println(F("\nstatus=IDLE")); | |
} | |
void loop() | |
{ | |
if (started) { | |
envia_GSM("teste"); | |
delay(1000); | |
} | |
} | |
void powerUpOrDown() | |
{ | |
//Liga o GSM Shield | |
Serial.print(F("Liga GSM...")); | |
pinMode(6, OUTPUT); | |
digitalWrite(6, LOW); | |
delay(1000); | |
digitalWrite(6, HIGH); | |
delay(1000); | |
Serial.println(F("OK!")); | |
digitalWrite(6, LOW); | |
delay(500); | |
} | |
void envia_GSM(String texto) | |
{ | |
char temp_string[55]; | |
char msg[10]; | |
int numdata; | |
if (inet.attachGPRS("timbrasil.br", "tim", "tim")) | |
Serial.println(F("status=Conectado...")); | |
else Serial.println(F("status=Nao conectado !!")); | |
delay(100); | |
String valor = "MSG_Texto1=" + texto; | |
valor.toCharArray(temp_string, 55); | |
numdata = inet.httpGET("api.trackcar.ciawn.com.br", 80, "/lat/testenumberlat/log/teste123456/user/1", msg, 50); | |
delay(5000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment