Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AScheduler is using NTP only #385

Closed
xoseperez opened this issue Jan 10, 2018 · 3 comments
Closed

AScheduler is using NTP only #385

xoseperez opened this issue Jan 10, 2018 · 3 comments

Comments

@xoseperez
Copy link
Owner

Originally reported by: Stefano Cotterli (Bitbucket: faina09, GitHub: faina09)


thank you for accepting my pull request!

I know there are some issues on UI, hope you can fix (I am not expert in pure css)

I found a bug in my code: I use NTP only and if the device is not connected to the network the scheduler don't trigger.

I fixed it using internal time, modifyng ascheduler.ino in two points:

#!arduino
LINE 59:
        if (!ntpConnected()){
            time_t t = now();
            sec = second(t);
            DEBUG_MSG_P(PSTR("[SCH] no NTP, time now=%02d:%02d:%02d\n"),hour(t),minute(t),second(t));
        }

LINE 100:
int diffTime(int schhour, int schminute){
    if (!ntpConnected()){
        time_t t = now();
        DEBUG_MSG_P(PSTR("[SCH] no NTP time = %02d:%02d:%02d\n"),hour(t),minute(t),second(t));
        return (hour(t) - schhour) * 60 + minute(t) - schminute;
    }
    else {
        String value = NTP.getTimeDateString();
        int hour = value.substring(0, 2).toInt();
        int minute = value.substring(3, 5).toInt();
        //DEBUG_MSG_P(PSTR("[SCH] ntp time: %02d:%02d\n"), hour, minute);
        //DEBUG_MSG_P(PSTR("[SCH] cmp time: %02d:%02d\n"), schhour, schminute);
        return (hour - schhour) * 60 + minute - schminute;
    }
}
@xoseperez
Copy link
Owner Author

Got them already. I have done some fixes to the web UI and changes to keep the same naming convention as other modules. Hope you don't mind. It's merged into dev to be released with next version.

Again, thank you very much. It's a very useful feature.

@xoseperez
Copy link
Owner Author

Closing this one. The reference issue for this is #131

@xoseperez
Copy link
Owner Author

Removing milestone: 1.12.0 (automated comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant