Hi there,
I’m trying to get a script to run on my Pi that will control the universal remote functions I’ve programmed.
My script is located:
/home/pi/scripts/change-source.sh
Contents:
irsend SEND_ONCE Samsung_BN59-01175N KEY_CHANNELUP
sleep 2.5
irsend SEND_ONCE Samsung_BN59-01175N KEY_MODE
sleep 2
irsend SEND_ONCE Samsung_BN59-01175N KEY_RIGHT
sleep 0.5
irsend SEND_ONCE Samsung_BN59-01175N KEY_RIGHT
sleep 0.5
irsend SEND_ONCE Samsung_BN59-01175N KEY_RIGHT
sleep 1
irsend SEND_ONCE Samsung_BN59-01175N KEY_ENTER
sleep 0.5
exit
(I also have a Python version available)
It wouldn’t be easy to script all of this in Particle, hence wanting the trigger the script to run from the Pi itself.
So far I have put together this from various other posts:
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include "Particle.h"
void doCall(String arguments){
Particle.publish(arguments);
Process proc = Process::run(arguments);
proc.wait();
while (!proc.exited()) {
delay(10);
}
Particle.publish(String("exit_code ")+String(proc.exitCode()));
delay(10);
}
void stdoutEventHandler(const char *event, const char *data){
//Particle.publish("changesourcepi");
String arguments {data};
String command {"/home/pi/scripts/change-source.sh"};
String command_and_arguments{command +arguments};
//Particle.publish(command_and_arguments);
doCall(command_and_arguments);
}
void setup() {
Particle.subscribe("changesourcepi", stdoutEventHandler);
Particle.publish("changesourcepi");
}
void loop() {
}
It flashes to the Pi fine. However, when I try to trigger through IFTTT nothing happens on my Pi.
Could someone point me in the right direction as to what I could be missing out?