Error when using date_time on wifi

Hi,

Added date_time to STA by referring to lwm2m_client.

NCS 2.3.0

nRF7002-DK

An error occurred as shown below.

[00:00:17.036,376] <wrn> date_time: ntp.uio.no getaddrinfo, error: -2

[00:00:17.036,407] <wrn> date_time: time.google.com getaddrinfo, error: -2

[00:00:17.036,437] <wrn> date_time: Did not get time from any NTP server

[00:00:17.036,437] <inf> sta: Could not obtain date-time update

It seems that getaddrinfo is not working properly.
remove getaddrinfo function code,
Entering the IP address manually in sntp_init works fine.

Is there a bug in getaddrinfo or do I need additional settings?

I am attaching the tested code.
You need to change ssid and password.

sta_date_time.zip

Thank you.

Parents
  • Hi,

     

    Thank you for sharing such detailed information, and a project to recreate the scenario. This is highly appreciated.

     

    It looks like the DNS resolver is not enabled by default. As you're using static IP, we'll also need to statically assign the DNS server.

    Here's an example of my added configurations to prj.conf:

    CONFIG_DATE_TIME_THREAD_STACK_SIZE=2048
    CONFIG_DNS_RESOLVER=y
    CONFIG_DNS_SERVER_IP_ADDRESSES=y
    CONFIG_DNS_SERVER1="8.8.8.8"
    
     

    At my end, this is the printed log afterwards:

    [00:00:06.863,494] <inf> sta: ==================
    [00:00:06.863,494] <inf> sta: State: SCANNING
    [00:00:07.163,635] <inf> sta: ==================
    [00:00:07.163,665] <inf> sta: State: SCANNING
    [00:00:07.463,775] <inf> sta: ==================
    [00:00:07.463,806] <inf> sta: State: SCANNING
    [00:00:07.583,435] <inf> wpa_supp: wlan0: SME: Trying to authenticate with fc:34:97:0b:f6:dc (SSID='OpenWrt' freq=5180 MHz)
    [00:00:07.586,730] <inf> wifi_nrf: wifi_nrf_wpa_supp_authenticate:Authentication request sent successfully
    
    [00:00:07.763,916] <inf> sta: ==================
    [00:00:07.763,946] <inf> sta: State: AUTHENTICATING
    [00:00:08.007,232] <inf> wpa_supp: wlan0: Trying to associate with fc:34:97:0b:f6:dc (SSID='OpenWrt' freq=5180 MHz)
    [00:00:08.013,824] <inf> wifi_nrf: wifi_nrf_wpa_supp_associate: Association request sent successfully
    
    [00:00:08.028,198] <inf> wpa_supp: wlan0: Associated with fc:34:97:0b:f6:dc
    [00:00:08.028,381] <inf> wpa_supp: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
    [00:00:08.047,180] <inf> wpa_supp: wlan0: WPA: Key negotiation completed with fc:34:97:0b:f6:dc [PTK=CCMP GTK=TKIP]
    [00:00:08.047,454] <inf> wpa_supp: wlan0: CTRL-EVENT-CONNECTED - Connection to fc:34:97:0b:f6:dc completed [id=0 id_str=]
    [00:00:08.055,725] <inf> sta: Connected
    [00:00:08.068,847] <inf> sta: ==================
    [00:00:08.068,878] <inf> sta: State: COMPLETED
    [00:00:08.068,908] <inf> sta: Interface Mode: STATION
    [00:00:08.068,908] <inf> sta: Link Mode: WIFI 6 (802.11ax/HE)
    [00:00:08.068,939] <inf> sta: SSID: OpenWrt                         
    [00:00:08.068,969] <inf> sta: BSSID: FC:34:97:0B:F6:DC
    [00:00:08.069,000] <inf> sta: Band: 5GHz
    [00:00:08.069,000] <inf> sta: Channel: 36
    [00:00:08.069,030] <inf> sta: Security: WPA2-PSK
    [00:00:08.069,030] <inf> sta: MFP: Optional
    [00:00:08.069,030] <inf> sta: RSSI: -57
    [00:00:08.069,061] <inf> sta: wait 3s
    [00:00:11.147,216] <inf> sta: Obtained date-time from NTP server
    

     

    Could you try this and see if it also works on your side?

     

    Kind regards,

    Håkon

  • Hi,

    Thank you for your answer.
    It works very well.

    Thank you.

  • Hi,

     

    I'm glad to hear that it worked!

    Hope you have a wonderful day!

     

    Cheers,

    Håkon

Reply Children
No Data
Related