Using Soft AP example - can't connect to HTTP

This rang a bell with me when I first read it as something I should go and check as I'm sure I had read it was safe. @jvanier & @mdma have previously stated that System.set will check the existing value first and then only change it if it is different, of course things might have changed since 2015...

@Nemiah, am wondering if you were able to sort out this problem?

I too am suffering with similar issues with SoftAP (using P1, DeviceOS 1.4.0).

With the device in listening mode

  • My laptop is reliably provided with an IP address (192.168.0.2) by the device (good)
  • Am able to ping the device (192.168.0.1) (good)
  • Browsing the device responds with “Connection Refused” (bad)
  • curl also return “Connection Refused” (bad)
  • debug reveals that “myPage()” is not called
  • softap_set_application_page_handler(myPage, nullptr) is called within STARTUP()
  • myPage is correctly forward declared
  • I note for the record that ping sometimes does not work… seems random…

I have had SoftAP working sometime in the past, but have had to define it out of recent times because of the 20K+ text overhead.

Am resurrecting its inclusion by setting refactoring myPage() to retrieve the static text from file instead. Am pretty sure that this code change is not the issue because of the debug - ** myPage() is simply not being called ** (as port 80 is not open).

Any thoughts? I note that there has been a lot of noise on the topic of SoftAP…

UPDATE: I was able to get reliable ping AND connection to the HTTP service on port 80 with the device.

How?

I put the device into SAFE MODE then into LISTEN MODE… I believe this to be the default SoftAP mode of operation and not my code, because there was no head or body content, just the the HTML tags.

Happy to report that I was able to sort this issue.

  • Extensive testing revealed that SoftAP requires circa 10K of free memory
  • I optimised memory usage, but still did not have enough for SoftAP usage
  • Resolved by workaround - some classes required large amounts of memory which was allocated to the BSS segment. Changed some of these classes to use heap memory for the large structures ( ie used malloc() ).
  • The trick was to not call the class .begin() method when in Listening Mode, hence memory would not be allocated to the class

Downsides are:

  • one needs to enter Listening Mode soon after reset, before loop() kicks off
  • you need to reset after using SofftAP to configure your WiFi

Case closed.

1 Like