Go Down

Topic: esp8266 connect when starting to which AP? (Read 749 times) previous topic - next topic

BosseB

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):

Code: [Select]
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?

Juraj

#16
Apr 21, 2019, 07:55 am Last Edit: Apr 21, 2019, 07:59 am by Juraj
 
Code: [Select]
   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)

BosseB

I tried this:

Code: [Select]
    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?

Juraj


BosseB

// @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.
 
Code: [Select]
               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.

Juraj

#20
Apr 21, 2019, 02:11 pm Last Edit: Apr 21, 2019, 02:13 pm by Juraj
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.
 
Code: [Select]
               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.


BosseB

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...

Juraj

sorry, normal click, not second mouse button

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?

Juraj

#24
Apr 22, 2019, 12:10 pm Last Edit: Apr 22, 2019, 12:10 pm by Juraj
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.


BosseB

#25
Apr 22, 2019, 02:16 pm Last Edit: Apr 22, 2019, 02:16 pm by 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:

Juraj

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:

and if you click on it?

BosseB

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...

Juraj

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

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?

Go Up