Blynk as service



  • Hi guys,

    I am using blynk to toggle a gpio that in return is seen by a c app that in turn grabs a copy of a image, stored by a mjpg_streamer running in the background (in /tmp that that is a ram disk - trying to avoid exceeding flash memory rd/wr lifespan) , and sends the pic via mailsend to my address as well as a pushing notification via Pushover to tell me to check my mail. (The idea is that the gpio can be triggered via blynk or a physical event like an alarm going off or someone ringing a doorbell.) I know that I could probably make this all a lot easier by making the Omega2 available from outside my network (and using PHP via a browser do it all), I've seen a few guys talking about that and quite a few warned about the security aspect of doing that.

    So, this way, as convoluted as it is, I can get to the Omega without altering my router or anything.

    I am an procedural programming dabbler (C in fact on old style 8051's) so writing OOP in C++ or JS or whatever is like rocket science to a burger flipper. Oop is on my bucket list but low on the priority scale.

    This is just a way I figured to make it work.

    And it does.

    The issue I'm having is with blynk. I can get it working fine. I launch blynk (ON-OFF) on an Omega2 with the test CLI command as per Onion's documentation
    node /usr/bin/blynk-library/bin/blynk-client.js <my Token>
    I then push it into the background with a Ctrl-Z followed by a bg command on the ssh session. I have a simple sketch to toggle a gpio from my iPhone, and, it works great. However, after a day or so, blynk is not running anymore.

    HOW do I keep it running or relaunch it if it is not? AND, how could I find out why blink is dying? WHAT is the best way to launch blynk sort of like a deamon?
    I could pull some convoluted shit, but would prefer not to, by getting my C prog to launch something like a
    system("top | grep blynk > running.txt")
    every now and then in the main loop, opening and examining that file and if it finds blynk not running, launch it again with something like a
    system("node /usr/bin/blynk-library/bin/blynk-client.js <my Token>")

    I had a look at blynk-client.js but, being a procedural programmer, I am unable to find the main loop so not sure what I can do there. Nor do I know if the blynk library has amIRunning() and reLaunch() type of functionality. And the Onion Omega specific help on the Blynk site is non existent. It seems also that there is a C++ lib but (apparently) for the Omega. I do have a cross compiler setup in Docker thanks to the very helpful @José-Luis-Cánovas but obviously that would need a rebuild with a blynk library for C/C++ if that is available.

    Have any of you guys done something like this or worked with the blynk library or have some insights or some way to modify the blynk-client.js to take care of it automatically. "C'mon mister, spare a poor beggar a bit of info."



Looks like your connection to Onion Community was lost, please wait while we try to reconnect.