esp8266 connect when starting to which AP?

Well, I am using Sloeber IDE since a year ago to manage projects with many source files. But I don't know where to find an Examples menu item...

So I opened my old Arduino IDE and managed to find WiFiScan.
Its code is like this:

  int n = WiFi.scanNetworks();
  Serial.println("scan done");
  if (n == 0)
    Serial.println("no networks found");
  else
  {
    Serial.print(n);
    Serial.println(" networks found");
    for (int i = 0; i < n; ++i)
    {
      // Print SSID and RSSI for each network found
      Serial.print(i + 1);
      Serial.print(": ");
      Serial.print(WiFi.SSID(i));
      Serial.print(" (");
      Serial.print(WiFi.RSSI(i));
      Serial.print(")");
      Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*");
      delay(10);
    }
  }

Those print statements look the same to me...

EDIT:
Interestingly when I built the firmware it did not throw errors and I could upload the flash to my lab prototype and it runs!
Seems like the error messages in the IDE code window are Sloeber misinterpreting the code....

A WiFi scan takes 1.6 seconds and one result I have is this:

Rx: e9
Starting WiFi network scansl
scandone
usl
Scan done, T=1602
6 networks found
1: Karlbom (-85 dB) (mac= 54:A0:50:79:02:B8) (enc= *)
2: HP-Setup>09-M277 LaserJet (-54 dB) (mac= 42:49:0F:06:5F:09) (enc= open)
3: bossefiber (-46 dB) (mac= 2C:4D:54:4A:D3:E8) (enc= *)
4: bosseguest (-52 dB) (mac= 2C:4D:54:4A:D3:E9) (enc= *)
5: bossefiber (-82 dB) (mac= 88:D7:F6:BA:91:78) (enc= *)
6: VML 2.4GHz (-82 dB) (mac= AC:22:0B:87:A4:E0) (enc= *)
WiFi scan done[03]

#1 = our neighbor
#2 = my HP printer
#3&4 = my main router
#5 = my slave router 15 m away behind a number of walls
#6 = I have no idea

I think you'll be fine then ! Now it is just a matter of selection, if your slave router is still visible when far away.

One problem is that the ESP-07 has a built-in ceramic antenna and it is on the top edge of the module between pins 1 and 16.
Depending on the orientation of the plastic box it is inside the antenna lobe may or may not find the router's antenna.

I thought the ESP-07 has an external antenna connection point ? and a plastic box will hardly hamper your connection.

Deva_Rishi:
I think you'll be fine then ! Now it is just a matter of selection, if your slave router is still visible when far away.

Yes, I will have to create a WiFiConnect() function, which looks for multiple AP with the same ssid, then selects the strongest to connect to.

I thought the ESP-07 has an external antenna connection point ? and a plastic box will hardly hamper your connection.

Yes there is an external connector for an antenna. But there is also a ceramic antenna on board.
If you connect an external antenna thebn a 0 ohm resistor connecting the ceramic antenna must be removed.
I have done so on several other projects and it works good.
I have not said the plastic hampers the signal, but since the box can be placed on one of several sides it can be so oriented that there is no good signal from the AP. The ceramic antenna is parallel to two coordinates and at right angle to the last.

LATER
I have now written a WiFiConnectSta() function to connect to the strongest of the networks matching the ssid.
I am doing this using Sloeber IDE 4.2 and I am having some problems with its checking of the source code...
Here is my function (not yet tested on the real hardware):

bool ConnectWiFiSta(char *ssid, char *passwd)
{
	int i, j, m;
	bool ret = false;
	bool found = false;
	uint8_t mac[6];
	int32_t level, channel;

	SerialDebug.print("Starting WiFi scan to check availability at T="); SerialDebug.println(millis());
	m = WiFi.scanNetworks(); //Return network count.
	SerialDebug.print("Processing scan result at T="); SerialDebug.println(millis());
	if (m > 0) //Networks found
	{
		for (i = 0; i < m; i++) //Check if ssid compares
		{	
			if (strcmp(ssid, WiFi.SSID(i).c_str()) == 0) //We have a match!
			{
				if (!found)  //First match so grab whetever comes along
				{
					for (j = 0; j<6; j++) mac[j] = WiFi.BSSID(i)[j];
					level = WiFi.RSSI(i);
					channel = WiFi.channel(i);
					found = true; //Only once here...
				}
				else if (WiFi.RSSI(i) > level) //A new match is stronger
				{
					for (j = 0; j<6; j++) mac[j] = WiFi.BSSID(i)[j];
					level = WiFi.RSSI(i);
					channel = WiFi.channel(i);
				}
			}
		}
                if (found)
                {
		    //So we have checked the networks and have a good strength match
		    //Now connect:
	            WiFi.begin(ssid, passwd, channel, mac, true);
	            ret = true;
                }
	}
	return (ret);
}

It compiles OK, but Sloeber shows an error marker on each line dealing with the array of scan result, such as:
level = WiFi.RSSI(i);
All in all there are 8 such error bombs in the left side margin.
Apparently Sloeber cannot figure out that there is an overload where there is an index inside the call like (i).
What can I do to fix this?

   String ssid = WiFi.SSID(index); // @suppress("Invalid arguments")

Eclipse offers fixes in a pop-up on the error mark on left margin. most of the time they are not useful. (for Java it works much better)

I tried this:

    String ssid_s;

    m = WiFi.scanNetworks(); //Return network count.
    if (m > 0) //Networks found
    {
        for (i = 0; i < m; i++) //Check if ssid compares
        {
            ssid_s = WiFi.SSID(i); // <== Still marked with the bomb and invalid arguments
            ....

I thought that Sloeber is not able to correctly parse out the indexed version of the WiFi properties...
In that case maybe some update to an iclude file or similar would have helped, but which?

// @suppress("Invalid arguments")

Juraj:
// @suppress("Invalid arguments")

Isn't that a comment???
I treated it as such and did not include it, but if I paste it into one line the warning/error does not go away.

               SerialDebug.println(WiFi.BSSIDstr(i)); // @suppress("Invalid arguments")

                if (!found)  //First match so grab whatever comes along
                {
                    for (j = 0; j<6; j++) mac[j] = WiFi.BSSID(i)[j];
                    level = WiFi.RSSI(i);
                    channel = WiFi.channel(i); // @suppress("Invalid arguments")
                    found = true; //Only once here...
                }

Both lines above still show the warning, even after a build that succeeds.

BosseB:
Isn't that a comment???
I treated it as such and did not include it, but if I paste it into one line the warning/error does not go away.

               SerialDebug.println(WiFi.BSSIDstr(i)); // @suppress("Invalid arguments")

if (!found)  //First match so grab whatever comes along
                {
                    for (j = 0; j<6; j++) mac[j] = WiFi.BSSID(i)[j];
                    level = WiFi.RSSI(i);
                    channel = WiFi.channel(i); // @suppress("Invalid arguments")
                    found = true; //Only once here...
                }




Both lines above still show the warning, even after a build that succeeds.

open pop-up on the the mark on left border.

Screenshot from 2019-04-21 14-09-43.png

When you say "open pop-up" do you mean:

  • rightclick red mark on the border
  • Select "suppress" in the menu shown

That does not work for me, the pop-up menu that is shown when right-clicking is completely different and is the same independent of where in the left border I click. It has 13 items to select from starting with "Toggle Breakpoint".
Seems not related to the problem we are discussing.

I am on Sloeber 4.2 and I know there is a newer version available, could this be something new in a newer Sloeber?
Unfortunately I did not dare upgrade because the description on how to do it was so incredibly difficult to follow and I stayed with the "working" version...

sorry, normal click, not second mouse button

I cannot get that menu pop-up to appear whatever I do.
Is it part of a newer Sloeber version?
I am on 4.2

If so is there any upgrade path or do I have to install a side by side higher version and configure it to work like the one I have?

BosseB:
I cannot get that menu pop-up to appear whatever I do.
Is it part of a newer Sloeber version?
I am on 4.2

If so is there any upgrade path or do I have to install a side by side higher version and configure it to work like the one I have?

you can simply copy the comment

it is Eclipse C++ support.

ezgif.com-video-to-gif.gif

I don't see this at all. When I hover the mouse over the red mark a small rectangle appears with a yellow text box below.
Please see the attached image:
sloeber_invalid_argument.png

BosseB:
I don't see this at all. When I hover the mouse over the red mark a small rectangle appears with a yellow text box below.
Please see the attached image:
sloeber_invalid_argument.png

and if you click on it?

If I click on the red blob the message disappears momentarily and then returns.
If I click on the little green point to the right, it adds a breakpoint on that line.

Nothing else seems to happen and if I again click the green point the breakpoint disappears.

Must be some mis-configuration inside Sloeber 4.2...

I have a year old Eclipse Oxygen instalation with Sloeber as add-on

OK, I'll give up now. After all the code builds OK.
The issue is about Eclipse/Sloeber and probably requires a different topic.
I wonder if Jantje reads this forum?

BosseB:
OK, I'll give up now. After all the code builds OK.
The issue is about Eclipse/Sloeber and probably requires a different topic.
I wonder if Jantje reads this forum?

Sloeber only uses existing Eclipse C++ development support. This problem is there