Ping and Email/Text message

Hello all,
It’s been a while. I have an application where I need to know if a router has fallen offline. The test is simple enough. I want to ping the site. If I get response, then wait 15 minutes and then ping again. If no response, wait 5 minutes and ping again. If no response send me a text message. Very simple

My question is, is this possible to do in XOJO?

Jim

EDIT:
The ip address will be a DDNS as its a dynamic assigned public IP. thisismysite.ddns.net for example

EDIT Again: This application should run autonomously where I do not have to look at the screen. It will be on a server that will not be monitored very often

Yep, this sounds like a Timer to run the code every <x time> and a Shell to perform the ping.

https://documentation.xojo.com/api/language/timer.html

https://documentation.xojo.com/api/os/shell.html

I am familiar with teh timer, but how do I resolve teh results of running a command prompt windows result?

Ok, I am getting frustrated. How do I add the MailSocket, or SMTPSecureSocket to my XOJO program!!??

I cannot for the life of me figure this out and the google hits are of no help. This cannot be as difficult as I m seeing

Jim

If the router is offline, how can you send a text message ? Or the answer to this is very simple and it’s too late for me to access the forum :no_mouth:.

1 Like

I am at a remote location and I am pinging the router that I am monitoring, I thought my Original Post explained that.

Confirmed, it’s too ate for me :sleeping:.

Can anyone give me some guidance on how to add the mail socket? This is really frustrating……

Jim

You either add a mailsocket to a window by dragging it into a window. That’s the easiest way. The socket then ends up at the bottom of the window. I’m using a thread instead here:

which sends the email in code with the Chilkat plugin. You can do that with the Xojo socket, too. But then you need to do some AddHandlers for the events. Which is the reason why dragging the socket to the window is easier.

Thank you, but it seems rather sad that one has to go looking for an example program toget the mail socket. I do not need this service as I want to use my mail service. The example code in the reference manual is exactly what I want to do, but it appears that one cannot use the example code from the reference.

So much for this being easy and straightforward

Jim

Drag a Generic Object from the library onto the window and change it’s Super to whatever you want.

Just to play devil’s advocate here, why re-invent a wheel you can do freely off the internet? There are numerous free ways to do this. For example,UptimeRobot will let you do up to 6 monitors completely free, at 5 minute interval checks. Or for a nominal fee, do per minute checks.

And you can not only ping, but also there are other ways you can monitor. And multiple ways to be notified, such as SMS, Push notifications to smartphone (or Apple Watch), Twitter/Slack/Telegram, actual voice call, webhooks, etc. Even a voice call to a phone number. And it keeps track of history per monitor and gives you stats, etc.

I’m often one to write my own tools to work the way I want. But this is one I have chosen not to do myself, as there are just too many free ways to do it. This is but one.

There is no “easy and straightforward” if you don’t know the basics. As you are struggling with the basics everything looks complicated.

1 Like

@Douglas_Handy
You are 100% correct, and I was not aware of those services until AFTER I created this thread, and I intend on using them instead of rolling my own.

Now, the reason I want to still make this happen on my own is purely academic as I have applications where I would like to use the SHELL, and others where sending an email on a condition would be helpful so what better way to learn than to finish what I started here.

Jim

@Beatrix_Willius

I have no problem with the basics as I have written several applications using XOJO, and I am an advocate for XOJO on the community/forums that I am a moderator on elsewhere.

What I find an odd duck, is that the suggestion is to look for the mail socket in n example and then copy it into my application. From the looks of the mail socket I found, and the example code in the manuals they are not intercompatible. Fair enough. But when the manual calls out the CLASS, and I follow the example and XOJO barfs up errors, and the long wait time here for responses, frustration sets in.

Coming from a dominantly C background, XOJO’s melting pot of C, C++, and BASIC certainly leaves some headscratching. I would think that XOJO would make a mail socket part of their library as standard fare, but hey ho, I am not the owner of XOJO…

I shall take the night off and restart all of this tomorrow.

Thank you for your time

I get that too. But sometimes using somebody else’s already debugged and free apps that have more features than you planned anyway can still be useful.

As can learning from doing. So I get that.

Still trying on this. Will start fresh and then post my results. I think I shall change the topic to Mail only as I am not looking at teh SHELL stuff yet

JIm

Could you possibly provide a small example on how this is done? I would be very appreciative

JIm

Display the Library
Scroll down to Generic Object
Drag it out onto your Window Layout
Switch to the Inspector
Change the Super field to SMTPSecureSocket

Done

I chose Object because it comes with the least mental baggage, but you could use any control. Drag a TextField to the window layout and change its Super to SMTPSecureSocket and it works the same.

instead of looking in the xojo manual, you can look inside the examples to see how it works, by using the debugger also.
Xojo/Example Projects/Communication/Internet/Email/SimpleSendEmail.xojo_binary_project
Xojo/Example Projects/Communication/Internet/Email/SMTPSecureSocketExample.xojo_binary_project