Created Thu, 31 Aug 2017 08:38:45 +0000 by aabfm
Thu, 31 Aug 2017 08:38:45 +0000
Hi, Following the post "POST call on a mx7ck" I'm now facing another issue: how to force a specific DNS. Yesterday I managed to have the IP resolved but I was using DHCP with my router, today I'm at a different location where I was given a fixed IP, subnet mask and gateway, however I couldn't get the response from the server, i.e. there was no TRUE return from the tcpClient.isEstablished() call... :( The way around is this:
IPv4 ip = {193,0,0,171};
IPv4 subnet = {255,255,255,0};
IPv4 gatew = {193,0,0,3};
IPv4 dns = {193,0,0,1};
long unsigned int maxdns;
maxdns=deIPcK.setDNS(deIPcK.getcMaxDNS(),dns);
deIPcK.setDNS(maxdns,dns);
con=deIPcK.begin(ip,gatew,subnet);
I hope you find this info useful! Cheers.
Thu, 31 Aug 2017 09:44:39 +0000
Looking at the code to setDNS:
bool DEIPcK::setDNS(int index, const IPv4& ipDNS)
{
// get it set up if not already
if(_fBegun && ((uint32_t) index) < cDNSMax)
{
return(DNSAddNS(_pLLAdp, &ipDNS, index));
}
return(false);
}
it looks like it will only do anything if you have already called begin()
on your connection. So re-ordering your statements, and using 0 for the DNS index, should work:
IPv4 ip = {193,0,0,171};
IPv4 subnet = {255,255,255,0};
IPv4 gatew = {193,0,0,3};
IPv4 dns = {193,0,0,1};
con=deIPcK.begin(ip,gatew,subnet);
deIPcK.setDNS(0,dns);
Thu, 31 Aug 2017 11:12:51 +0000
You are completely right! Thanks for the tip.