Skip to content

Upgrade to 2.5.0 problems, ip_addr incompatibility and wrong pin definitions in pins_arduino.h #5730

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

Closed
codebeat-nl opened this issue Feb 6, 2019 · 6 comments

Comments

@codebeat-nl
Copy link

codebeat-nl commented Feb 6, 2019

When upgrading to 2.5.0, the following problems occur when compiling:

  • type ip_addr has been changed, now need to change it to ip4_addr and is no longer compatible with earlier versions.
  • Pin D0 to D5 are defined as variables in pins_arduino.h however incorrect. Get macro expansion errors when compiling. After removing my defines and using these pins definitions, esp starts to reboot all the time. D0 is 0, D1 = 1, etc. This is not correct, it refers to the wrong GPIO.

This is the correct mapping I have used all of the time and works just fine:

// ESP8266 Pin names to GPIO,  weird pin mapping correction.
// https://github.com/esp8266/Arduino/blob/master/variants/nodemcu/pins_arduino.h#L37-L59
// Pin numbers written on the board itself do not correspond to ESP8266 GPIO pin numbers. 
// The defines below make using this board easier (If you want to use esp pin 5, 
// use D5 for pin number, and it will be translated to 'real' GPIO pin 14):

#define D0 16 // supports PWM
#define D1  5 // I2C Bus SCL (clock)
#define D2  4 // I2C Bus SDA (data)
#define D3  0
#define D4  2 // Same as "LED_BUILTIN", but inverted logic
#define D5 14 // SPI Bus SCK (clock)
#define D6 12 // SPI Bus MISO 
#define D7 13 // SPI Bus MOSI
#define D8 15 // SPI Bus SS (CS)
#define D9  3 // RX0 (Serial console)
#define D10 1 // TX0 (Serial console)

#define SD0   7
#define SD1   8
#define SD2   9
#define SD3   10
#define SDCMD 11
@d-a-v
Copy link
Collaborator

d-a-v commented Feb 6, 2019

You don't give much details.
What was the previous core version you were using ?

type ip_addr has been changed, now need to change it to ip4_addr and is no longer compatible with earlier versions.

When possible, IPAddress variables should be used in place of any ip_addr/_t types where ip.addr or ip->addr were used. This is much more compatible.

Pins are defined in variants/. Did you select the wrong one ?
In arduino IDE, board selection defines pins definition.

@codebeat-nl
Copy link
Author

codebeat-nl commented Feb 6, 2019

Previous version was: 2.4.0

Error when defining for example D0 in my h-file:

Users\Codebeat\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\variants\ESPDuino/pins_arduino.h:35:22: note: in expansion of macro 'D0'

 static const uint8_t D0   = 0;

exit status 1

@codebeat-nl codebeat-nl changed the title Upgrade to 2.5.0 problems, ip_addr incompatibility and wrong pin definitions in arduino_pins.h Upgrade to 2.5.0 problems, ip_addr incompatibility and wrong pin definitions in pins_arduino.h Feb 6, 2019
@codebeat-nl
Copy link
Author

codebeat-nl commented Feb 6, 2019

I use ip_addr with use of stat_info:

String suGetClientMacAddress( SUWebServerRequest* request )
{ 
  if( !!(request) && suIsAccessPointMode() )
   {  
     struct ip4_addr*      IPaddress; // <-- This is now changed, was ip_addr in version 2.4.0
     IPAddress             ip;
     struct station_info*  stat_info = wifi_softap_get_station_info();
     String                sClientIp = suGetClientIp( request );
     
     Serial.print( "Client ip: " );
     Serial.println( sClientIp );
     
     if( sClientIp.length() > 0 )
     {
      while( stat_info ) 
      {
        IPaddress = &stat_info->ip;
        ip = IPaddress->addr;
        
        if( suIpAddressToString( ip ) == sClientIp )
        {
          return String( stat_info->bssid[0], HEX )+":"+
                 String( stat_info->bssid[1], HEX )+":"+
                 String( stat_info->bssid[2], HEX )+":"+
                 String( stat_info->bssid[3], HEX )+":"+
                 String( stat_info->bssid[4], HEX )+":"+
                 String( stat_info->bssid[5], HEX );
        } 
       
        stat_info = STAILQ_NEXT(stat_info, next);
      }
     } 
   }
  
  return "";  
}

@d-a-v
Copy link
Collaborator

d-a-v commented Feb 6, 2019

String suGetClientMacAddress( SUWebServerRequest* request )
{ 
  if( !!(request) && suIsAccessPointMode() )
   {  
     struct station_info*  stat_info = wifi_softap_get_station_info();
     String                sClientIp = suGetClientIp( request );
     
     Serial.print( "Client ip: " );
     Serial.println( sClientIp );
     
     if( sClientIp.length() > 0 )
     {
      while( stat_info ) 
      {
        IPAddress ip = stat_info->ip; // should work
        // or IPAddress ip = stat_info->ip->addr; // should work too, less portable
        // String ipString = ip.toString(); // may be useful
        
        if( suIpAddressToString( ip ) == sClientIp )
        {
          return String( stat_info->bssid[0], HEX )+":"+
                 String( stat_info->bssid[1], HEX )+":"+
                 String( stat_info->bssid[2], HEX )+":"+
                 String( stat_info->bssid[3], HEX )+":"+
                 String( stat_info->bssid[4], HEX )+":"+
                 String( stat_info->bssid[5], HEX );
        } 
       
        stat_info = STAILQ_NEXT(stat_info, next);
      }
     } 
   }
  
  return "";  
}

@d-a-v
Copy link
Collaborator

d-a-v commented Feb 7, 2019

`...Arduino15\packages\esp8266\hardware\esp8266\2.5.0\variants\ESPDuino/pins_arduino.h:35:22: note: in expansion of macro 'D0'``

This missing definition that you need was fixed for everybody in #4828.
You may check ARDUINO_ESP8266_RELEASE_2_5_0 and coreVersionNumeric() if you need conditional compilation (first is defined in cores/esp8266/core_version.h, second in cores/esp8266/core_esp8266_version.h, both already included in your sketch)

@devyte
Copy link
Collaborator

devyte commented Feb 15, 2019

Closing due to user error.

@devyte devyte closed this as completed Feb 15, 2019
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

3 participants