I'm using bsdlib (v0.7.7) on nrf9160 without Zephyr. Our products are working fine in the field, but so far you need to specify the host by IP address. I'm trying to implement add DNS using nrf_getaddrinfo() but I fail to get any useful response. I cannot find any example using nrf_getaddrinfo(), and the API docs don't really explain how to use any of the parameters.
struct nrf_addrinfo hints;
memset (&hints, 0, sizeof (hints));
hints.ai_family = NRF_AF_INET;
hints.ai_socktype = NRF_SOCK_STREAM;
struct nrf_addrinfo *info;
int got = nrf_getaddrinfo("<our-url-here>", "http", &hints, &info);
I tried some variations of the parameters. All I ever get in response is 22, which tells me "Invalid argument". So I guess I'm using some parameter incorrectly. But I failed in guessing so far.
Could you provide a very basic working example usinf nrf_getaddrinfo() that requests the IP4 for a given domain string, that shows how every parameter is set. ATM all I can think of is doing DNS myself using UDP, but I would rather use the implemented solution.
I'm doing this in Germany using a 1nce sim card, so it is using Deutsche Telekom.
Edit:
To be on the safe side, I included a call to nrf_setdnsaddr() on modem setup (call reports success).
I took the code from this answer: https://devzone.nordicsemi.com/f/nordic-q-a/50029/nrf9160-modem-firmware-v1-0-0-setting-custom-dns-server/235419#235419
struct nrf_in_addr dns;
dns.s_addr = 134744072; // Google DNS, 8.8.8.8
const int err = nrf_setdnsaddr(NRF_AF_INET, &dns);
Log("LTE| set DNS: %d\n", err);