EliasKotlyar / Xiaomi-Dafang-Hacks

4.16k stars 1k forks source link

setting the correct date / time #1797

Open jammmyb opened 2 years ago

jammmyb commented 2 years ago

i am running this on two different cameras.

one is a Neos SmartCam and the other is the Xiaomi Dafang.

the Dafang has the correct date / time, but the smartcam is Current time is Thu Sep 17 02:26:14 BST 1970 - GMT0BST,M3.5.0/1,M10.5.0

dafang smartcam

how do i fix this please?

mercs600 commented 2 years ago

I noticed the same issue, any solution ?

c--- commented 2 years ago

If you ssh in to the camera then run:

ntpd -d -w -p time.google.com

Do you get replies?

kittenarmy commented 2 years ago

I have the same issue.

ntpd -d -w -p time.google.com

@c--- I get replies after editing resolv.conf but it still doesn't update the clock. I suspect because the date is too far out, but the -g option to override is not available with this busybox version of ntpd. No idea how to get this option included.

I also had edited defaultgw.conf since I'm using static IP as per #1504

c--- commented 2 years ago

@kittenarmy My ntpd command was just to test the network. If you want to set the time then remove the -w option.

kittenarmy commented 2 years ago

@kittenarmy My ntpd command was just to test the network. If you want to set the time then remove the -w option.

Ahh thank you! It works over SSH but I can't get it to work in run.sh or as a user script. There doesn't seem a way to get debug info on it.

Screenshot 2022-04-18 at 23 28 15

jammmyb commented 2 years ago

ssh

still wrong date/time

what can i try next?

@c--- i googled your command to see if there was other things to try.

c--- commented 2 years ago

If you want to debug and set the time then you need to use something like:

ntpd -d -n -p time.google.com

Without the -n or -w option it's going to fork in to the background and won't output the debugging messages.

It might be a good idea to make sure there are not multiple ntpd running. ps|grep ntpd

In theory ntpd is started from /system/sdcard/run.sh and can be verified that it's running by using the same ps command ps|grep ntpd. If the debugging tests succeed and the automated service is active and running but the time is not being set then I'm not sure what could be going on. Possibly the ntp server in ntp_srv.conf is incorrect or for some unknown reason the background service can't set the system time.

kittenarmy commented 2 years ago

I ran ps|grep ntpd and got two lines:

  279 root      0:00 /system/sdcard/bin/busybox ntpd -p time.google.com
  899 root      0:00 busybox grep ntpd
cecildaniel2003 commented 2 years ago

I have the same issue, but for me it says network is unreachable.

[root@DAFANG:~]# ntpd -d -w -p time.google.com ntpd: 'time.google.com' is 216.239.35.8 ntpd: sending query to 216.239.35.8 ntpd: send failed: Network is unreachable

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

herrxyz commented 1 year ago

image unfortunately, timezone is not set correctly in my device (shown 8am, should be 10am in Berlin time) dafang-cam, github-repo from 2023-04-15 ssh-output:

[root@DAFANG:~]# ntpd -d -w -p de.pool.ntp.org
ntpd: 'de.pool.ntp.org' is 129.70.132.32
ntpd: sending query to 129.70.132.32
ntpd: reply from 129.70.132.32: offset:-0.001118 delay:0.050575 status:0x24 strat:2 refid:0x52894681 rootdelay:0.000244 reach:0x01

-> seems to get a time from ntp

[root@DAFANG:~]# ps|grep ntpd
  262 root      0:00 /system/sdcard/bin/busybox ntpd -p de.pool.ntp.org
 1110 root      0:00 busybox grep ntpd

for testing, switched timezone to Australia/Adelaide, rebootet, still 8am in OSD image

-> timezone does not get set (or at least not for OSD)

gomako commented 1 year ago

I am also experiencing this. Manually set in web interface to time.google.com or time.cloudflare.com If I run ntpd -d -n -p time.google.com then I get ntpd: bad address 'time.google.com' However, if I run ntpd -d -n -p 216.239.35.12 then it sets the time correctly. 216.239.35.12 is the IP address of time.google.com. Maybe there is a domain lookup issue? I have used the IP address in the web config and it seems to save it correctly. Hopefully that will help someone!