I'm going to buy an arduino yun, and I've been learning a little bit about it but I've got a doubt. Is it possible to upload an sketch to arduino yun through the internet? I read that is possible through the wifi but I'm not sure if there's another way (even if it is not official) to do that.
I'm interested in this as well, for a slightly different reason.
I have a WiFi access point (not part of a router) that is connected to my Ethernet wired network. With the Yun on the wireless, and my laptop on the wired (they are the same network number) I cannot upload wirelessly, nor access the console through the serial monitor. If I connect the laptop through the wireless (or the Yun on the wired) then it works.
When the Yun and laptop aren't on the same physical medium (although it's the same network number) the Yun doesn't show up on the Arduino IDE port list. If I put the on the same medium, it shows up. If I put the laptop back on the wired, the Yun still shows up on the port list, but as soon as I try to access it (serial monitor or upload sketch) there is an error, and the Yun once again disappears from the port list. However, I can access web pages from the Yun, or even SSH to it, even when one is on wireless and the other on wired, so the basic connectivity is there.
It's as if there is some kind of broadcast packet needed for the IDE to recognize the Yun that isn't being passed by my WiFi access point. I would assume that this would also be a problem going over the Internet.
Is there some work-around for this? What does the IDE need to see to recognize the Yun?
In fact, I don't understand why arduino yun has the functionality of uploading sketches over wifi and it hasn't got the functionality of uploading over the internet. At the end of the day it is only to search for the ip address and stablish a connection as a private network.
ShapeShifter:
It's as if there is some kind of broadcast packet needed for the IDE to recognize the Yun that isn't being passed by my WiFi access point. I would assume that this would also be a problem going over the Internet.
Indeed that's what happens: a broadcast message is sent by the yun on all the networks it's attached to. It's called zeroconf although the name Bonjour (the Apple implementation) is more known
gcp900:
In fact, I don't understand why arduino yun has the functionality of uploading sketches over wifi and it hasn't got the functionality of uploading over the internet. At the end of the day it is only to search for the ip address and stablish a connection as a private network.
If you can manage to access yun's webpanel from outside, and if you're running the latest version of openwrt-yun, you can upload a precompiled sketch via web.
Locate and save the compiled .hex file, go the yun's webpanel, scroll down until you find the upload button, select the .hex file and upload it.
If you wish to do that via IDE, please consider contributing to the Arduino IDE project
Good to know about the ability to upload sketches via the web GUI. Is there a similar way to access the console (SSH via a particular port?)
[quote author=Federico Fissore link=topic=269923.msg1903369#msg1903369 date=1412153981]Indeed that's what happens: a broadcast message is sent by the yun on all the networks it's attached to. It's called zeroconf although the name Bonjour (the Apple implementation) is more known
[/quote]
Interesting. My current work project is adding WiFi to an industrial machine, and that uses mDNS/Bonjour for name resolution. I'm pretty sure I can access that by name through my network access point. Perhaps it's letting the name query packets through, but not the service advertisements? (Probably not using the proper terms there.)
What could be interesting is the ability to manually specify an address (and port?) of the Yun. The port would be useful if you had multiple Yuns behind a firewall: you could open a port forward for each to reach the respective Yun. Even better would be the ability to pre-configure a list of such definitions, which would then appear on the port list, and allow you to easily switch between distant Yuns. (Of course, this would be an advanced feature, and might not fit within the ease-of-use expectations of Arduino.)
If only I had the time to work on it... (Maybe some day...)
ShapeShifter:
What could be interesting is the ability to manually specify an address (and port?) of the Yun. The port would be useful if you had multiple Yuns behind a firewall: you could open a port forward for each to reach the respective Yun. Even better would be the ability to pre-configure a list of such definitions, which would then appear on the port list, and allow you to easily switch between distant Yuns. (Of course, this would be an advanced feature, and might not fit within the ease-of-use expectations of Arduino.)
You can change the .service file: it's located at /etc/avahi/services/arduino.service on your yun
Good to know. However, what I meant was that in the IDE, if we had the ability to manually specify the address of a Yun (so that it can be accessed over the internet or through a router) it would be nice if we could also specify a port number so it can be mapped to different Yuns behind a firewall.
Suppose you have three Yuns, with addresses 192.168.1.100 to 192.168.1.102, these port forwards could be set up (with no need to change the port number on the Yun):
port 8080 --> 192.168.1.100:80
port 8081 --> 192.168.1.101:80
port 8082 --> 192.168.1.102:80
I'm just thinking out loud... if we're talking about features that would be nice to have in the IDE, might as well think the problem through to make sure it covers useful scenarios.
[quote author=Federico Fissore link=topic=269923.msg1904746#msg1904746 date=1412233748]You can change the .service file: it's located at /etc/avahi/services/arduino.service on your yun
Good to know. However, what I meant was that in the IDE, if we had the ability to manually specify the address of a Yun (so that it can be accessed over the internet or through a router) it would be nice if we could also specify a port number so it can be mapped to different Yuns behind a firewall.
Suppose you have three Yuns, with addresses 192.168.1.100 to 192.168.1.102, these port forwards could be set up (with no need to change the port number on the Yun):
port 8080 --> 192.168.1.100:80
port 8081 --> 192.168.1.101:80
port 8082 --> 192.168.1.102:80
I'm just thinking out loud... if we're talking about features that would be nice to have in the IDE, might as well think the problem through to make sure it covers useful scenarios.
[/quote]That would be a functionality of your firewall and has nothing to do directly with the Arduino Yun or the IDE...
PCWorxLA:
That would be a functionality of your firewall and has nothing to do directly with the Arduino Yun or the IDE...
Yes, of course setting up port forwards is strictly a function of the firewall. But both you and Federico seem to be missing my point. Right now, the only way that the IDE can connect to a Yun over the network, to upload sketches or open the serial monitor to the console, is if the IDE receives a broadcast message from the Yun. This doesn't work if the Yun is behind some device that doesn't pass the broadcasts (like my access point) or if it is behind a router/firewall (as in the OP's case where he wants to access the Yun from the Internet.)
If, in addition to the current automatic method, the IDE had the ability to manually specify the IP address of a Yun (and if the appropriate port forwards were set up) then it would be possible to access a Yun from anywhere, not just the local network segment. Now, if in addition to the IP address, we could also specify the remote Yun's port number in the IDE, then there could be multiple Yuns on that remote network, and the port forward rules in the remote router would know how to dispatch incoming connections to the correct Yun.
Yes, this requires setting up some port forwards in the router, and no, it doesn't require changing the port on the Yun itself. But it's all a moot point without the ability to manually specify an IP address (whether it includes a port or not.) My only point is if we are discussing a possible future feature, why not think it through and make it as useful as possible?
PCWorxLA:
That would be a functionality of your firewall and has nothing to do directly with the Arduino Yun or the IDE...
Yes, of course setting up port forwards is strictly a function of the firewall. But both you and Federico seem to be missing my point. Right now, the only way that the IDE can connect to a Yun over the network, to upload sketches or open the serial monitor to the console, is if the IDE receives a broadcast message from the Yun. This doesn't work if the Yun is behind some device that doesn't pass the broadcasts (like my access point) or if it is behind a router/firewall (as in the OP's case where he wants to access the Yun from the Internet.
Broadcasts are by design/rule/RFC not passing beyond (private) subnets.
And just think about the security implication of having the programming interface/capability of your Yun open to the Wide Weird Web. This is just a disaster waiting to happen.
If you reallyneed the capability to program your Yun from outside it's local subnet, set up a VPN connection (IPSec or OpenVPN) to your perimeter firewall and connect that way.
Not everything that at a first glance looks a great idea in fact is one...
PCWorxLA:
Not everything that at a first glance looks a great idea in fact is one...
Which is why it's good to understand the problem statement and proposed solutions, discuss it, and work out details and potential issues before any changes are made. Thank you for participating. (Hmm... that sounds a bit condescending; it absolutely isn't meant to be.)
In my case, where a device is blocking broadcasts between two segments of the same private network, it might make some sense since a VPN wouldn't work there. But that's a rather unusual isolated case. The broader situation where such a feature might be used is to gain access from the public Internet, as in the OP's case, and you bring up a very valid point why that could be a bad idea. So overall, the idea may do more harm than good.
For remote installations, it is not practical to access the Yun webpage as it is likely behind a firewall as was discussed earlier. A better solution is for the Yun to connect to a website, see if there is an updated sketch waiting and if so, download the new sketch and then install it. What is needed is the Linux commands to upload a .hex file (and bootloader?) to the AVR and then cause it to reboot. The AVR can initiate the process over the bridge.
tcrussell:
What is needed is the Linux commands to upload a .hex file (and bootloader?) to the AVR and then cause it to reboot. The AVR can initiate the process over the bridge.