WX ESP8266 Module Name and Simple IDE Discovery

ShawnaShawna Posts: 463
edited 2019-12-20 - 12:44:14 in Propeller 1
I can't seem to change the WX modules name from the settings page and have it retained after a power cycle. I have tried this on 2 different modules with 2 different versions of firmware. I am selecting the "Save to Flash" button after I change the name. The Device will show up in SimpleIDE with the new name, but when I cycle the power the name defaults back to its factory name. Is this a known bug or am I missing something?

Also, is there a way to disable the wx module from showing up in the SimpleIDE port selection drop-down menu? I thought I had read about this in another thread, but I can't seem to find it. We have 3 of these in the house and I have many more little projects I would like to add them too. But accidentally programming the wrong propeller would cause headaches. Especially when I'm not the only one in the house using SimpleIDE.

Thanks
Shawn A.

Comments

  • There have been several times that I thought about changing the name of the device but never tried it. I will have to give it a try now and see it does work.

    I have written updated firmware code that will hide this device so you don't see it. Several times I have grabbed the wrong device and wiped out a working unit in action.

    I guess if I would have changed the name that might not have happened.

    I also have code that will allow the WX module to send out UDP packets for applications that just want to pickup so information being sent out.

    Mike
  • iseries wrote: »
    I have written updated firmware code that will hide this device so you don't see it. Several times I have grabbed the wrong device and wiped out a working unit in action.

    Mike,
    I would be interested in hearing how you modified the code to do that. Did you modify files in the Parallax-ESP folder?

    Shawn
  • iseries wrote: »
    There have been several times that I thought about changing the name of the device but never tried it. I will have to give it a try now and see it does work.

    I have written updated firmware code that will hide this device so you don't see it. Several times I have grabbed the wrong device and wiped out a working unit in action.

    I guess if I would have changed the name that might not have happened.

    I also have code that will allow the WX module to send out UDP packets for applications that just want to pickup so information being sent out.

    Mike
    Have you told Parallax about this? They might be interested in adopting your changes.

  • I used Azure and built a Ubuntu server. I then download the Parallax-ESP repository.

    The hard part was upgrading the ESP8266 SDK library from 2.0.0 to 2.2.1. This is not a necessary step but I like using the current SDK.

    The files I changed where:
    html/settings.html
    html/wifi/wifi.html
    parallax/sscp-settings.c
    parallax/sscp-tcp.c
    parallax/sscp.c
    parallax/sscp.h
    parallax/user_main.c

    I created a new program to except the udp functions:
    parallax/sscp-udp.c

    The sscp program parses all the commands and routes them to the correct program for processing.

    The problem with hiding the device is if you don't know what IP it's at you can't bring up the web page to change it back. If you have access to the router or you know what IP it was at when you disabled it that's not a big problem.

    I can give you the OTA file that you could load on the WiFi-WX board. You should however have the current OTA file to change it back if you need to.

    Mike
  • iseries wrote: »
    I used Azure and built a Ubuntu server. I then download the Parallax-ESP repository.

    The hard part was upgrading the ESP8266 SDK library from 2.0.0 to 2.2.1. This is not a necessary step but I like using the current SDK.

    The files I changed where:
    html/settings.html
    html/wifi/wifi.html
    parallax/sscp-settings.c
    parallax/sscp-tcp.c
    parallax/sscp.c
    parallax/sscp.h
    parallax/user_main.c

    I created a new program to except the udp functions:
    parallax/sscp-udp.c

    The sscp program parses all the commands and routes them to the correct program for processing.

    The problem with hiding the device is if you don't know what IP it's at you can't bring up the web page to change it back. If you have access to the router or you know what IP it was at when you disabled it that's not a big problem.

    I can give you the OTA file that you could load on the WiFi-WX board. You should however have the current OTA file to change it back if you need to.

    Mike
    This all sounds good. I know Parallax is interested in UDP so I think they'd want to adopt your changes. Could you submit a pull request?
  • Mike,
    Could I get the OTA file and the SDK files before they are compiled. I would like to look through the files and learn how you changed them. I have modified the ESP8266 that I use with password protected config pages. I would like to take your version and add password protection. I don't really care what the module name is as long as I can shut off its discovery. The version that I use is older, I used Clock Loops thread to recompile the SDK files after I modified them. I couldn't figure out how to modify anything but the HTML pages.

    https://forums.parallax.com/discussion/169250/parallaxwx-esp8266-raspberrypi-debian-esp-open-sdk-simpleide-openspin-proploader-devel/p1

    It would be nice if Parallax would update their firmware for the module. I personally think that device discovery, udp and the ability to change the ports would be huge and make the device more functional. I also think that password protection for the config pages would be nice, I realize that code space is limited and it would be hard to implement a full fledged version with password protection.

    Thanks
    Shawn
  • Shawna wrote: »
    Mike,
    Could I get the OTA file and the SDK files before they are compiled. I would like to look through the files and learn how you changed them. I have modified the ESP8266 that I use with password protected config pages. I would like to take your version and add password protection. I don't really care what the module name is as long as I can shut off its discovery. The version that I use is older, I used Clock Loops thread to recompile the SDK files after I modified them. I couldn't figure out how to modify anything but the HTML pages.

    https://forums.parallax.com/discussion/169250/parallaxwx-esp8266-raspberrypi-debian-esp-open-sdk-simpleide-openspin-proploader-devel/p1

    It would be nice if Parallax would update their firmware for the module. I personally think that device discovery, udp and the ability to change the ports would be huge and make the device more functional. I also think that password protection for the config pages would be nice, I realize that code space is limited and it would be hard to implement a full fledged version with password protection.

    Thanks
    Shawn
    There is actually plenty of code space. The problem is with RAM space. If these changes use little or no additional RAM they should be okay.

  • It's been a while since I have looked at this code but here it is:

    user_main.c is changed to not call initDiscovery();

    A parameter was added to flashConfig to check whether to call it or not.

    The config parameter I added was cmd-loader.

    In Parallax change:
    user_main.c
    sscp-settings.c

    In esp-link-stuff
    config.c
    config.h

    In html/wifi
    wifi.html

    Mike
  • Thanks Mike, I will take a look.
  • iseries wrote: »
    It's been a while since I have looked at this code but here it is:

    user_main.c is changed to not call initDiscovery();

    A parameter was added to flashConfig to check whether to call it or not.

    The config parameter I added was cmd-loader.

    In Parallax change:
    user_main.c
    sscp-settings.c

    In esp-link-stuff
    config.c
    config.h

    In html/wifi
    wifi.html

    Mike
    Thanks but didn't you say you also added UDP support? Could you include those files as well?

  • UDP took a little more work and I was looking for my test code to see if I actually tested it out.

    I also added IP address support so you can program what IP address, Subnet, DNS, and gateway you want the WiFi module to use.

    I also coded some Arduino code that will emulate some of the basic functions of the WiFi module except for an HTTP server and file system. It will however connect to a remote host and send and receive data so you can build your code and then slip in a $3.00 ESP-01 module in its place.

    Mike

    h
    h
    7K
    c
    c
    21K
  • iseries wrote: »
    UDP took a little more work and I was looking for my test code to see if I actually tested it out.

    I also added IP address support so you can program what IP address, Subnet, DNS, and gateway you want the WiFi module to use.

    I also coded some Arduino code that will emulate some of the basic functions of the WiFi module except for an HTTP server and file system. It will however connect to a remote host and send and receive data so you can build your code and then slip in a $3.00 ESP-01 module in its place.

    Mike
    Thanks!

  • Mike,
    Hey I am starting to try and dig into this, are you sure the discover enable/disable is in the wifi.html code, I don't seem to see it there? I could be totally missing it though, or did you put it in the settings.html code?

    Thanks
    Shawn

  • Oops your right. I had to fix the WiFi.html page because of bug.

    Here is the settings page.

    Mike
  • ShawnaShawna Posts: 463
    edited 2019-12-23 - 22:37:39
    I fired my linux VM up and refreshed my brain on how to build the esp. I built a new OTA build from the git site which I believe should be like a fresh install. Sorry with the terminology. I flashed the wx and everything worked as planned.

    The WX Module not remembering its name, is a bug that Clock Loop mentioned in the thread I posted above. He also mentions how to hard code the name into the module.

    Mike, I would like to try your code but I'm not sure if the software I use to make the builds is compatible with what you use. I don't want to brick the module.

    When I follow the tutorial Clock Loop wrote it creates a folder called ESP8266_NONOS_SDK-2.1.0-18-g61248.
    I think it uses xtensa-lx106-elf to compile or build or make the ota file. Forgive me for my ignorance, I know enough about this to break stuff. Correct me if that is not how it works.

    Anyways you said above..............
    iseries wrote: »
    The hard part was upgrading the ESP8266 SDK library from 2.0.0 to 2.2.1. This is not a necessary step but I like using the current SDK.

    So my version of the SDK falls between those 2 you mentioned.

    This makes me think I should be able to just swap files and build away and it shouldn't turn into the smallest brick in my house?

    Is that enough info and do you think I'm good to try building it?

    Thanks
    Shawn



  • Oh, I assume that when I run the make command, it compiles the c code and everything else, it "builds" the files. If this is the case and there was a problem, I think it would display errors.
  • I replaced the files and performed a make clean and a make and the compiler returned some errors, not really sure where to go with this, so I will have to do some reading.


    Thanks
    Shawn
    1537 x 801 - 159K
  • I think I found the problem, not sure what it means.

    I replaced this section of code from you sscp-setting file.
    static int setIPAddress(void *data, char *value)
    {
    	char* p;
    	char dash = '-';
    	struct ip_info info;
    	ip_addr_t dns1;
    	ip_addr_t dns2;
    	char* v;
    
    	p = os_strchr(value, dash);
    	if (p != NULL)
    	{
    		v = value;
    		*p = 0;
    		info.addr = ipaddr_addr(v);
    		*p = dash;
    		v = p + 1;
    		p = os_strchr(v, dash);
    		if (p != NULL)
    		{
    			*p = 0;
    			info.netmask = ipaddr_addr(v);
    			*p = dash;
    			v = p + 1;
    			p = os_strchr(v, dash);
    			if (p != NULL)
    			{
    				*p = 0;
    				info.gw = ipaddr_addr(v);
    				*p = dash;
    				v = p + 1;
    				p = os_strchr(v, dash);
    				if (p != NULL)
    				{
    					*p = 0;
    					dns1.addr = ipaddr_addr(v);
    					*p = dash;
    					v = p + 1;
    					dns2.addr = ipaddr_addr(v);
    				}
    				else
    				{
    					dns1.addr = ipaddr_addr(v);
    				}
    			}
    		}
    		wifi_station_dhcpc_stop();
    		if (dns1.addr != 0)
    			espconn_dns_setserver(0, dns1);
    		if (dns2.addr != 0)
    			espconn_dns_setserver(1, dns2);
    		wifi_set_ip_info(STATION_IF, &info);
    		return 0;
    	}
    
        return -1;
    }
    

    And replaced it with this code which I copied out of the sscp-setting file Build from the original Parallax Firmware
    static int setIPAddress(void *data, char *value)
    {
        return -1;
    }
    

    I ran a make clean and make command and it built with no errors and created an .ota file.

    I am tempted to flash the ESP after supper with the new file.

    Thanks
    Shawn
  • Right, This is the code that allows the module to be programmed with an IP address which you do not need anyway.

    Mike
  • iseries wrote: »
    Right, This is the code that allows the module to be programmed with an IP address which you do not need anyway.
    Mike

    I don't need it ............ but that is a nice feature!

    So I flashed the OTA file and everything worked as expected. Now I won't be blasting my sons devices, and he won't be blasting mine.

    I might also add that the the device needs to be rebooted for the "Hide from Loader" setting to take place. Which isn't a big deal, but if you don't know it, one might think its not working.

    Very Nice!!!!!

    Thanks Mike

    I will probably go back and see if I can make your original file work, I would like to be able to make the IP Address Static. Right now I just reserve an ip address in my router with the MAC address of the ESP8266 module, which works fine.

    UDP is pretty cool, I don't fully know how to use it. I do have a wiznet running as a WOL server. I originally wanted to do this with the ESP8266 module, but then found out you cannot do WOL over wifi.

    The next holy grail for me is being able to change the HTTP/TCP port. Port 80 is fine but it would be nice to be able to change it. Awhile back I tried to find where the port was set in the code, but was unsuccessful. I might have found it though when I was looking through the files you modified.

    Thanks
    Shawn
  • The port is defined in the user_main.c program as part of the startup code. " httpdInit(builtInUrls, 80);"

    You could change that line and rebuild the code otherwise a parameter could be added to the web page to have it's value.

    The problem is that the automatic DNS server used when you connect with your phone the first time as STA, it will return just HTTP://esp.nonet. The port number is not part of the return request information.

    Mike
  • ShawnaShawna Posts: 463
    edited 2019-12-28 - 03:33:03
    @iseries
    Ok, so you kind of lost me after your last post. I've finally had a little time to do some investigating.
    iseries wrote: »
    The problem is that the automatic DNS server used when you connect with your phone the first time as STA, it will return just HTTP://esp.nonet. The port number is not part of the return request information.
    Should that say AP instead of STA?
    iseries wrote: »
    The port is defined in the user_main.c program as part of the startup code. " httpdInit(builtInUrls, 80);"

    I tried following the "httpdInit()" function from file to file and it looks like it does change the port number.

    So then I did a search for "esp.nonet" and I found it in this file "captdns.c".

    This is the description at the top of the"captdns.c" file.
    /*
    This is a 'captive portal' DNS server: it basically replies with a fixed IP (in this case:
    the one of the SoftAP interface of this ESP module) for any and all DNS queries. This can 
    be used to send mobile phones, tablets etc which connect to the ESP in AP mode directly to
    the internal webserver.
    */
    

    From your previous post and what I could understand in the program, it does look like changing the port would work, as long as AP mode is not being used.
    Is that a correct statement?

    When I re-flash my ESP module and it reboots, it retains the wifi network and password. So I'm thinking that after the initial wifi network is setup in AP mode, I should be able to set the module to STA mode. Then I should be able to reflash the module with the new port number and everything should be good.

    Does that sound right, or am I going to brick it?

    Once I have changed the port number, if I want to change the network that the wifi module is connected too, it may need to be flashed back to port 80 before changing networks.

    Any thoughts?


    Thanks
    Shawn

  • My point was that people connecting to the unit the first time as an Access Point will generate a DNS request which will return the home page of the unit which is registered as http://esp.nonet.

    Because you are changing the port number to something other than 80 they will not see the home page and instead will see page not found request from there browser. To fix that they would have to use HTTP:8080//esp.nonet where 8080 is the new port number you used for your device. Not a big deal since you are hiding it anyway.

    Mike
  • Oh, I understand now.

    Thanks Mike
  • ShawnaShawna Posts: 463
    edited 2019-12-29 - 22:33:13
    I was playing with the ESP8266 module today and getting frustrated. Sometimes after a power cycle the modules name would be retained and sometimes it would not.

    I have found the answer through trial and error.

    If the module is in STA mode, and the modules name is changed from the settings page, it will not retain the name after a power cycle even if you click on the "save to flash" button.

    If the module is in STA+AP or AP mode, changing the name and clicking the "save to flash" button will save it to flash. When the power is cycled, it will boot back up with the expected name.

    The OTA file I was using was downloaded today from the product page for the WX ESP8266.


    Shawn
  • The 2 goals of this thread were to have the modules name retained after a power cycle and hide the module from SimpleIDE.

    1) Retain modules name after power cycle.
    This is easy, put the device into either AP or STA+AP mode from the Network page.
    Then goto the Settings page and change the name of the Module at the top of the page and click "Save to Flash". When the module is power cycled, it should have the new name.

    2) Hide Module from SimpleIDE.
    This one is a little trickier, it requires modifying files in the Parallax-ESP folder and then re-compiling the folder to create a new OTA firmware file.

    Mike was kind enough to include the files necessary for adding the discovery mode to the Parallax-ESP build. The files and locations that need to be added to the Parallax-ESP folder are as follows.

    In Parallax change:
    user_main.c
    sscp-settings.c

    In esp-link-stuff:
    config.c
    config.h

    In html:
    settings.html

    Once these files have been added/modified, it is time to re-compile the Parallax-ESP folder.

    There are a couple of ways to do this, I used Clock Loop's guide to recompile the Parallax-ESP folder.
    https://forums.parallax.com/discussion/169250/parallaxwx-esp8266-raspberrypi-debian-esp-open-sdk-simpleide-openspin-proploader-devel/p1

    Mike mentioned the use of Azure to recompile the folder.

    Also there is a guide on the Parallax-ESP Github site.
    https://github.com/parallaxinc/Parallax-ESP

    Once the new firmware has been re-compiled and flashed into the module, navigate to the settings.html page, there should be a setting labeled "Hide from Loader:". Change this setting to Yes and click the "Save to Flash" button, this will hide the module from SimpleIDE. The module does need to be reset in-order for the change to take place.

    Attached are the files needed to hide the module. I modified the sscp-setting.c file because I was getting compile errors using Clock Loop's guide.


    @iseries
    Mike, thanks again for taking the time to add the "Hide from Loader" setting to the WX Module, and sharing the files with the rest of us.




    Shawn





Sign In or Register to comment.