Initial commit

This commit is contained in:
AVS
2026-06-26 16:42:07 +05:00
commit da6b107066
17 changed files with 1448 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
#include <HTTPClient.h>
#include <WiFi.h>
const char* SERVER_URL = "http://192.168.1.100:8880/send";
const char* APP_TOKEN = ""; // Set your application token here
const char* WIFI_SSID = "YourWiFiSSID";
const char* WIFI_PASSWORD = "YourWiFiPassword";
void setup() {
Serial.begin(115200);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nWiFi connected");
}
void sendTelegramMessage(const char* message) {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.begin(SERVER_URL);
http.addHeader("Content-Type", "application/json");
if (strlen(APP_TOKEN) > 0) {
http.addHeader("X-App-Token", APP_TOKEN);
}
String payload = "{\"text\":\"" + String(message) + "\"}";
int httpResponseCode = http.POST(payload);
if (httpResponseCode > 0) {
String response = http.getString();
Serial.println("HTTP Response: " + String(httpResponseCode));
Serial.println(response);
} else {
Serial.println("Error: " + String(httpResponseCode));
}
http.end();
} else {
Serial.println("WiFi not connected");
}
}
void loop() {
sendTelegramMessage("Hello from ESP32!");
delay(60000); // Send every minute
}
+30
View File
@@ -0,0 +1,30 @@
param(
[Parameter(Mandatory=$true)]
[string]$Message,
[Parameter(Mandatory=$false)]
[string]$ServerUrl = "http://localhost:8880",
[Parameter(Mandatory=$true)]
[string]$AppToken
)
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$body = @{
text = $Message
} | ConvertTo-Json -Depth 3
$headers = @{
"Content-Type" = "application/json; charset=utf-8"
"X-App-Token" = $AppToken
}
try {
$response = Invoke-RestMethod -Uri "$ServerUrl/send" -Method Post -Body ([System.Text.Encoding]::UTF8.GetBytes($body)) -Headers $headers
Write-Host "Message sent successfully. Message ID: $($response.message_id)"
exit 0
} catch {
Write-Error "Failed to send message: $_"
exit 1
}