Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wifievent problem #9

Open
ponchatello opened this issue Dec 21, 2020 · 13 comments
Open

wifievent problem #9

ponchatello opened this issue Dec 21, 2020 · 13 comments

Comments

@ponchatello
Copy link

I have this error, any solution? im begginer

Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

tello_example:64:16: error: variable or field 'WiFiEvent' declared void

void WiFiEvent(WiFiEvent_t event)

            ^

tello_example:64:16: error: 'WiFiEvent_t' was not declared in this scope

C:\Users\neuro\Downloads\telloArduino-master\telloArduino-master\tello_example\tello_example.ino: In function 'void connectToWiFi(const char*, const char*)':

tello_example:53:23: error: no matching function for call to 'WiFiClass::disconnect(bool)'

WiFi.disconnect(true);

                   ^

C:\Users\neuro\Downloads\telloArduino-master\telloArduino-master\tello_example\tello_example.ino:53:23: note: candidate is:

In file included from C:\Users\neuro\Documents\Arduino\libraries\tello/Tello.h:12:0,

             from C:\Users\neuro\Downloads\telloArduino-master\telloArduino-master\tello_example\tello_example.ino:1:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\libraries\WiFi\src/WiFi.h:130:9: note: int WiFiClass::disconnect()

 int disconnect(void);

     ^

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\libraries\WiFi\src/WiFi.h:130:9: note: candidate expects 0 arguments, 1 provided

tello_example:55:8: error: 'class WiFiClass' has no member named 'onEvent'

WiFi.onEvent(WiFiEvent);

    ^

tello_example:55:16: error: 'WiFiEvent' was not declared in this scope

WiFi.onEvent(WiFiEvent);

            ^

tello_example:58:23: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]

WiFi.begin(ssid, pwd);

                   ^

In file included from C:\Users\neuro\Documents\Arduino\libraries\tello/Tello.h:12:0,

             from C:\Users\neuro\Downloads\telloArduino-master\telloArduino-master\tello_example\tello_example.ino:1:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\libraries\WiFi\src/WiFi.h:79:9: error: initializing argument 1 of 'int WiFiClass::begin(char*, const char*)' [-fpermissive]

 int begin(char* ssid, const char *passphrase);

     ^

C:\Users\neuro\Downloads\telloArduino-master\telloArduino-master\tello_example\tello_example.ino: At global scope:

tello_example:64:16: error: variable or field 'WiFiEvent' declared void

void WiFiEvent(WiFiEvent_t event)

            ^

tello_example:64:16: error: 'WiFiEvent_t' was not declared in this scope

exit status 1

variable or field 'WiFiEvent' declared void

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

@mateustoin
Copy link

Coloque essas duas linhas depois do include:

void connectToWiFi(const char * ssid, const char * pwd);
void WiFiEvent(WiFiEvent_t event) ;

This error occurs because the functions used to connect to WiFi are at the end of the code, without having been declared before. So your code considers that they don't exist. That should do it!

@ponchatello
Copy link
Author

i don't understand
in which part should I place this lines?

@mateustoin
Copy link

After #include <Tello.h>

@ponchatello
Copy link
Author

hablas español?

No logro hacerlo funcionar, lo coloque hasta el principio del código, pero da exactamente le mismo error
queria adjuntar unas imagenes pero no puedo

#include <Tello.h>

#include <Tello.h>

#include <Tello.h>

void connectToWiFi(const char * ssid, const char * pwd);
void WiFiEvent(WiFiEvent_t event);

// WiFi network name and password:
const char * networkName = "TELLO-5F7BE8";//Replace with your Tello SSID
const char * networkPswd = "dronatello";

//Are we currently connected?
boolean connected = false;

@DEAD-GOST
Copy link

still same problem

@DEAD-GOST
Copy link

`#include <Tello.h>

#include <Tello.h>

void connectToWiFi(const char * ssid, const char * pwd)
{
Serial.println("Connecting to WiFi network: " + String(ssid));

// delete old config
WiFi.disconnect(true);
//register event handler
WiFi.onEvent(WiFiEvent);

//Initiate connection
WiFi.begin(ssid, pwd);

Serial.println("Waiting for WIFI connection...");
}

//wifi event handler
void WiFiEvent(WiFiEvent_t event)
{
switch (event)
{
case SYSTEM_EVENT_STA_GOT_IP:
//When connected set
Serial.print("WiFi connected! IP address: ");
Serial.println(WiFi.localIP());
//initialise Tello after we are connected
tello.init();
connected = true;
break;

case SYSTEM_EVENT_STA_DISCONNECTED:
  Serial.println("WiFi lost connection");
  connected = false;
  break;

}
}

// WiFi network name and password:
const char * networkName = "TELLO-XXXXXX";//Replace with your Tello SSID
const char * networkPswd = "";

//Are we currently connected?
boolean connected = false;

Tello tello;

void setup()
{
Serial.begin(9600);
//Connect to the WiFi network
connectToWiFi(networkName, networkPswd);
}

void loop()
{
// put your main code here, to run repeatedly:
if(connected )
{
tello.takeoff();
delay(5000);
tello.up(30);
delay(2000);
tello.down(30);
delay(2000);
tello.right(30);
delay(2000);
tello.left(30);
delay(2000);
tello.land();
//you have 5 seconds to save your tello before it takes off again
delay(5000);

//do once and go into a while loop
while(1)
{
  delay(5000);
}

}
}

`

void WiFiEvent(WiFiEvent_t event)
^
test-2:22:16: error: 'WiFiEvent_t' was not declared in this scope
exit status 1
variable or field 'WiFiEvent' declared void

@whateverfast
Copy link

I have the same problem.

tello_example:6:6: error: variable or field 'WiFiEvent' declared void
    6 | void WiFiEvent(WiFiEvent_t event);
      |      ^~~~~~~~~
tello_example:6:16: error: 'WiFiEvent_t' was not declared in this scope
    6 | void WiFiEvent(WiFiEvent_t event);
      |                ^~~~~~~~~~~
/Users/Emanuel/Downloads/telloArduino-master/tello_example/tello_example.ino: In function 'void connectToWiFi(const char*, const char*)':
tello_example:56:23: error: no matching function for call to 'WiFiClass::disconnect(bool)'
   56 |   WiFi.disconnect(true);
      |                       ^
In file included from /Users/Emanuel/Documents/Arduino/libraries/tello/Tello.h:12,
                 from /Users/Emanuel/Downloads/telloArduino-master/tello_example/tello_example.ino:1:
/Applications/Arduino.app/Contents/Java/libraries/WiFi/src/WiFi.h:130:9: note: candidate: 'int WiFiClass::disconnect()'
  130 |     int disconnect(void);
      |         ^~~~~~~~~~
/Applications/Arduino.app/Contents/Java/libraries/WiFi/src/WiFi.h:130:9: note:   candidate expects 0 arguments, 1 provided
tello_example:58:8: error: 'class WiFiClass' has no member named 'onEvent'
   58 |   WiFi.onEvent(WiFiEvent);
      |        ^~~~~~~
tello_example:58:16: error: 'WiFiEvent' was not declared in this scope; did you mean 'WiFiClient'?
   58 |   WiFi.onEvent(WiFiEvent);
      |                ^~~~~~~~~
      |                WiFiClient
tello_example:61:14: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
   61 |   WiFi.begin(ssid, pwd);
      |              ^~~~
      |              |
      |              const char*
In file included from /Users/Emanuel/Documents/Arduino/libraries/tello/Tello.h:12,
                 from /Users/Emanuel/Downloads/telloArduino-master/tello_example/tello_example.ino:1:
/Applications/Arduino.app/Contents/Java/libraries/WiFi/src/WiFi.h:79:21: note:   initializing argument 1 of 'int WiFiClass::begin(char*, const char*)'
   79 |     int begin(char* ssid, const char *passphrase);
      |               ~~~~~~^~~~
/Users/Emanuel/Downloads/telloArduino-master/tello_example/tello_example.ino: At global scope:
tello_example:67:6: error: variable or field 'WiFiEvent' declared void
   67 | void WiFiEvent(WiFiEvent_t event) {
      |      ^~~~~~~~~
tello_example:67:16: error: 'WiFiEvent_t' was not declared in this scope
   67 | void WiFiEvent(WiFiEvent_t event) {
      |                ^~~~~~~~~~~
exit status 1
variable or field 'WiFiEvent' declared void

HELP ?

@DEAD-GOST
Copy link

I have resolved this, by creating my own Lib

@DEAD-GOST
Copy link

@DEAD-GOST
Copy link

Video
https://youtu.be/Zdl6R5u_-Ok

@DEAD-GOST
Copy link

I have the same problem.

tello_example:6:6: error: variable or field 'WiFiEvent' declared void
    6 | void WiFiEvent(WiFiEvent_t event);
      |      ^~~~~~~~~
tello_example:6:16: error: 'WiFiEvent_t' was not declared in this scope
    6 | void WiFiEvent(WiFiEvent_t event);
      |                ^~~~~~~~~~~
/Users/Emanuel/Downloads/telloArduino-master/tello_example/tello_example.ino: In function 'void connectToWiFi(const char*, const char*)':
tello_example:56:23: error: no matching function for call to 'WiFiClass::disconnect(bool)'
   56 |   WiFi.disconnect(true);
      |                       ^
In file included from /Users/Emanuel/Documents/Arduino/libraries/tello/Tello.h:12,
                 from /Users/Emanuel/Downloads/telloArduino-master/tello_example/tello_example.ino:1:
/Applications/Arduino.app/Contents/Java/libraries/WiFi/src/WiFi.h:130:9: note: candidate: 'int WiFiClass::disconnect()'
  130 |     int disconnect(void);
      |         ^~~~~~~~~~
/Applications/Arduino.app/Contents/Java/libraries/WiFi/src/WiFi.h:130:9: note:   candidate expects 0 arguments, 1 provided
tello_example:58:8: error: 'class WiFiClass' has no member named 'onEvent'
   58 |   WiFi.onEvent(WiFiEvent);
      |        ^~~~~~~
tello_example:58:16: error: 'WiFiEvent' was not declared in this scope; did you mean 'WiFiClient'?
   58 |   WiFi.onEvent(WiFiEvent);
      |                ^~~~~~~~~
      |                WiFiClient
tello_example:61:14: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
   61 |   WiFi.begin(ssid, pwd);
      |              ^~~~
      |              |
      |              const char*
In file included from /Users/Emanuel/Documents/Arduino/libraries/tello/Tello.h:12,
                 from /Users/Emanuel/Downloads/telloArduino-master/tello_example/tello_example.ino:1:
/Applications/Arduino.app/Contents/Java/libraries/WiFi/src/WiFi.h:79:21: note:   initializing argument 1 of 'int WiFiClass::begin(char*, const char*)'
   79 |     int begin(char* ssid, const char *passphrase);
      |               ~~~~~~^~~~
/Users/Emanuel/Downloads/telloArduino-master/tello_example/tello_example.ino: At global scope:
tello_example:67:6: error: variable or field 'WiFiEvent' declared void
   67 | void WiFiEvent(WiFiEvent_t event) {
      |      ^~~~~~~~~
tello_example:67:16: error: 'WiFiEvent_t' was not declared in this scope
   67 | void WiFiEvent(WiFiEvent_t event) {
      |                ^~~~~~~~~~~
exit status 1
variable or field 'WiFiEvent' declared void

HELP ?

I have solved this

@konradsoares
Copy link

Using ESP8266WiFi.h library and getting this error.

C:\Users\xxx\Documents\Arduino\tello\tello_example\tello_example.ino: In function 'void WiFiEvent(WiFiEvent_t)':
C:\Users\xxx\Documents\Arduino\tello\tello_example\tello_example.ino:68:10: error: 'SYSTEM_EVENT_STA_GOT_IP' was not declared in this scope
68 | case SYSTEM_EVENT_STA_GOT_IP:
| ^~~~~~~~~~~~~~~~~~~~~~~
C:\Users\xxx\Documents\Arduino\tello\tello_example\tello_example.ino:77:10: error: 'SYSTEM_EVENT_STA_DISCONNECTED' was not declared in this scope; did you mean 'WIFI_EVENT_STAMODE_DISCONNECTED'?
77 | case SYSTEM_EVENT_STA_DISCONNECTED:
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| WIFI_EVENT_STAMODE_DISCONNECTED

exit status 1

Compilation error: 'SYSTEM_EVENT_STA_GOT_IP' was not declared in this scope

@konradsoares
Copy link

After changing
#include <Tello.h>
#include <ESP8266WiFi.h>

// WiFi network name and password:
const char * networkName = "TELLO-xxxxxxxx";//Replace with your Tello SSID
const char * networkPswd = "";

//Are we currently connected?
boolean connected = false;

Tello tello;

void setup()
{
Serial.begin(9600);
//Connect to the WiFi network
connectToWiFi(networkName, networkPswd);
}

void loop()
{
// put your main code here, to run repeatedly:
if(connected )
{
tello.takeoff();
delay(5000);
tello.up(30);
delay(2000);
tello.down(30);
delay(2000);
tello.right(30);
delay(2000);
tello.left(30);
delay(2000);
tello.land();
//you have 5 seconds to save your tello before it takes off again
delay(5000);

//do once and go into a while loop
while(1)
{
  delay(5000);
}

}
}

void connectToWiFi(const char * ssid, const char * pwd)
{
Serial.println("Connecting to WiFi network: " + String(ssid));

// delete old config
WiFi.disconnect(true);
//register event handler
WiFi.onEvent(WiFiEvent);

//Initiate connection
WiFi.begin(ssid, pwd);

Serial.println("Waiting for WIFI connection...");
}

//wifi event handler
void WiFiEvent(WiFiEvent_t event)
{
switch (event)
{
case WIFI_EVENT_STAMODE_CONNECTED:
Serial.println("WiFi connected");
break;

case WIFI_EVENT_STAMODE_DISCONNECTED:
  Serial.println("WiFi disconnected");
  connected = false;
  break;
  
case WIFI_EVENT_STAMODE_GOT_IP:
  Serial.print("WiFi connected! IP address: ");
  Serial.println(WiFi.localIP());
  //initialise Tello after we are connected
  tello.init();
  connected = true;
  break;

}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants