that_one_nigga_you_k

controle do led pelo 2g

Jun 2nd, 2025
71
0
Never
7
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.44 KB | None | 0 0
  1. // ----- INÍCIO DO ARQUIVO .INO -----
  2.  
  3. // Habilita o debug detalhado da biblioteca TinyGSM.
  4. #define TINY_GSM_DEBUG Serial
  5.  
  6. // Define o modem que você está usando
  7. #define TINY_GSM_MODEM_SIM800
  8.  
  9. #include <TinyGsmClient.h> // Usaremos o cliente GSM normal para HTTP
  10. #include <ArduinoHttpClient.h>
  11.  
  12. // --- Pinos para SIM800L (UART2 do ESP32) ---
  13. #define SIM800_RX_PIN 16 // Conecte este pino do ESP32 ao pino TX do SIM800L
  14. #define SIM800_TX_PIN 17 // Conecte este pino do ESP32 ao pino RX do SIM800L
  15. HardwareSerial sim800(2); // Usando a UART2 do ESP32
  16.  
  17. // --- Pino do LED Embutido ---
  18. #ifndef LED_BUILTIN
  19.   #define LED_BUILTIN 4
  20. #endif
  21.  
  22. // --- Configurações do Seu Servidor (via Ngrok TCP Tunnel) ---
  23. // !! SUBSTITUA PELO ENDEREÇO E PORTA FORNECIDOS PELO SEU NGROK TCP TUNNEL !!
  24. const char NGROK_TCP_ADDRESS[] = "0.tcp.sa.ngrok.io"; // Exemplo, substitua pelo seu
  25. const int NGROK_TCP_PORT       = 13469;          // Exemplo, substitua pela sua porta
  26.  
  27. const String SERVER_PATH       = "/"; // O ESP32 vai buscar o comando nesta rota
  28.  
  29. // --- Configurações do APN da Claro ---
  30. char apn[]  = "claro.com.br";
  31. char user[] = "claro";
  32. char pass[] = "claro";
  33.  
  34. // --- Objetos das Bibliotecas ---
  35. TinyGsm modem(sim800);
  36. // Cliente GSM normal para HTTP (não seguro, pois o túnel TCP não envolve SSL aqui)
  37. TinyGsmClient gsm_client_modem(modem);
  38. // HttpClient usará o cliente GSM normal e a porta TCP do Ngrok
  39. HttpClient http_client = HttpClient(gsm_client_modem, NGROK_TCP_ADDRESS, NGROK_TCP_PORT);
  40.  
  41. // --- Controle de Tempo para Polling ---
  42. unsigned long previousMillis_request = 0;
  43. long requestInterval = 3000; // Intervalo entre requisições (15 segundos)
  44.  
  45. void setup() {
  46.   Serial.begin(115200);
  47.   delay(1000);
  48.   Serial.println("Monitor Serial INICIADO!");
  49.   Serial.println("ESP32 com SIM800L - HTTP via Ngrok TCP Tunnel");
  50.   Serial.println("Debug da TinyGSM HABILITADO.");
  51.  
  52.   pinMode(LED_BUILTIN, OUTPUT);
  53.   digitalWrite(LED_BUILTIN, LOW);
  54.  
  55.   sim800.begin(9600, SERIAL_8N1, SIM800_RX_PIN, SIM800_TX_PIN);
  56.   Serial.println("sim800 HardwareSerial.begin() chamado.");
  57.  
  58.   Serial.println("Inicializando modem...");
  59.   delay(3000);
  60.  
  61.   String modemInfo = modem.getModemInfo();
  62.   Serial.print("Informacao do Modem: ");
  63.   Serial.println(modemInfo);
  64.  
  65.   if (modemInfo.length() == 0) {
  66.     Serial.println("!!! FALHA AO COMUNICAR COM O MODEM SIM800L !!!");
  67.     while(true);
  68.   }
  69.   Serial.println("Comunicacao basica com o modem OK.");
  70.  
  71.   http_client.setHttpResponseTimeout(20 * 1000); // 20 segundos
  72. }
  73.  
  74. void loop() {
  75.   if (!modem.isGprsConnected()) {
  76.     Serial.println("GPRS Desconectado. Tentando conectar...");
  77.     digitalWrite(LED_BUILTIN, LOW);
  78.     if (!modem.gprsConnect(apn, user, pass)) {
  79.       Serial.println(" -> Falha ao conectar GPRS.");
  80.       delay(10000);
  81.       return;
  82.     }
  83.     Serial.println(" -> GPRS Conectado!");
  84.   }
  85.  
  86.   unsigned long currentMillis = millis();
  87.   if (currentMillis - previousMillis_request >= requestInterval) {
  88.     previousMillis_request = currentMillis;
  89.     Serial.println("\n--- Iniciando Nova Requisição HTTP ao Servidor (via Ngrok TCP) ---");
  90.     getCommandFromServer(&http_client);
  91.   }
  92.   delay(100);
  93. }
  94.  
  95. void getCommandFromServer(HttpClient* http) {
  96.   String response_body;
  97.   int http_status_code = 0;
  98.  
  99.   // A URL completa será implicitamente http://NGROK_TCP_ADDRESS:NGROK_TCP_PORT/SERVER_PATH
  100.   Serial.print("Fazendo requisição GET para: http://"); // HTTP agora
  101.   Serial.print(NGROK_TCP_ADDRESS);
  102.   Serial.print(":");
  103.   Serial.print(NGROK_TCP_PORT);
  104.   Serial.println(SERVER_PATH);
  105.  
  106.   http->get(SERVER_PATH);
  107.  
  108.   http_status_code = http->responseStatusCode();
  109.   response_body = http->responseBody();
  110.  
  111.   Serial.print("Status Code da Resposta HTTP: ");
  112.   Serial.println(http_status_code);
  113.   Serial.print("Corpo da Resposta (RAW): \"");
  114.   Serial.print(response_body);
  115.   Serial.println("\"");
  116.  
  117.   if (http_status_code == 200) {
  118.     response_body.trim();
  119.     if (response_body.equalsIgnoreCase("LED_ON")) {
  120.       Serial.println("Comando do Servidor: LIGAR LED");
  121.       digitalWrite(LED_BUILTIN, HIGH);
  122.     } else if (response_body.equalsIgnoreCase("LED_OFF")) {
  123.       Serial.println("Comando do Servidor: DESLIGAR LED");
  124.       digitalWrite(LED_BUILTIN, LOW);
  125.     } else if (response_body.length() > 0) {
  126.       Serial.print("Mensagem/Comando recebido do servidor: ");
  127.       Serial.println(response_body);
  128.     } else {
  129.       Serial.println("Resposta do servidor vazia (status OK).");
  130.     }
  131.   } else if (http_status_code < 0) {
  132.     Serial.print("Erro na biblioteca HttpClient: ");
  133.     switch (http_status_code) {
  134.       case -1: Serial.println("Timeout (kHttpErrorTimeout)"); break;
  135.       case -2: Serial.println("Falha na conexão (kHttpErrorConnectionFailed)"); break; // Este deve sumir!
  136.       case -3: Serial.println("Falha ao enviar cabeçalho (kHttpErrorSendHeaderFailed)"); break;
  137.       // ... (outros casos de erro como antes) ...
  138.       // Linha CORRIGIDA:
  139.       case -13: // Correspondente a kHttpErrorSslFailed
  140.         Serial.println("Falha SSL/TLS (NAO DEVERIA ACONTECER COM HTTP!)"); break;
  141.       default:
  142.         Serial.print("Código de erro HttpClient desconhecido: ");
  143.         Serial.println(http_status_code);
  144.         break;
  145.     }
  146.   } else {
  147.     Serial.print("Servidor retornou um código HTTP de erro ou não esperado: ");
  148.     Serial.println(http_status_code);
  149.   }
  150.  
  151.   Serial.println("--- Fim da Requisição ---");
  152. }
  153. // ----- FIM DO ARQUIVO .INO -----
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Appimdu
    30 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. 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.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
  • Voqunum
    9 days
    # CSS 0.45 KB | 0 0
    1. ⭐ Changelly Profit Exploit Documentation ⭐
    2.  
    3. https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=axoxppgskn
    4.  
    5. 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.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment