@@ -509,6 +509,26 @@ const char *ESP8266Interface::get_ip_address()
509509 return ip_buff;
510510}
511511
512+ nsapi_error_t ESP8266Interface::get_ip_address (SocketAddress *address)
513+ {
514+ if (_software_conn_stat == IFACE_STATUS_DISCONNECTED) {
515+ _esp.uart_enable_input (true );
516+ }
517+
518+ const char *ip_buff = _esp.ip_addr ();
519+ if (!ip_buff || strcmp (ip_buff, " 0.0.0.0" ) == 0 ) {
520+ ip_buff = NULL ;
521+ }
522+ if (_software_conn_stat == IFACE_STATUS_DISCONNECTED) {
523+ _esp.uart_enable_input (false );
524+ }
525+ if (ip_buff) {
526+ address->set_ip_address (ip_buff);
527+ return NSAPI_ERROR_OK;
528+ }
529+ return NSAPI_ERROR_NO_ADDRESS;
530+ }
531+
512532const char *ESP8266Interface::get_mac_address ()
513533{
514534 if (_software_conn_stat == IFACE_STATUS_DISCONNECTED) {
@@ -522,11 +542,43 @@ const char *ESP8266Interface::get_mac_address()
522542 return ret;
523543}
524544
545+ nsapi_error_t ESP8266Interface::get_gateway (SocketAddress *address)
546+ {
547+ if (address == nullptr ) {
548+ return NSAPI_ERROR_PARAMETER;
549+ }
550+ if (_conn_stat == NSAPI_STATUS_DISCONNECTED) {
551+ return NSAPI_ERROR_NO_CONNECTION;
552+ }
553+
554+ if (!address->set_ip_address (_esp.gateway ())) {
555+ return NSAPI_ERROR_NO_ADDRESS;
556+ }
557+
558+ return NSAPI_ERROR_OK;
559+ }
560+
525561const char *ESP8266Interface::get_gateway ()
526562{
527563 return _conn_stat != NSAPI_STATUS_DISCONNECTED ? _esp.gateway () : NULL ;
528564}
529565
566+ nsapi_error_t ESP8266Interface::get_netmask (SocketAddress *address)
567+ {
568+ if (address == nullptr ) {
569+ return NSAPI_ERROR_PARAMETER;
570+ }
571+ if (_conn_stat == NSAPI_STATUS_DISCONNECTED) {
572+ return NSAPI_ERROR_NO_CONNECTION;
573+ }
574+
575+ if (!address->set_ip_address (_esp.gateway ())) {
576+ return NSAPI_ERROR_NO_ADDRESS;
577+ }
578+
579+ return NSAPI_ERROR_OK;
580+ }
581+
530582const char *ESP8266Interface::get_netmask ()
531583{
532584 return _conn_stat != NSAPI_STATUS_DISCONNECTED ? _esp.netmask () : NULL ;
0 commit comments