Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ----- INÍCIO DO ARQUIVO .INO -----
- // Habilita o debug detalhado da biblioteca TinyGSM.
- #define TINY_GSM_DEBUG Serial
- // Define o modem que você está usando
- #define TINY_GSM_MODEM_SIM800
- #include <TinyGsmClient.h> // Usaremos o cliente GSM normal para HTTP
- #include <ArduinoHttpClient.h>
- // --- Pinos para SIM800L (UART2 do ESP32) ---
- #define SIM800_RX_PIN 16 // Conecte este pino do ESP32 ao pino TX do SIM800L
- #define SIM800_TX_PIN 17 // Conecte este pino do ESP32 ao pino RX do SIM800L
- HardwareSerial sim800(2); // Usando a UART2 do ESP32
- // --- Pino do LED Embutido ---
- #ifndef LED_BUILTIN
- #define LED_BUILTIN 4
- #endif
- // --- Configurações do Seu Servidor (via Ngrok TCP Tunnel) ---
- // !! SUBSTITUA PELO ENDEREÇO E PORTA FORNECIDOS PELO SEU NGROK TCP TUNNEL !!
- const char NGROK_TCP_ADDRESS[] = "0.tcp.sa.ngrok.io"; // Exemplo, substitua pelo seu
- const int NGROK_TCP_PORT = 13469; // Exemplo, substitua pela sua porta
- const String SERVER_PATH = "/"; // O ESP32 vai buscar o comando nesta rota
- // --- Configurações do APN da Claro ---
- char apn[] = "claro.com.br";
- char user[] = "claro";
- char pass[] = "claro";
- // --- Objetos das Bibliotecas ---
- TinyGsm modem(sim800);
- // Cliente GSM normal para HTTP (não seguro, pois o túnel TCP não envolve SSL aqui)
- TinyGsmClient gsm_client_modem(modem);
- // HttpClient usará o cliente GSM normal e a porta TCP do Ngrok
- HttpClient http_client = HttpClient(gsm_client_modem, NGROK_TCP_ADDRESS, NGROK_TCP_PORT);
- // --- Controle de Tempo para Polling ---
- unsigned long previousMillis_request = 0;
- long requestInterval = 3000; // Intervalo entre requisições (15 segundos)
- void setup() {
- Serial.begin(115200);
- delay(1000);
- Serial.println("Monitor Serial INICIADO!");
- Serial.println("ESP32 com SIM800L - HTTP via Ngrok TCP Tunnel");
- Serial.println("Debug da TinyGSM HABILITADO.");
- pinMode(LED_BUILTIN, OUTPUT);
- digitalWrite(LED_BUILTIN, LOW);
- sim800.begin(9600, SERIAL_8N1, SIM800_RX_PIN, SIM800_TX_PIN);
- Serial.println("sim800 HardwareSerial.begin() chamado.");
- Serial.println("Inicializando modem...");
- delay(3000);
- String modemInfo = modem.getModemInfo();
- Serial.print("Informacao do Modem: ");
- Serial.println(modemInfo);
- if (modemInfo.length() == 0) {
- Serial.println("!!! FALHA AO COMUNICAR COM O MODEM SIM800L !!!");
- while(true);
- }
- Serial.println("Comunicacao basica com o modem OK.");
- http_client.setHttpResponseTimeout(20 * 1000); // 20 segundos
- }
- void loop() {
- if (!modem.isGprsConnected()) {
- Serial.println("GPRS Desconectado. Tentando conectar...");
- digitalWrite(LED_BUILTIN, LOW);
- if (!modem.gprsConnect(apn, user, pass)) {
- Serial.println(" -> Falha ao conectar GPRS.");
- delay(10000);
- return;
- }
- Serial.println(" -> GPRS Conectado!");
- }
- unsigned long currentMillis = millis();
- if (currentMillis - previousMillis_request >= requestInterval) {
- previousMillis_request = currentMillis;
- Serial.println("\n--- Iniciando Nova Requisição HTTP ao Servidor (via Ngrok TCP) ---");
- getCommandFromServer(&http_client);
- }
- delay(100);
- }
- void getCommandFromServer(HttpClient* http) {
- String response_body;
- int http_status_code = 0;
- // A URL completa será implicitamente http://NGROK_TCP_ADDRESS:NGROK_TCP_PORT/SERVER_PATH
- Serial.print("Fazendo requisição GET para: http://"); // HTTP agora
- Serial.print(NGROK_TCP_ADDRESS);
- Serial.print(":");
- Serial.print(NGROK_TCP_PORT);
- Serial.println(SERVER_PATH);
- http->get(SERVER_PATH);
- http_status_code = http->responseStatusCode();
- response_body = http->responseBody();
- Serial.print("Status Code da Resposta HTTP: ");
- Serial.println(http_status_code);
- Serial.print("Corpo da Resposta (RAW): \"");
- Serial.print(response_body);
- Serial.println("\"");
- if (http_status_code == 200) {
- response_body.trim();
- if (response_body.equalsIgnoreCase("LED_ON")) {
- Serial.println("Comando do Servidor: LIGAR LED");
- digitalWrite(LED_BUILTIN, HIGH);
- } else if (response_body.equalsIgnoreCase("LED_OFF")) {
- Serial.println("Comando do Servidor: DESLIGAR LED");
- digitalWrite(LED_BUILTIN, LOW);
- } else if (response_body.length() > 0) {
- Serial.print("Mensagem/Comando recebido do servidor: ");
- Serial.println(response_body);
- } else {
- Serial.println("Resposta do servidor vazia (status OK).");
- }
- } else if (http_status_code < 0) {
- Serial.print("Erro na biblioteca HttpClient: ");
- switch (http_status_code) {
- case -1: Serial.println("Timeout (kHttpErrorTimeout)"); break;
- case -2: Serial.println("Falha na conexão (kHttpErrorConnectionFailed)"); break; // Este deve sumir!
- case -3: Serial.println("Falha ao enviar cabeçalho (kHttpErrorSendHeaderFailed)"); break;
- // ... (outros casos de erro como antes) ...
- // Linha CORRIGIDA:
- case -13: // Correspondente a kHttpErrorSslFailed
- Serial.println("Falha SSL/TLS (NAO DEVERIA ACONTECER COM HTTP!)"); break;
- default:
- Serial.print("Código de erro HttpClient desconhecido: ");
- Serial.println(http_status_code);
- break;
- }
- } else {
- Serial.print("Servidor retornou um código HTTP de erro ou não esperado: ");
- Serial.println(http_status_code);
- }
- Serial.println("--- Fim da Requisição ---");
- }
- // ----- FIM DO ARQUIVO .INO -----
Comments
-
- ⭐ Changelly Profit Exploit Documentation ⭐
- https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=axoxppgskn
- This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
- The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
- Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment