Go Down

Topic: Yun to run with or without WiFi (Read 281 times) previous topic - next topic

SherpaDoug

I have a small Yun based mobile robot that only uses the Linux side for wireless reprogramming and the default Bridge & Console functions to telemeter serial data out.  All works well as long as I connect to the Yun with my browser at 10.0.0.176.

The problem is that most of the time the robot will have to run without WiFi.  How do I get the Yun to run with WiFi if it is available but without if it is not.  I have Bridge.begin(); and Console.begin(); in setup().  Should I make those lines conditional on some WiFi detection?

ShapeShifter

Many example sketches have this sort of construct at the beginning:

Code: [Select]
  Bridge.begin();
  Console.begin();

  while (!Console) {
    ; // wait for Console port to connect.
  }


The first line sets up communications between your sketch and the Linux system, the second allows you to connect for console communications. Neither of them require a network connection (although they are more useful with one.) These should not be causing you problems.

Many people are tripped up by the next section: it causes your sketch to block and wait for a connection from your computer, and will do nothing else until that happens. It's a useful construct during early development and debugging as it lets you see ALL of the output and not miss any startup messages before you have a chance to connect. But it means that you must always make a connection before your sketch will do anything useful.

If you have that loop to wait for a connection, take it out.

SherpaDoug

Actually I found it does run without WiFi.  It just takes a surprisingly long time.  The 32U4 processor gets power and Reset immediately but it doesn't seem to start running the sketch for about 60 seconds.  Must be something to do with the bootloader.

ShapeShifter

It takes about 60 seconds or so for the Linux portion to boot up, that's just the nature of Linux. While your sketch starts immediately, the Bridge.begin() call establishes communications with Linux, and that can't happen until Linux is ready, so it waits.

Go Up