How to set and get DNS-Server on new rpcWiFi lib for Wio Terminal?

Hi @ ansonhe97, I confirm that now the DNS is managed correctly even if the WiFi.begin () declaration sequence remains, which must be put before the WiFi.config () altriminti does not work. However, I also found a problem with the management of the WiFiClient. It seems that it does not respond correctly or in any case with a long time. If I try to use it to query MySQL the call times out. The same code used with an Ethernet shield works fine. I am attaching the code I used and the display of the serial monitor.

Code

Click to see the code

#include <WiFi.h>

#include “defines.h”

#include “Credentials.h”

#include <rpcWiFiClient.h>

#include <MySQL_Generic_Connection.h>

#include <MySQL_Generic_Query.h>

const char QUERY_TEST[] = “SELECT ATH50.Device.ChangeCFG FROM ATH50.Device WHERE ATH50.Device.idDevice = 1”;

WiFiClient client;

MySQL_Connection conn((Client *)&client);

#define WIFI_USE_SAMD

#define SEEED_WIO_TERMINAL

#define USING_WIFI_CUSTOM

void runQuery(void)

{

Serial.println("====================================================");

Serial.println("> Running SELECT with dynamically supplied parameter");

// Initiate the query class instance

MySQL_Query query_mem = MySQL_Query(&conn);

// Execute the query

// KH, check if valid before fetching

if (!query_mem.execute(QUERY_TEST))

{

Serial.println("Querying error");

return;

}

// Fetch the columns and print them

column_names *cols = query_mem.get_columns();

for (int f = 0; f < cols->num_fields; f++)

{

Serial.print(cols->fields[f]->name);

if (f < cols->num_fields - 1)

{

  Serial.print(",");

}

}

Serial.println();

// Read the rows and print them

row_values *row = NULL;

do

{

row = query_mem.get_next_row();

if (row != NULL)

{

  for (int f = 0; f < cols->num_fields; f++)

  {

    Serial.print(row->values[f]);

    if (f < cols->num_fields - 1)

    {

      Serial.print(",");

    }

  }

  Serial.println();

}

} while (row != NULL);

}

void setup()

{

Serial.begin(115200);

while (!Serial)

;

WiFi.begin(ssid, pass);

if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS))

{

Serial.println("STA Failed to configure");

}

Serial.print("Connecting to ");

Serial.println(ssid);

while (WiFi.status() != WL_CONNECTED)

{

delay(500);

Serial.print(".");

}

Serial.println("");

Serial.println(“WiFi connected!”);

Serial.print("IP address: ");

Serial.println(WiFi.localIP());

Serial.print("ESP Mac Address: ");

Serial.println(WiFi.macAddress());

Serial.print("Subnet Mask: ");

Serial.println(WiFi.subnetMask());

Serial.print("Gateway IP: ");

Serial.println(WiFi.gatewayIP());

Serial.print("DNS: ");

Serial.println(WiFi.dnsIP());

Serial.print("Connecting to SQL Server @ ");

Serial.print(server_addr);

Serial.println(String(", Port = ") + server_port);

//Serial.println(String("User = “) + user + String(”, PW = “) + password + String(”, DB = ") + default_database);

}

void loop()

{

Serial.println(“Connecting…”);

if (conn.connect(server_addr, server_port, user, password))

{

delay(500);

runQuery();

conn.close(); // close the connection

}

else

{

Serial.println("\nConnect failed. Trying again on next iteration.");

}

Serial.println("\nSleeping…");

Serial.println("================================================");

delay(10000);

}

Serial Monitor

Click to see the code

Connecting to D-Link-GR 2.4 Gz

WiFi connected!
IP address: 192.168.0.87
ESP Mac Address: 2c:f7:f1:1b:47:a9
Subnet Mask: 255.255.255.0
Gateway IP: 192.168.0.1
DNS: 8.8.8.8
Connecting to SQL Server @ 5.150.142.221, Port = 3306
Connecting…
[SQL] Connecting to Server: 5.150.142.221 , Port = 3306
[SQL] Connect OK. Try reading packets
[SQL] MySQL_Packet::wait_for_bytes: OK, Num bytes= 102
[SQL] MySQL_Packet::read_packet: packet_len= 98
[SQL] MySQL_Packet::read_packet: First time allocate buffer, size = 102
[SQL] MySQL_Packet::read_packet: exit
[SQL] Try parsing packets
[SQL] Try send_authentication packets
[SQL] MySQL_Packet::wait_for_bytes: OK, Num bytes= 11
[SQL] MySQL_Packet::read_packet: packet_len= 7
[SQL] MySQL_Packet::read_packet: exit
[SQL] MySQL_Packet::get_packet_type: packet type= 0
[SQL] MySQL_Packet::get_packet_type: packet type= MYSQL_OK_PACKET
[SQL] Connected. Server Version = 5.5.5-10.1.47-MariaDB-0+deb9u1

Running SELECT with dynamically supplied parameter
[SQL] MySQL_Query::execute: Reuse allocated buffer, conn->largest_buffer_size = 102 > 84
[SQL] MySQL_Query::execute: query = SELECT ATH50.Device.ChangeCFG FROM ATH50.Device WHERE ATH50.Device.idDevice = 1
[SQL] MySQL_Query::execute_query: query = SELECT ATH50.Device.ChangeCFG FROM ATH50.Device WHERE ATH50.Device.idDevice = 1
[SQL] MySQL_Packet::wait_for_bytes: client->stop
[SQL] MySQL_Packet::wait_for_bytes: OK, Num bytes= 0
[SQL] MySQL_Packet::read_packet: ERROR: Timeout waiting for client.
Querying error