7 Replies Latest reply on Sep 11, 2015 3:24 PM by Intel_Peter

    Edison on Arduino Carrier, no Static IP Address after using

    GBlake

      Folks,

       

      Searching, and posting this question in the Arduino and Sparkfun Q&A forums hasn't turned up an answer yet.

       

      I have brand new Edison-on-Arduino, that has been freshly configured with the latest image (I forget the image name/number (ww05-15...) but I did it a couple of nights ago).

       

      I am using a freshly installed instance of the Arduino 1.6.3 IDE, with the Edison selected as the target, in a Windows 7 computer.

       

      I am using that1.6.3 IDE and the WiFi library that came with it, to write "Arduino" software that gets downloaded into the Edison.

       

      I want to assign a static WiFi IP address to my Edison, so I tried using the library's WiFi.config() before (and after) invoking the library's WiFi.begin(), in order to assign a static IP address to the Edison's built-in BroadCom WiFi stuff.

       

      It didn't work. The Edison is always assigned/accepts an address different from the one I specify using the config() routine.

       

      Is this a known shortcoming of the WiFi library's ability to configure the Edison module?, or of the Edison module's ability to carry out the WiFi library's instructions?,

       

      Gblake

      PS: Please don't reflexively suggest I post the code, or start guessing that I might have an oddly configured router, or etc. unless you *know* that other people are able to use the WiFi library's routines to assign a static WiFi address to an Edison. Before doing any more guessing, I first want to know if the library behavior matches the library's documentation, when it is used with the Edison version of an Arduino... Know what I mean? Thanks!

        • 1. Re: Edison on Arduino Carrier, no Static IP Address after using
          Intel_Peter

          Hello Gblake,

           

          First of all, I'd suggest you to try the new 2.1 release image that was launched just yesterday, you can get it in IoT - Intel® Edison Download | Intel® Developer Zone.

          Now, I read in your post that you are using the Arduino IDE 1.6.3, however the latest version supported by Intel is the version 1.6.0 that you can get in IoT - Downloads | Intel® Developer Zone. This version was modified by Intel to be compatible with the Galileo and Edison boards. This means is that the libraries included in the Intel’s version of the Arduino IDE are different and specifically made to work with Galileo and Edison.

          If you take the time and check both Wi-Fi libraries (Arduino official and Intel’s version) you'll find big differences between the two. I'd suggest you to try with Intel's version of the Arduino IDE.

           

          Peter.

          • 2. Re: Edison on Arduino Carrier, no Static IP Address after using
            GBlake

            Peter,

             

            Thanks!  And ...

             

            Do you know if any of the big differences in Arduino IDE library behavior are documented?  Undocumented differences ain't a good thing.  Following the Set-up instructions published by Intel and/or Ardunio, I don't recall seeing any admonitions to stay away from the latest release of the IDE or its libraries.

             

            Give or take a few bug fixes, libraries that aren't separated by major revisions should behave the same, and certainly should match their published documentation (give or take a few release notes).  Hunting and pecking to hope some magic combination of Edison images, library versions, and IDE versions would solve this or some future problem is exactly what I (and thousands of other potential users) don't want to do.

             

            Ok ... I realize I am on a soapbaox, shooting the messenger.  Thanks for the suggestions.

             

            Regardless, I remain curious whether the WiFi library bundled with the Arduino IDE 1.6.3, fulfills the claims made for it on the Arduino website, when that library is used with an Edison running a WW05-15 image from a few days ago.

             

            Is anyone from Intel or Arduino able to give me an official answer?  Please?

            • 3. Re: Edison on Arduino Carrier, no Static IP Address after using
              Intel_Peter

              Hello Gblake,

               

              The difference between the libraries is due to the differences on the boards. I mean, the Arduino boards (most of them) are design to use a shield in order to have Wi-Fi capabilities, while the Galileo and Edison boards work in a different manner. The Galileo uses a PCI-E card and the Edison has an on-board Wi-Fi antenna. The main difference between an Arduino and the Edison is that the Edison manages these kinds of commands (Wi-Fi, Bluetooth, etc...) through its internal Linux therefore the difference in the libraries.

              Actually I checked the Arduino IDE 1.6.3 (and 1.6.4) and the Galileo and Edison are not even included on the boards (under the tools tab). I'd suggest you to try with the Intel's version that you can find in IoT - Intel® Edison Download | Intel® Developer Zone.


              Peter.

              • 4. Re: Edison on Arduino Carrier, no Static IP Address after using
                GBlake

                Well, we both know that in complicated web sites and documentation, inconsistencies can creep in, but ...

                • On this Arduino site page Arduino - IntelEdison
                • This sentence appears near the bottom "The Intel Edison can be programmed with this special version of the Arduino software. It's possible to make requests of the Linux kernel with system() calls.".
                • Following the link embedded in that sentence takes you to this page, Arduino - Software where you are invited to download version 4 of the 1.6 release of the Arduino IDE.

                Obviously the version number has crept up by one since I posted my original question, but users following that path certainly aren't directed to use version 1.6.0.

                 

                Also, you are correct that the Intel Edison isn't initially displayed under the IDE 1.6.3 Tools->Boards dropdown.  That is because in the 1.6.X versions, the IDE includes a "Boards Manager" (in the Tools->Boards submenu)  that you use to invoke support for the Intel Edison.  That is what I did.  Did you think I was imagining that I had used the 1.6.3 IDE to write, compile, and run/test WiFi software?  ;-)

                 

                Also, I realize you don't know me personally, but at the level we are discussing them, I understand the differences between an Atmel-based Arduino board and the Edison-Arduino board.  Those differences are not what I asked about.

                 

                Just for grins, I followed the link in your message to the IoT - Intel® Edison Download | Intel® Developer Zone .  What I found appeared to be a higgledy-piggedly tangle of material, not a clear, concise, unified description of what the IoT approach offers/does/has.

                 

                For what I could gather, if I decide to use the IoT... method, I am expected to use Eclipse to write code for a Yocoto Linux environment.  I don't want to do that now.  To be perfectly clear, let me add this amplifying statement: I am able to do that now; but I don't want to that now. I am trying to preserve a collection of code developed to run in the purposefully-simple runtime environment the Arduino R3 and Arduino Ethernet boards expose.   I want to add Arduino-Edison WiFi communication to some of that existing code.

                 

                Intel has said that they want to convince Arduino users, to become Arduino-Edison users; and to that end, they and the rest of the Arduino community have invested in modifying the Arduino IDE and libraries, and in creating a runtime environment in the Edison, so that code that works on other Arduino versions (and works with some shields) will work correctly in/on an Arduino-Edison.

                 

                So, Intel_Peter, I sincerely appreciate the intent to be helpful (I really do), but you are missing the target.  Encouraging me to sink an unbounded amount of time into learning a bunch of new APIs and their quirks, refreshing my Linux skills, (re)learning Eclipse (for this target), and rewriting a bunch of my code, in hopes of *maybe* experiencing different WiFi results, just doesn't answer the question.

                 

                Sheesh - How hard can it be to get someone from Intel and/or Arduino to simply state whether the library I am using does/doesn't match its documentation when used in the configuration I described?  and, if it doesn't match the documentation, to say whether any version of that library (plus other stuff) does?

                 

                Answer: Apparently it's harder than I expected it would be. ;-)

                 

                GBlake

                 

                PS:

                To remove all doubt (OK, you can never remove all, but almost all) that my home router is refusing to let the Edison have the IP address put into the WiFi.config() call, I just was able to have the router allow my home PC to request using that same static IP address.  That worked fine.  Using that static IP, the PC can communicate with local devices and the rest of the world just fine.

                 

                I also tried running the WiFi.config() demo code (after customizing the SSID and Password in that program with my home network's values).  I cut-and-pasted it from the relevant Arduino web site reference page.  In my configuration, that demo code failed to obtain the/a Static IP address. 

                 

                So, I'm back to (still) wondering what the official status is for that function. Have I done something wrong when setting up my Edison?  If some chunk of code needs to change, is there a formal bug report open for the appropriate software/firmware?  If a backlevel version of some piece of code would give me a work-around, where can I find that code (and a description of the differences between that version and the later versions of it)?

                • 5. Re: Edison on Arduino Carrier, no Static IP Address after using
                  GBlake

                  After a false start and some some digging, I found that when you use the 1.6.4 Arduino IDE's "Boards Manager" to install the "Core" for the Intel Edison, the WiFi library that gets installed and compiled is here on my Windows 7 PC:

                  C:\Users\GB\AppData\Roaming\Arduino15\packages\Intel\hardware\i686\1.6.2+1.0\libraries\WiFi\src\


                  Digging into that 1.6.2+1.0 version of the Wifi code I found the WiFi.config() and WiFi.begin() routines with the signatures I am invoking.


                  void WiFiClass::config(IPAddress local_ip)
                  {
                    _local_ip = local_ip;
                    trace_debug("config local ip %3d.%3d.%3d.%3d",
                    (_local_ip._sin.sin_addr.s_addr&0x000000FF),
                    (_local_ip._sin.sin_addr.s_addr&0x0000FF00)>>8,
                    (_local_ip._sin.sin_addr.s_addr&0x00FF0000)>>16,
                    (_local_ip._sin.sin_addr.s_addr&0xFF000000)>>24);
                  }
                  
                  

                   

                  and

                   

                  int WiFiClass::begin(char* ssid, const char *passphrase)
                  {
                    char cmd[256];
                    int retval;
                  
                  
                    trace_debug("begin ssid=%s,passphrase=%s",ssid,passphrase);
                    if(ssid == NULL)
                    return WL_NO_SSID_AVAIL;
                    if(passphrase == NULL)
                    return WL_CONNECT_FAILED;
                  
                  
                    sprintf(cmd, "systemctl restart wpa_supplicant");
                    system(cmd);
                    sprintf(cmd, "ifconfig %s up", ARDUINO_WLAN);
                    system(cmd);
                    retval = -1;
                    /* Clear out current networks, and create a new one using ssid and key */
                    while (retval != 0)
                    {
                    sprintf(cmd, "wpa_cli remove_network `wpa_cli list_networks | tail -1 | cut -b 1-3`");
                    retval = system(cmd);
                    }
                    sprintf(cmd, "wpa_cli -i%s add_network", ARDUINO_WLAN);
                    system(cmd);
                    sprintf(cmd, "wpa_cli -i%s set_network 0 auth_alg OPEN", ARDUINO_WLAN);
                    system(cmd);
                    sprintf(cmd, "wpa_cli -i%s set_network 0 key_mgmt WPA-PSK", ARDUINO_WLAN);
                    system(cmd);
                    sprintf(cmd, "wpa_cli -i%s set_network 0 psk \'\"%s\"\'", ARDUINO_WLAN, passphrase);
                    system(cmd);
                    sprintf(cmd, "wpa_cli -i%s set_network 0 mode 0", ARDUINO_WLAN);
                    system(cmd);
                    sprintf(cmd, "wpa_cli -i%s set_network 0 ssid \'\"%s\"\'", ARDUINO_WLAN, ssid);
                    system(cmd);
                    sprintf(cmd, "wpa_cli -iwlan0 select_network 0", ARDUINO_WLAN);
                    system(cmd);
                    sprintf(cmd, "wpa_cli -iwlan0 enable_network 0", ARDUINO_WLAN);
                    system(cmd);
                    sprintf(cmd, "wpa_cli -iwlan0 reassociate", ARDUINO_WLAN);
                    system(cmd);
                    delay(10000);
                  
                  
                    _local_ip = getLocalIP();
                    if(_local_ip._sin.sin_addr.s_addr == 0) {
                    trace_debug("didnt get an IP address, cant connect");
                    sprintf(cmd, "ifconfig %s down", ARDUINO_WLAN);
                    system(cmd);
                    _status = WL_IDLE_STATUS;
                    return _status;
                    }
                    _subnet = getSubnet();
                    strcpy(_ssid, ssid);
                    _status = WL_CONNECTED;
                    return _status;
                  }
                  
                  


                  The config() routine doesn't appear to do anything immediately useful (I don't see the _local_ip variable getting used anywhere important (to me at the momment) in the rest of the WiFi.cpp file); and the begin() routine doesn't appear to make any attempt to communicate a user-specified static IP address to the "system".


                  At first blush, different versions of those same routines (different signatures) appear similarly devoid of static IP capabilities.

                   

                  Grumble.

                   

                  Next, I suppose I get to look up how to successfully encode and transfer to the system, both a Static IP specification, and a command that will cause it to be used.

                  • 6. Re: Edison on Arduino Carrier, no Static IP Address after using
                    GBlake

                    Here is the next piece of the puzzle: Intel® Edison Products — Wi-Fi User Guide

                     

                    That user guide explains the command line interface (cli) and wpa_supplicant commands being used in the code in my previous post, and gives you the info you need to modify the existing WiFi class (the code I posted), and/or the linux script(s) and other files that become involved.  To implement assigning static IP addresses, I think both the WiFi class, and a file or two on the linux side (the "system" side) of the process are going to have to change.

                     

                    The guide also gives you the info you need if you want to take the approach of putting your WiFi startup/shutdown instructions into a script(s) that could be invoked by a single command(s) issued by a revised WiFi class.

                    • 7. Re: Edison on Arduino Carrier, no Static IP Address after using
                      Intel_Peter

                      Hello GBlake,

                       

                      Sorry for the delay in my response. You could use the workaround found in Setting Up a Static IP Address with Arduino* Sketch.

                       

                      Peter.