Go Down

Topic: Arduino-Yun Wifi - Internet Commands? (Read 7321 times) previous topic - next topic

ShapeShifter

I've not used the Console much, I usually use the USB port for debug messages during development, and then I don't use any type of serial stream communications once the project is finished.

The few times I used the Console class, I did nothing special with a network configuration: I just selected the Yun's network address in the Port menu, and opened the Serial Monitor. I've read where you have to do some extra effort to use a standard Telnet client to connect with the Console class, but that shouldn't be necessary when using the Arduino IDE's Serial Monitor window. Of course, my experience is with an official Arduino Yun board - there are some subtle and no so subtle differences introduced by Dragino in their Yun Shield, and this may be different for you.

I agree, port forwarding should only be necessary for connections coming in from the WAN (Internet) to your LAN (local network), it should not be necessary for a LAN to LAN connection. Assuming your Yun Shield and your computer are connected to the same logical network, your router should not be involved in any communications between your Yun Shield and computer, it's only involvement is to assign IP addresses to them.

Now, if your Yun Shield is connected by WiFi, and your computer is on wired Ethernet, and those are two logically distinct networks that must pass through your router, then you may have to set up some special routing rules. But that would be an unusual setup, and is not the way that most home networks are configured.

stgeorge

So finally got it working properly- interestingly, here is where I found the problem- this line:


 p.addParameter("\"devid=vBECBF1F4A7D765\"");


The curl command I have been trying to execute is:

curl -d "devid=vBECBF1F4A7D765" http://api.pushingbox.com/pushingbox/

and my runCurl(); loop had previously been:

Code: [Select]
void runCurl() {

 Process p;           
 p.begin("curl");
 p.addParameter("-d");
 p.addParameter("\"devid=vBECBF1F4A7D765\"");
 p.addParameter("http://api.pushingbox.com/pushingbox/");
 p.run();
 while (p.available()>0)
 {
   char c = p.read();
   Console.print(c);
 }
}


...which wasn't working.  After many, many experiments, I finally figured out that all I needed to do was literally have the devid in quotes.

Now it works beautifully...

Here is the final version which works...

Code: [Select]
void runCurl() {

 Process p;           
 p.begin("curl");
 p.addParameter("-d");
 p.addParameter("devid=vBECBF1F4A7D765");
 p.addParameter("http://api.pushingbox.com/pushingbox/");
 p.run();
 while (p.available()>0)
 {
   char c = p.read();
   Console.print(c);
 }
}

ShapeShifter

Now it works beautifully...
CONGRATULATIONS!  It's been a long hard battle...

Interesting that it doesn't actually need the double quote character in the parameter string. I guess it had problems passing it through properly? So, I suppose the curl command would also work from the SSH command line without the quotes around the devid string? I wonder why they suggested using them in the first place?

stgeorge

Thanks.  I'm guessing that the pushingbox website may be a bit overrated, but I'm grateful for the service they provide because it is a very inexpensive way to push notification out to me through this Arduino.

stgeorge

Anyone have experience working with Console ascii table?

It's so strange- my little runCurl(); loop is working well, but as soon as I add the console to it to try to see the output from the MCU, I can't get any activity to show up in the monitor.

I can see that it's communicating with my Arduino because firstly, I see that the read/transmit lights are lit up and secondly, the base program doesn't start up until I open the Console (aka Serial Monitor), and then it works correctly, but nothing pops up in the console monitor. 

Here is the current language for my loop:

Code: [Select]
void runCurl() {

 Process p;           
 p.begin("curl");
 p.addParameter("-d");
 p.addParameter("devid=vBECBF1F4A7D765");
 p.addParameter("http://api.pushingbox.com/pushingbox/");
 p.run();
 while (p.available()>0)
 {
   char c = p.read();
   Console.print(c);
 }
}


And yes, I've properly included the console, and started the bridge and console ahead of my while statement- all just like I do in either the Cosole Read example sketch or the Console ASCII Table print, both of which work and show up in the console correctly, but this process doesn't show anything.  Is it possible that there's nothing showing up that it can print out?

ShapeShifter

Is it possible that there's nothing showing up that it can print out?
I suppose it's possible. It's also possible p.run() isn't returning?

Easy way to tell is the add some additional messages, just for testing:

Code: [Select]
void runCurl() {

 Process p;          

 Console.println("Calling curl");

 p.begin("curl");
 p.addParameter("-d");
 p.addParameter("devid=vBECBF1F4A7D765");
 p.addParameter("http://api.pushingbox.com/pushingbox/");
 p.run();

 Console.println("Start of output:");

 while (p.available()>0)
 {
   char c = p.read();
   Console.print(c);
 }

 Console.println("End of output");
}


This way, you should at least see something...

Go Up