Shop OBEX P1 Docs P2 Docs Learn Events
SimpleIDE WiFi - Page 5 — Parallax Forums

SimpleIDE WiFi

12357

Comments

  • Hi Ray,

    Thanks for posting your app and the tests.

    Andy
  • Since I have been testing and working with my WX WiFi SIP and WX WiFi DIP modules, a few questions have come up. The general question, which direction will Parallax be pushing the WiFi modules?

    1. What will be the procedure for having the WiFi module join a network, something in the firmware or something else? I think having to program the Propeller for an IP address, every time, would be a little confining I would think.

    2. Once you have joined the network, how do you get your html loaded to your module, to your new IP address?

    3. Will the development direction for the WiFi be, to use it in a stationary spot, within functional signal range (~15 feet)?

    4. If the Wifi is to be used in a mobile fashion, how to you get it to work between the hotspots? You would need the WiFi module to be able too switch the IP address.

    I will probably have more questions as I do more tests, but it would be nice get some concise answers to the ones I just listed.

    Ray

  • edited 2017-02-21 19:27
    The answers to 1, 2, and 4 are related:

    It's not a case of programming the Propeller to check its IP address every time before loading your application program. Checking the IP address can be done as part of the propeller program's initialization. If the Propeller does it programmatically, it can join a network and find its IP address through function calls. Your application can also initialize by trying to join a list of SSIDs. The program can try one, and checking for the IP address. If it's 0.0.0.0, try the next SSID. The program building blocks are located in parallax-esp-2016-11-02-1804-e\Examples\Propeller C\

    - Switch to STA + AP mode.side
    - Check Station IP Address.side
    - Join a Network.side
    - Leave a Network.side

    We also have enhancements planned for Static IP Addressing and SSID Scanning.

    In the meantime, sans static IP addressing, the IP address can be displayed in the terminal, or with a display that says something like, "Go to [ip address]/files/filename.html. I'm partial to the 96x64 Color OLED Display.

    Regarding question 3 and distance:

    My personal experience in the office has been about 60 ft, but that particular distance disappears from line-of-sight as it passes behind a metal partition. Other, more intentional in-house tests have been 30 m line-of-sight. This could vary considerably with environment and the other Wi-Fi hardware taking part in the communication.
  • Another way to prevent the need to programmatically recheck your IP that can be done on many wireless routers is to go into their settings and set up a DHCP reservation based on the device's MAC address. So you could try going into your wireless router's configuration pages and make it assign a set-by-you IP address based on your Wi-Fi module's MAC address.
  • In the other post, when I mentioned ~15 feet signal, this in a home environment, with the signal passing through two walls, and whatever items are in the other room. I do have an area where I could have line-of sight, maybe up to thirty feet, which I will be testing.

    The other item that I am thinking about is the firmware, which has the "files" to load your html program, which occurs at 192.168.4.1. Now when you have a new IP address, when you are on your home network, how would you load and run your html program, with your new address?

    Ray
  • Hi Ray,

    Yes, the configuration page will be at the new address when it's in station (STA) mode. If it's in STA+AP mode it'll be at the new address if your computer is on your home network, or at the 192.168.4.1 address if your computer is on the Wi-Fi module's access point (AP) network. If the Wi-Fi module is in AP mode, the configuration pages are only accessible through 192.168.4.1 when your computer is on the Wi-Fi module's network.

    Andy
  • This morning I tried joining my home network, and it worked as expected. I am using my RB5X robot which has the original AB and a Parallax WX WiFi SIP module.

    In my hobby space, I have a WiFi hotspot, that is the starting point. After turning on the robot, I joined the WX WiFi SIP AP, 192.168.4.1. In the firmware window, I chose "networks" and STA+AP mode, which came up with a list of WiFi signals. After choosing the best WiFi signal, it gave me an IP address for the WiFi SIP module. Now I can place my robot anywhere in the house and have a functional WiFi connection with my desktop computer. So far this all looks very promising.

    It would be really neat if within my html app, I could have a visual of what hotspot signal the WiFi is working with. I would prefer to have the code within the html, and not the Propeller, if that is possible.

    Ray
  • edited 2017-02-24 16:29
    Hi Ray,
    Rsadeika wrote: »
    ...It would be really neat if within my html app, I could have a visual of what hotspot signal the WiFi is working with. I would prefer to have the code within the html, and not the Propeller, if that is possible...

    Thanks for mentioning it. These two enhancement ideas may or may not get noticed here on the forums. If you instead post them on the Wi-Fi Module firmware GitHub repository, it'll ensure that the developers see it. Here's the address:

    https://github.com/parallaxinc/Parallax-ESP/issues

    Andy
  • As I mentioned in my other thread, I have moved my AB WX+WX WiFi over to my solar station. I have set up two voltage dividers which is showing data for the solar panel and the batteries. Since I will be using my html for displaying the data, I have run into a small problem, how do I 'G' more than one piece of information?

    In the html below, I can get one value and show it on the browser, but how do I get more than one value and then have it show up on the browser? I tried adding another event in the PropGCC program, but that did not work as expected. So, I guess maybe a small example of how this could be done, would be appreciated.

    Probably the next step would be, is to try too setup a data logging situation within the browser, and have the data stored on a local hard drive.

    Again, I would like to mention what a delight it is to be using the AB WX+WX WiFi, a real time saver, plus ease of use.

    /*
      wifi_solar.c
      
      Feb 25, 2017
      WiFi Solar Station
      
    */
    #include "simpletools.h"
    #include "wifi.h"
    #include "adcDCpropab.h"
    
    #define reboot() __builtin_propeller_clkset(0x80)
    
    volatile float vx,vy;
    
    int event, id, handle;
    int solarId;
    
    void pwrmon();
    
    
    int main()
    {
      // Add startup code here.
      cog_run(pwrmon,128);
      pause(50);
      wifi_start(31, 30, 115200, WX_ALL_COM);
      solarId = wifi_listen(HTTP, "/solar");
       
      while(1)
      {
        // Add main loop code here.
        wifi_poll(&event, &id, &handle);
        if(event == 'P')
        {
        }
        else if(event == 'G')
        {
          //if(id == solarId)
          //{
            //wifi_print(GET, handle, "%.2f", vx);
            //pause(50);
            //wifi_print(GET, handle, "%.2f", vy);
          //}
          if(id == solarId)
          {
            wifi_print(GET, handle, "%.2f", vx);  // Send to html
          }                
        }
        print("%cSolar panel: %.2f",HOME,vx);     // Show on local terminal          
        pause(50);
        print("  Batteries: %.2f%c\n",vy,CLREOL); // Show on local terminal
      }  
    }
    
    void pwrmon()
    {
      adc_init(21, 20, 19, 18);
      float v0,v1;
      while(1)
      {
        v0 = adc_volts(0);   // Solar panel
        pause(100);
        vx = (v0*4.9295);
        //vx = v0;
        //print("%cSolar panel: %.2f",HOME,vx);
        pause(50);
        v1 = adc_volts(1);   // Battery array
        pause(100);
        vy = (v1*4.7869);
        //vy = v1;
        //print("  Batteries: %.2f%c\n",vy,CLREOL);
        //pause(1000);
      }      
    }  
    
    <!-- wifisolar.html -->
    <!DOCTYPE HTML>
    <html>
    	<body>
    		<font face="Arial" size=2 color="blue">
    		Raw Battery Voltage
    		</font>
    		<br>
    		<button onclick="getFromMcu()">Update</button>
    		<p id="value">Raw Voltage</p>
    		
    
    	</body>
    	<script>
    	function useMcuReply(response)
    	{
    		var val = document.getElementById("value");
    		val.innerHTML = "Value: " + response;
    	}
    	function getFromMcu()
    	{
    		httpGet("/solar", useMcuReply);
    	}
    	function httpGet(path, callback)
        {
    		var req = new XMLHttpRequest();
            req.open("GET", path, true); 
            req.onreadystatechange = function() 
            { 
              if (req.readyState == 4)
                if(req.status == 200)
                  callback(req.responseText);
                else
                  callback("Waiting...");
            }
            req.send(null);
          }
    
    	</script>
    </html>
    
  • edited 2017-03-04 17:46
    Hi Ray,

    Take another look at the The Page Displays Buttons app in ...parallax-esp-2016-11-02-1804-*\Examples\Propeller C... The C code replies with two values in a wifi_print call. More info: Display Pushbutton States

    Another approach would be to set up two listeners and send the values with different paths. The ActivityBot Buttons IR Speed has an example of that.

    Andy



  • Temporary work for Linux users: you can now find compiled binaries of SimpleIDE here: http://david.zemon.name:8111/project.html?projectId=SimpleIDE&tab=projectOverview&guest=1

    Note that the above link is ONLY providing the SimpleIDE executable at this moment, not a complete package. I found this was a very easy goal and should help many users who already have an existing installation of SimpleIDE and just want to upgrade to the latest version.

    Full package coming... eventually. :)
  • Thanks David Zemon.

    In the previous post I listed my code for the Solar station application, which I now have a working prototype program. I have decided to post the code in my "Solar windowsill info" thread. I will be posting further code and developments in that thread, from now on.

    While working with the html code, I noticed that you can run the html with .../files/xxxx.html. But, I also noticed that if you use something like a putty program you can log into WX WiFi address, without the xxxx.html, but nothing occurs. Now if you had a command line UI in your PropGCC program, is there a way to access the UI part, of your PropGCC program, in your putty terminal window? Not sure of what the complexities of your WX WiFi firmware would be.

    Ray
  • Rsadeika wrote: »
    Thanks David Zemon.

    In the previous post I listed my code for the Solar station application, which I now have a working prototype program. I have decided to post the code in my "Solar windowsill info" thread. I will be posting further code and developments in that thread, from now on.

    While working with the html code, I noticed that you can run the html with .../files/xxxx.html. But, I also noticed that if you use something like a putty program you can log into WX WiFi address, without the xxxx.html, but nothing occurs. Now if you had a command line UI in your PropGCC program, is there a way to access the UI part, of your PropGCC program, in your putty terminal window? Not sure of what the complexities of your WX WiFi firmware would be.

    Ray
    You can get a command line interface with your program by using telnet to connect to the IP address of your module. That appears as if it were serial I/O on the Propeller side.

  • Since I am using a Windows 7 system, what programs are available for doing that? I have never used a telnet, so I am not even sure how that would work.

    Ray
  • Rsadeika wrote: »
    Since I am using a Windows 7 system, what programs are available for doing that? I have never used a telnet, so I am not even sure how that would work.

    Ray
    If you want something really simple and don't mind typing commands you can just use "proploader -t".

  • In putty, it has a telnet selection, I have always been using the default SSH setting. Well, anyway, I tried the telnet selection, and it works, it was displaying my print() commands, that are in the PropGCC program.

    Now I can add in a UI section for things like a quick reboot of the program, or control the AB WX+WX WiFi without having those functions displayed on the browser. Now I have to figure out how to implement a password control in the PropGCC program to control access via the telnet.

    Ray
  • Rsadeika wrote: »
    In putty, it has a telnet selection, I have always been using the default SSH setting. Well, anyway, I tried the telnet selection, and it works, it was displaying my print() commands, that are in the PropGCC program.

    Now I can add in a UI section for things like a quick reboot of the program, or control the AB WX+WX WiFi without having those functions displayed on the browser. Now I have to figure out how to implement a password control in the PropGCC program to control access via the telnet.

    Ray
    Yes, putty should work fine.

  • Below is a quick and dirty program to see if this works with a Parallax WX WiFi SIP module. I used putty in telnet mode, and I do not get any activity.

    I guess I have to assume that the telnet will only work with a Parallax WX WiFi DIP module, because it has to use P31 and P30? Or am I missing some specific code in the example program below.

    Ray
    /*
      test_telnet.c
    
      March 7, 2017
      
    */
    #include "simpletools.h"
    #include "wifi.h"
    
    void menu();
    
    int main()
    {
      // Add startup code here.
      wifi_start(5, 4, 115200, WX_ALL_COM);
      
      char inBuff[40];
     
      while(1)
      {
        // Add main loop code here.
        print("> ");
        getStr(inBuff,40);
        if(!strcmp(inBuff,"help")) menu();
        else
        {
          print("Invalid Command\n");
        }      
      }  
    }
    
    void menu()
    {
      print("Menu - help, \n");
    }  
    
  • I think there is a way to use different pins with print etc. Andy will probably see this and respond.
  • The other potential problem that I see, in the telnet_test program is if you add:
    wifi_poll(&event, &id, &handle);
    in the while(1) loop, the getStr() will stop the loop, waiting for some incoming. That, I think would have a very bad affect on the browser program.

    Ray
  • I am thinking about adding an RTC function to the AB WX+ (includes the WiFi module), because the Propeller has limited RAM resources, a good option would be to use the browser resources.

    Since my AB WX+ runs 24/7, that means it also has access to my network, which means I could have access to the system clock for the real time. On the Propeller side, if you use something like:
    wifi_poll(&event, &id, &handle); 
        print("event = %c, id = %d, handle = %d\r", event, id, handle);
        if(event == 'P')
        {
          if(id == ledId)
          {
            print("Incoming POST request\r");
            wifi_scan(POST, handle, "RTC %d%d", &date, &time);               
          }        
        }
    
    what would be the appropriate code in the html to get the system time, without having to activate a button on the html side? I think javascript has a multi threading component, is their a simpler option.

    What I would like to achieve is the PropGCC program being able to get the current time and date in real time. This way if I implement a data logger program, I can attach the current time and date to a specific data point. This could also help in tracking (data logging) other things attached to the AB WX+ system. All that without having the timedate lib installed and running.

    Ray
  • I have been trying to get the program below, to work correctly, but I am not having much success.

    The reboot button works as expected. The showing of the AB WX+ system date works correctly. But when I try to do a system date update, the wrong date keeps coming up. Is there something with the datetime dt update that I am doing wrong? Anybody have any ideas.

    Ray
    /*
      wificlock.c
    
      March 13, 2017
      
    */
    #include "simpletools.h"
    #include "wifi.h"
    #include "datetime.h"
    
    #define reboot() __builtin_propeller_clkset(0x80)
    
    datetime dt = {2017, 1, 1, 0, 0, 0};
    char times[9];
    char dates[9];
    
    int event, id, handle;
    int resetId,timeId,dateId;
    char command;
    
    int main()
    {
      // Add startup code here.
      dt_run(dt);
      pause(50);
      wifi_start(31, 30, 115200, WX_ALL_COM);
      resetId = wifi_listen(HTTP, "/reset");
      timeId = wifi_listen(HTTP, "/time");
      dateId = wifi_listen(HTTP, "/date");
    
      int sysy,sysmo,sysd;
      int test = 0;
       
      while(1)
      {
        // Add main loop code here.
        wifi_poll(&event, &id, &handle);
        if(event == 'P')
        {
          if(id == resetId)
          {
            wifi_scan(POST, handle, "go%c", &command);
          }
          if(id == dateId)
          {
            wifi_scan(POST, handle, "go%d", &sysy);
            dt.y = sysy;
            dt_set(dt);
            wifi_scan(POST, handle, "go%d", &sysmo);
            dt.mo= sysmo;
            dt_set(dt);
            wifi_scan(POST, handle, "go%d", &sysd);
            dt.d=sysd;
            dt_set(dt);
          }                
        }
        else if(event == 'G')
        {
          if(id == dateId)
          {
            dt = dt_get();
            dt_toDateStr(dt, dates);
            wifi_print(GET, handle, "%s\r", dates);
          }        
        }
        if(command != 0)
        {
          switch(command)
          {
            case 'R':
              reboot();
              break;
          }        
        }
        test++;
        print("%c test: %d",HOME,test);
        print("%c",CLREOL);                  
      }  
    }
    
    <!--wificlock.html -->
    <!DOCTYPE HTML>
    <html>
    <body>
    	<font face="Arial" size=2 color="cyan">
    	Show AB WX+ System Date
    	</font>
    	<br>
    	<div>
    	<a onclick="getFromMcuD();">Date</a>
    	</div>
    	<p id= "value">Value</p>
    	<br>
    	<font face="Arial" size=2 color="cyan">
    	Set AB WX+ System Date and System Reboot
    	</font>
    	<br>
    <div>
    <a onclick="dateBtn();">Date</a>
    <a onclick="resetBtn('R');">Reboot</a>
    </div>
    </body>
    <script>
    function dateBtn()
    {
    	var dt = new Date();
    	httpPost("/date","go=" + dt.getFullYear())
    	httpPost("/date","go=" + dt.getMonth())
    	httpPost("/date","go=" + dt.getDay())
    }
    function resetBtn(command)
    {
    	httpPost("/reset", "go=" + command)
    }
    function getFromMcuD()
    {
    	httpGet("/date", useMcuReply);
    }
    function useMcuReply(response)
    {
    	var val = document.getElementById("value");
    	val.innerHTML = "Value: " + response;
    }
    function httpPost(path,param)
    {
    	var req = new XMLHttpRequest();
    	req.open("POST", path, true);
    	req.setRequestHeader("Content-type",
    	"application/x-www-form-urlencoded");
    	req.send(param);
    }
    function httpGet(path, callback)
    {
    	var req = new XMLHttpRequest();
        req.open("GET", path, true); 
        req.onreadystatechange = function() 
    		{ 
    			if (req.readyState == 4)
                if(req.status == 200)
                  callback(req.responseText);
                else
                  callback("Waiting...");
            }
            req.send(null);
    }
    
    </script>
    </html>
    
  • In the application below, I am not sure if there is a problem with the html, WX WiFi firmware, or SimpleIDE.

    I sort of narrowed down to the wifisolar.c program, I think. In the segment:
      wifi_start(31, 30, 115200, WX_ALL_COM);
      solarId = wifi_listen(HTTP, "/solar");
      batteryId = wifi_listen(HTTP, "/battery");
      battery2Id = wifi_listen(HTTP, "/battery2");
      timeId = wifi_listen(HTTP, "/times");
      dateId = wifi_listen(HTTP, "/date");
      resetId = wifi_listen(HTTP, "/reset");
    
    it seems that that only four items are being handled, in the browser, solarId, batteryId, battery2Id, and timeId. I am not sure how wifi_start() works, does it have a limit of wifi_listen() items that it can handle?

    The problem shows up in the html browser, with the current wifi_listen() order, I do not get the dateId item to work in the browser. But, when I change the order around, put dateId in front of timeId, then the timeId no longer works, in the browser. I also tried moving solarId to the end of the list, and that item was not working in the browser, plus dateId and timeId were not working as expected.

    Are the wifi_listen() items eating up all the data space, or does the wifi_start() have an item limit.

    Ray

    /*
      wifi_solar.c
      
      Feb 25, 2017
      WiFi Solar Station
      
    */
    #include "simpletools.h"
    #include "wifi.h"
    #include "adcDCpropab.h"
    #include "simpletext.h"
    #include "fdserial.h"
    #include "datetime.h"
    
    #define reboot() __builtin_propeller_clkset(0x80)
    
    serial *rpi;
    
    volatile float vx,vy,vz;  // vx=solar panel, vy=batteries, vz=car battery
    volatile float tempf,humid,baro;
    
    datetime dt = {2017, 1, 1, 0, 0, 0};
    
    int event, id, handle;
    int solarId,batteryId,battery2Id,timeId,dateId,resetId;
    char sysr;
    
    char times[9];
    char dates[9];
    
    
    /* COGed Functions*/
    void pwrmon();
    void datamon();
    /******************************/
    
    int main()
    {
      // Add startup code here.
    /*                    Rx Tx      BAUD   */
      //rpi = fdserial_open(31, 30, 0, 115200);
      dt_run(dt);  // Start clock  
      pause(50);
      cog_run(pwrmon,128);
      pause(50);
      //cog_run(datamon,128);
      //pause(50);
      wifi_start(31, 30, 115200, WX_ALL_COM);
      solarId = wifi_listen(HTTP, "/solar");
      batteryId = wifi_listen(HTTP, "/battery");
      battery2Id = wifi_listen(HTTP, "/battery2");
      timeId = wifi_listen(HTTP, "/times");
      dateId = wifi_listen(HTTP, "/date");
      resetId = wifi_listen(HTTP, "/reset");
      
    
      int DO = 22, CLK = 23, DI = 24, CS = 25;
      sd_mount(DO, CLK, DI, CS);  // Mount SD
      
      char inBuff[40];
      int sysh,sysm,syss,sysy,sysmo,sysd;
      
      while(1)
      {
        // Add main loop code here.
        wifi_poll(&event, &id, &handle);
        if(event == 'P')
        {
          /*if(id == timeId)
          {
            wifi_scan(POST, handle, "go%d", &sysh);
            dt.h = sysh;
            pause(50);
            wifi_scan(POST, handle, "go%d", &sysm);
            dt.m = sysm;
            pause(50);
            wifi_scan(POST, handle, "go%d", &syss);
            dt.s = syss;
            dt_set(dt);
          }
          if(id == dateId)
          {
            wifi_scan(POST, handle, "go%d", &sysy);
            dt.y = sysy;
            pause(50);
            wifi_scan(POST, handle, "go%d", &sysmo);
            dt.mo=sysmo;
            pause(50);
            wifi_scan(POST, handle, "go%d", &sysd);
            dt.d=sysd;        
            dt_set(dt);
          } */
          if(id == resetId)
          {
            wifi_scan(POST, handle, "go%c", &sysr);
          }                        
        }
        else if(event == 'G')
        {
          if(id == dateId)
          {
            //get_Date();
            print("'G' /date \n");
            dt = dt_get();
            dt_toDateStr(dt, dates);
            //dt_fromDateStr(dt, dates);
            wifi_print(GET, handle, "%s\r", dates);
          }
          if(id == timeId)
          {
            print("'G' /time \n");
            //get_Time();
            dt = dt_get();
            dt_toTimeStr(dt, times);
            wifi_print(GET, handle, "%s\r", times);
          }
          if(id == solarId)
          {
            wifi_print(GET, handle, "%.2f\r", vx);
          }
          if(id == batteryId)
          {
            wifi_print(GET, handle, "%.2f\r", vy);  // Send to html
          }
          if(id == battery2Id)
          {
            wifi_print(GET, handle, "%.2f\r", vz);
          }        
        }
        if(sysr != 0)
        {
          switch(sysr)
          {
            case 'R':
              reboot();
              break;
          }        
        }      
    
        //print("%cSolar panel: %.2f",HOME,vx);     // Show on local terminal          
        //pause(50);
        //print("  Batteries: %.2f Car bat: %.2f%c",vy,vz,CLREOL); // Show on local terminal
            
      }  
    }
    /******************************/
    /* COGed Functions */
    void pwrmon()
    {
      adc_init(21, 20, 19, 18);
      float v0,v1,v2;
      while(1)
      {
        v0 = adc_volts(0);   // Solar panel
        pause(100);
        vx = (v0*4.9295);
        v1 = adc_volts(1);   // Battery array
        pause(100);
        vy = (v1*4.7869);
        pause(50);
        v2 = adc_volts(2);
        vz = (v2*4.9317);    
      }      
    }
    
    void datamon()
    {
    
    }    
    /******************************/
    
    <!-- wifisolar.html -->
    <!DOCTYPE HTML>
    <html>
    	<head>
    		<style>
    			a{
    				background-color:#637aad;
    				color:white;
    				font-size:23px;
    				margin:5px;
    				width:100px;
    				height:55px;
    				cursor:pointer;
    				padding-top:4px;
    				padding-bottom:4px
    			}
    			a:hover{backgrond-color:white;color:navy;}
    		</style>
    	</head>
    	<body bgcolor=3b5898>
    		<div align="center">
    			<font face="Arial" size=6 color="red">
    			Solar Station Report
    			</font>
    		</div>
    	<br>
    	<font face="Arial" size= 2 color="cyan">
    	Voltage for Solar Panel
    	<br>
    	 or Battery Array or Battery2
    	</font>
    	<br>
    	<br>
    	<!--<input type="radio" name="choices" onclick="getFromMcuS();"> Solar -->
    	<!--<input type="radio" name="choices" onclick="getFromMcuB();"> Battery -->
    	<div>
    	<a onclick="getFromMcuS();">Solar</a>
    	<a onclick="getFromMcuB();">Battery</a>
    	<a onclick="getFromMcuB2();">Battery2</a>
    	<a onclick="getFromMcuD();">Date</a>
    	<a onclick="getFromMcuT()">Time</a>
    	</div>
    	<p id="value">Value</p>
    	<br>
    	<div>
    	<font face="Arial" size= 2 color="cyan">
    	Update AB WX+ 
    	<br>
    	 System  Reboot
    	</font>
    	<br>
    	<br>
    
    	<a onclick="resetBtn('R');">Reboot</a>
    	</div>
    	</body>
    	
    	<script>
    	function resetBtn(command)
    	{
    		httpPost("/reset", "go=" + command);
    	}
    	function useMcuReply(response)
    	{
    		var val = document.getElementById("value");
    		val.innerHTML = "Value: " + response;
    	}
    	function getFromMcuS()
    	{
    		httpGet("/solar", useMcuReply);
    	}
    	function getFromMcuB()
    	{
    		httpGet("/battery", useMcuReply);
    	}
    	function getFromMcuB2()
    	{
    		httpGet("/battery2", useMcuReply);
    	}
    	function getFromMcuD()
    	{
    		httpGet("/date", useMcuReply);
    	}
    	function getFromMcuT()
    	{
    		httpGet("/times", useMcuReply);
    	}
    	function httpGet(path, callback)
        {
    		var req = new XMLHttpRequest();
            req.open("GET", path, true); 
            req.onreadystatechange = function() 
            { 
              if (req.readyState == 4)
                if(req.status == 200)
                  callback(req.responseText);
                else
                  callback("Waiting...");
            }
            req.send(null);
          }
          function httpPost(path,param)
          {
    		  var req = new XMLHttpRequest();
    		  req.open("POST", path, true);
    		  req.setRequestHeader("Content-type",
    		  "application/x-www-form-urlencoded");
    		  req.send(param);
    	  }
    	  function sleep(milliseconds)
    	  {
    		  var start = new Date().getTime();
    		  for(var i = 0; i < 1e7; i++)
    		  {
    			  if((new Date().getTime() - start) > milliseconds)
    			  {
    				  break;
    			  }
    		  }
    	  }
    	</script>
    </html>
    
  • David BetzDavid Betz Posts: 14,511
    edited 2017-03-20 14:05
    The WX firmware supports a maximum of four listeners. Your attempt to setup a fifth should have produced an error.
  • The WX firmware supports a maximum of four listeners. Your attempt to setup a fifth should have produced an error.
    [\QUOTE]
    Is that, or was that an arbitrary limit? Will that limit be changed or is there a hardware/software limitation. Maybe I missed that in the Learn tutorials, but that is a very important piece of information that should be known by all.

    Now that I have been playing around with this WiFi stuff, it seems like the listener limit could well be a big handicap for the development of more interesting programs.

    I really hate to say this, I think that the WX WiFi is still in an alpha state, and maybe a warning should have been included.

    Ray
  • In the v1.0 Wi Fi Module Guide is states a max of 4 listeners.

    https://parallax.com/sites/default/files/downloads/32420-Parallax-Wi-Fi-Module-API-v1.0.pdf


    Page 12 of 21:
    "There are a maximum of four listeners available. Issuing additional LISTEN commands when all four listeners are already established will result in a response ofb=E,4E (NO_FREE_LISTENER)untilaCLOSEcommandisusedtofreealistener."


    dgately
  • It looks like I downloaded the pdf, but relied on the Learn site for all the necessary information. It states that it shows a response, but where, I have not seen any errors come up in SimpleIDE when I do a Run. But, I did not check to see if comes up as a warning... just checked, it does not show up as a warning.

    So, the question still remains, is four a firm limit, or will it be increased with the next firmware update?

    Ray
  • David BetzDavid Betz Posts: 14,511
    edited 2017-03-20 20:38
    I don't know Andy's library but I'd be willing to bet that wifi_listen returns a zero or negative value if it fails.
  • The "Documentation wifi Library.html" inside the Learn/Simple Libraries/libwifi/ directory, contains the following info on wifi_listen.
    int wifi_listen	(char protocol, char *path)		
    Activate a listener process to monitor HTTP or WebSocket protocol activity on port 80 with a specified path.
    
    Parameters
    protocol	Use HTTP (for HTTP), or WS (for WebSocket).
    path	The 'path' part of the URL that the remote client uses to access this module and its resources. The path can end in an asterisk '*' to match anything that begins with path.
    
    Returns
    wifi_id (positive if success, negative if error code).
    

    So, yes it returns a negative value on failure... You should probably check the value returned for any resource getter that a library returns. It's good for debugging as well as for failures.

    dgately
  • Well, it looks like my application needs a redesign. At the moment I have or need at least five listeners, and with an expansion in my program that could increase to six or seven.

    I was trying to figure out how to get more functionality out of a listener, but it is not working for me. I do realize I need more experience with this wifi stuff, but ...

    Now I am wondering what would happen if you had four listeners in COG 0, and you created another COG, if I have any extra COGs, with another four listeners. Would that complicate things to the point where the program would not work? It seems that one complication might be: wifi_start(31, 30, 115200, WX_ALL_COM); , how would the COGs handle that?

    I am also wondering if I have hit a limitation of the AB WX and WX WiFi, for use with my application.

    Ray
Sign In or Register to comment.