I'm trying to upload some sensor data over LoRa to an Amazon AWS account.
I'm using a Dragino LoRa shield + Arduino UNO to read and transmit the sensor data to the LG01 gateway.
I've loaded the Python SDK and all my certificates from AWS into the Linux side of the LG01.
I can get the sensor data from the UNO+Shield to the LG01 and read this out over the console, so I know the data is getting to the LG01 from the sensor.
Separately, if I ssh into the Dragino, I can publish and subscribe to an AWS IoT topic with "made up" data using the python code in the SDK, with mosquitto_pub commands, or with a script, so that works too.
However, I can't seem to call any of these commands from my sketch using the process class.
I'm currently trying the following (which is a sample sketch just to test the Process class connections with AWS):
void mqtt_publish(){
Process p;
p.begin("/root/Test");
p.run();
// If there's output from Linux,
// send it out the Console:
while (p.available()>0)
{
char c = p.read();
Console.write(c);
}
Console.println("Sending..."); // Just to make sure the loop is running in the absence of any other feedback
}
where Test is in the root directory and is the command that worked in the Dragino ssh console:
#!/bin/sh
mosquitto_pub -h myuniquedeviceID.amazonaws.com -p 8883 -t TestTopic -m 1973 --cafile root-CA.crt --cert MyCert.cert.pem --key MyKey.private.key
I've also tried:
void mqtt_publish()
{
Process p;
p.begin("mosquitto_pub");
p.addParameter("-h");
p.addParameter("mydeviceinfofromAWS.etc..");
p.addParameter("8883");
p.addParameter("-t");
p.addParameter("TestTopic");
p.addParameter("-m");
p.addParameter("1973");
p.addParameter("--cafile");
p.addParameter("root-CA.crt");
p.addParameter("--cert");
p.addParameter("MyCert.cert.pem");
p.addParameter("--key");
p.addParameter("MyKey.private.key");
p.run();
while (p.available() > 0) {
char c = p.read();
Console.print(c);
}
Console.flush();
}
also to no avail. I also tried p.runShellCommand which didn't work either.
I've updated the Bridge library in Arduino IDE and downloaded the latest Firmware (4.3.4) to the Dragino, and I've made sure the MCU is correctly autodetected as ATMega328p and that UART Operation Mode is set to Linux Console/Arduino Bridge.
The problem seems to be in the Process/Bridge, but I can't find out where.
Any help would be appreciated. Thanks!