you said you wanted to ping your Ip, that would indicate doing it from outside.
reverse it ?
have the router message you every X minutes as long as there's power, if there's no message within the regular time slot, you either have no power, or your ISP is having issues.
but there should be a service online, providing this kind of basic monitoring for free.
perhaps not reporting via telegram though.
i have the script for windows, so now i need to run it on linux? and i can`t find any answers how i need to run the program on router, how i can add it to router system, maybe you can recommend some resources where people explain how to do it
thanks for ther script, but i have one, i need to make it work on router.Maybe i`m a bad explainer but i have my application on wondows, what i need to do to run it on router?
#include<iostream>
#include <stdio.h>
#include <tgbot/tgbot.h>
using namespace std;
using namespace TgBot;
int main() {
Bot bot("6010182175:AAHQy3qPN-Erg0W0wvLKEX1Ook2fWbbhhjo");
bot.getEvents().onCommand("start", [&bot](Message::Ptr message) {
bot.getApi().sendMessage(message->chat->id, "Hi!");
});
bot.getEvents().onAnyMessage([&bot](Message::Ptr message) {
printf("User wrote %s\n", message->text.c_str());
cout << "lf" << endl;
bool check = false;
while (true) {
int x = system("ping 91.196.148.96");
if (x == 0) {
if (check == false) {
check = true;
bot.getApi().sendMessage(message->chat->id, "light");
}
}
else {
if (check == true) {
check = false;
bot.getApi().sendMessage(message->chat->id, "no light");
}
}
Sleep(5000);
}
});
try {
printf("Bot username: %s\n", bot.getApi().getMe()->username.c_str());
TgLongPoll longPoll(bot);
while (true) {
printf("Long poll started\n");
longPoll.start();
}
}
catch (TgException& e) {
printf("error: %s\n", e.what());
}
return 0;
}
yeah, i read them before asking, but some errors appeared whick i can`t solve. For me it will be better to run my C code. So i tried to undesrand what i need to make it work. I tried to follow that https://openwrt.org/docs/guide-developer/helloworld/start instructions, but in the very beginning some packages give error(i can provide screens if you need?).
I am a complete begginer in linux, but have some experience with c++, so write my code using it. The main problem is to understand what am i supposed to do next. I just need to ping the ip address every n seconds, but i don`t know work it or not if i have no electricity at home, because earlier i just run all the code in sandbox(just in a visualstudio compiler)
exactly, every n hours a day i have electricity restrictions. That`s why i need to check if i have light at home or no. And the main problem that nothing working at that time, the same result if you pull your pc and router from the socket
I have xiaomi mi 4a gigabit version. Sorry for being stupid, but i just dont know work it or not if there is no electricity for that devices. For example, if i run the code on router but then the electricity turn off, the program continue to happen and send messages on telegram or no?