Arduino Primo wifi switches back to AP mode when powered off

I have had some success with my Arduino Primo wifi, but would like to use Arduino Primo securely. However, if power is interrupted and then restored, the mode switches back from STA to AP + STA.

The documentation from Arduino states that "It is important switching in STA MODE so the board will be visible on the Arduino IDE and, furthermore, you will be able to protect it from possible attacks, since it will no longer be visible as open network." Most devices like Wemo stay in STA mode.

So, Please advise how to change the Arduino Primo back to the STA mode other than to reset from scratch. Ideally, it would be nice to have a command in the code to do so. Right now, I have observed that to change the mode I would have to go back, reload a non-wifi code like "blink" before it will switch modes.

Also, the command listen_service(client, "arduino") does not seem to work as suggested in the example "WifiRestServer". I had to delete this command and use client.readStringUntil('/') to see the "GET " command, then the appended data could be read.

explained here

Juraj, I'm afraid I need more details to follow your advice.

I do not understand what "brick the esp8266 to block the AP" means. Tried to search but with no success.

I also looked at A Beginner's Guide to the ESP8266, which seemed to suggest ways to put in different modes, but the instruction to do Station mode and AP seemed identical (both used WiFi.begin the same way).

Also don't understand " put a sketch into esp8266, which turns off AP and has OTA support, for future experiments"

Also, please address problem with listen_service() function.

esp8266 on Primo is a dead end. sooner or later you hit the wall. your only way to changed the program in esp8266 is OTA. if it goes wrong you can never change it without soldering and the AP may be still active.

if you want to try something use only arduino esp8266 package version 2.4 rc1. not newer. 2.4 doesn't work without erasing the flash. and you can't erase the flash without serial connection.

I'm afraid I cannot follow your instructions. I do not know how to use only esp8266 package and what is "rcl".
Do I load a different version of IDE to do that? All I know is how to write code (following examples), link/upload the sketches and look for updates in the Board Manager. How do I know when I'm using flash memory?

rc1 is release candidate 1

esp8266 package: Arduino Primo is supported from version 2.4.0 rc1 of the esp8266 core for Arduino IDE. To install it using boards manager, follow the instructions.

Buy a Wemos or NodeMcu and learn esp8266 Test what you need to OTA upload to Primo. Because with Primo you do not have the trial and error option.

And do not forget, use only the 2.4.0 rc1 version of the sep8266 Arduino core.