Automating date/time input for modem/router

F

Franc Zabkar

My D-Link DSL-302G modem/router has a real-time clock whose settings
are volatile. To avoid hand keying the date/time via the modem's JS
interface, I wonder if there is a way to copy the JS code to the hard
drive and modify it to automatically retrieve the PC's date/time. I
could then add the hacked JS page to my browser's bookmarks. I've
already successfully modified and adapted other modem menus, but I
don't know how to go about this particular task (I'm not a
programmer).

The router's IP address is 10.1.1.1. AIUI, all relative addresses in
the PopOutPage would need to be changed to reflect this..

The date/time input code is accessed via this URL:
http://10.1.1.1/PopOutPage?id=3&ex_param1=

The source code for the above JS form is here:
http://www.users.on.net/~fzabkar/DSL-302G/PopOutPage.htm

The above form calls these .gsv and .css files:
http://10.1.1.1/hag/js/global.gsv
http://10.1.1.1/hag/css/style.css

The respective source code is here:
http://www.users.on.net/~fzabkar/DSL-302G/global.gsv
http://www.users.on.net/~fzabkar/DSL-302G/style.css

Thanks in advance for any pointers.

- Franc Zabkar
 
F

Franc Zabkar

My D-Link DSL-302G modem/router has a real-time clock whose settings
are volatile. To avoid hand keying the date/time via the modem's JS
interface, I wonder if there is a way to copy the JS code to the hard
drive and modify it to automatically retrieve the PC's date/time. I
could then add the hacked JS page to my browser's bookmarks. I've
already successfully modified and adapted other modem menus, but I
don't know how to go about this particular task (I'm not a
programmer).

OK, I've narrowed down my requirements to the following:

I need a small JS routine that reads the PC date/time and builds a URL
in this format:

http://10.1.1.1/Action?sysm_date_ch...L-302G&dom_name=HomeLAN&id=1&cmdSubmit=Submit

The date in the above example is Sep 3, 2005 and the time is 22:2:22.
Daylight saving is on. The time zone is "EAST +1000 Eastern Australian
Standard".

Thanks in advance for any assistance.

- Franc Zabkar
 
T

Thomas 'PointedEars' Lahn

Franc said:
I need a small JS routine that reads the PC date/time and builds a URL
in this format:

http://10.1.1.1/Action?sysm_date_ch...L-302G&dom_name=HomeLAN&id=1&cmdSubmit=Submit
The date in the above example is Sep 3, 2005 and the time is 22:2:22.
Daylight saving is on. The time zone is "EAST +1000 Eastern Australian
Standard".

One possibility:

var
sBaseURI = "http://10.1.1.1/Action?sysm_date_check=",
d = new Date(),
aMonths = [
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
],
sFullURI = [
baseURI,
"&sys_month=", aMonths[d.getMonth()],
"&sys_date=", d.getDate(),
"&sys_year=", d.getFullYear(),
"&sysm_time_check=&sys_hour=", d.getHours(),
"&sys_minute=", d.getMinutes(),
"&sys_second=", d.getSeconds(),
"&timezone_combo=", whatever_that_is,
"&dst=", left_as_an_exercise_to_the_reader,
"&host_name=DSL-302G&dom_name=HomeLAN&id=1&cmdSubmit=Submit"
].join("");
Thanks in advance for any assistance.

RTFM next time.


PointedEars
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated
Fri, 3 Feb 2006 07:04:09 remote, seen in
Franc Zabkar said:
OK, I've narrowed down my requirements to the following:

I need a small JS routine that reads the PC date/time and builds a URL
in this format:

http://10.1.1.1/Action?sysm_date_check=&sys_month=Sep&sys_date=3&sys_year=2005&s
ysm_time_check=&sys_hour=22&sys_minute=2&sys_second=22&timezone_combo=42&dst=1&h
ost_name=DSL-302G&dom_name=HomeLAN&id=1&cmdSubmit=Submit

The date in the above example is Sep 3, 2005 and the time is 22:2:22.
Daylight saving is on. The time zone is "EAST +1000 Eastern Australian
Standard".

Thanks in advance for any assistance.

Did you consider reading the newsgroup FAQ before posting? See sig
below.

EAST is in fact not a time zone, AFAICS; a time zone is the set of all
places which have the same winter offset from GMT/UTC/UT. AIUI, the
Eastern third of Australia is in the GMT+10 zone, and remains in that
zone even in Summer when parts of it change their local time to GMT+11.

You appear to be in a part which has Summer Time.

You may need to send the Standard Time even in Summer, or you may need
to send the civil time. Timezone_combo is not to me an obvious concept.

You may want to consider the possibility of moving your system or giving
your code to a colleague elsewhere, in which case be sure not to hard-
code the local Time Rules.

Your PC is liable to indicate Winter Time from 2006-03-26, though AIUI
the change will be a week later.

A sensibly-designed router would want to be sent the time in ISO 8601
UTC format, i.e. as 2005-09-03 22:02:22Z ; presumably yours is imported
from a chronologically-inept location.

There's no difficulty in generating such a string from the information
in the Date Object D resulting from D = new Date() but your example
is not adequate to indicate the full requirement.

For example, does DST=1 mean that it *is* summer, or that the location
changes offset for summer. If the latter, how does it know when to
change offset - maybe DST rules are built in ... !!
 
F

Franc Zabkar

JRS: In article <[email protected]>, dated
Fri, 3 Feb 2006 07:04:09 remote, seen in

Did you consider reading the newsgroup FAQ before posting? See sig
below.

Sorry, I did not. The reason is that I have absolutely *no*
prerequisite knowledge of HTML, JS, or C, and I don't foresee any
pressing need for same. In any case, I have two books on JS, but they
both assume a working knowledge of HTML.

Anyway I thought the answer would be simple enough, and indeed it was.
While it isn't pretty, here is my solution (using input from this NG):

http://www.users.on.net/~fzabkar/DSL-302G/TimeSync.htm
EAST is in fact not a time zone, AFAICS; a time zone is the set of all
places which have the same winter offset from GMT/UTC/UT. AIUI, the
Eastern third of Australia is in the GMT+10 zone, and remains in that
zone even in Summer when parts of it change their local time to GMT+11.

You appear to be in a part which has Summer Time.

You may need to send the Standard Time even in Summer, or you may need
to send the civil time. Timezone_combo is not to me an obvious concept.

I have no control over this because it is built into the modem's
firmware. In any case I don't consider timezone_combo as a true
variable because this setting can be saved in the modem's nonvolatile
memory. The user can preset his own choice in the abovementioned JS
script. Indeed, it would be impossible to programmatically select the
preferred timezone_combo given that some system time zones can map to
several timezone_combo options, eg:

20 CET +0100 Central European
21 FWT +0100 French Winter
22 MET +0100 Middle European
23 MEWT +0100 Middle European Winter
24 SWT +0100 Swedish Winter
You may want to consider the possibility of moving your system or giving
your code to a colleague elsewhere, in which case be sure not to hard-
code the local Time Rules.

This code is purely for my own convenience. The *only* reason that I
wish to synchronise the modem's date and time is so that I can make
sense of the modem's event log. I really don't care too much about the
time zone, or whether daylight is being saved. Therefore I am quite
happy to hard-code the TZ and DST parameters. In any case these
parameters can be retained by the modem's nonvolatile memory and need
not be updated.

Perhaps this log of PPP events will illustrate the problem:

http://www.users.on.net/~fzabkar/DSL-302G/Alarms.htm

Notice that when the modem first powers up and connects to the DSLAM,
the date and time are those which are retrieved from the modem's
nonvolatile memory:

======================================================================
Sat Sep 03 20:09:11 2005 : STATUS ALARM : ATM Interface Up : Interface
- atm-0
Sat Sep 03 20:09:11 2005 : STATUS ALARM : DSL Interface Up
Sat Sep 03 20:09:01 2005 : STATUS ALARM : System Up
======================================================================

I believe that "Sat Sep 03" was the date when I last saved the modem's
configuration settings, ie PPP, Bridging, LAN, WAN, Admin.

After synchronising the date/time, the log looks like this:

======================================================================
Sat Feb 04 19:02:42 2006 : STATUS ALARM : PPP Interface Up : Interface
- ppp-0
Sat Feb 04 19:02:42 2006 : STATUS ALARM: PPP Event: NCP Got secondary
DNS address: 192.231.203.3
Sat Feb 04 19:02:42 2006 : STATUS ALARM: PPP Event: NCP Got primary
DNS address: 192.231.203.132
======================================================================
Your PC is liable to indicate Winter Time from 2006-03-26, though AIUI
the change will be a week later.

A sensibly-designed router would want to be sent the time in ISO 8601
UTC format, i.e. as 2005-09-03 22:02:22Z ; presumably yours is imported
from a chronologically-inept location.

There's no difficulty in generating such a string from the information
in the Date Object D resulting from D = new Date() but your example
is not adequate to indicate the full requirement.

For example, does DST=1 mean that it *is* summer, or that the location
changes offset for summer. If the latter, how does it know when to
change offset - maybe DST rules are built in ... !!

Again, this is a function of the modem's firmware. It is of no real
interest to me as I don't work past midnight and I switch off the
modem when I'm done. I may experiment with this parameter, though,
just out of curiosity. When I find out how it works I'll add an
appropriate comment to the TimeSync routine.

Thanks for your input.

- Franc Zabkar
 
F

Franc Zabkar

Franc said:
I need a small JS routine that reads the PC date/time and builds a URL
in this format:

http://10.1.1.1/Action?sysm_date_ch...L-302G&dom_name=HomeLAN&id=1&cmdSubmit=Submit
The date in the above example is Sep 3, 2005 and the time is 22:2:22.
Daylight saving is on. The time zone is "EAST +1000 Eastern Australian
Standard".

One possibility:

var
sBaseURI = "http://10.1.1.1/Action?sysm_date_check=",
d = new Date(),
aMonths = [
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
],
sFullURI = [
baseURI,
"&sys_month=", aMonths[d.getMonth()],
"&sys_date=", d.getDate(),
"&sys_year=", d.getFullYear(),
"&sysm_time_check=&sys_hour=", d.getHours(),
"&sys_minute=", d.getMinutes(),
"&sys_second=", d.getSeconds(),
"&timezone_combo=", whatever_that_is,
"&dst=", left_as_an_exercise_to_the_reader,
"&host_name=DSL-302G&dom_name=HomeLAN&id=1&cmdSubmit=Submit"
].join("");
Thanks in advance for any assistance.

RTFM next time.

Thanks very much for your help ... I think. As I confessed elsewhere,
I have absolutely no knowledge of HTML, JS, or C, so RTFM would be a
big ask. I'd liken it to asking someone at comp.lang.swahili to
translate a couple of sentences of English and being told to consult a
dictionary.

Anyway, after a considerable struggle, I came up with this:

http://www.users.on.net/~fzabkar/DSL-302G/TimeSync.htm
PointedEars

- Franc Zabkar
 
T

Thomas 'PointedEars' Lahn

Franc said:
[...] Thomas 'PointedEars' Lahn [...] wrote:
[Full quote]

Read the FAQ and the FAQ Notes before you post here again.
Thanks very much for your help ... I think. As I confessed elsewhere,
I have absolutely no knowledge of HTML, JS, or C, so RTFM would be a
big ask. I'd liken it to asking someone at comp.lang.swahili to
translate a couple of sentences of English and being told to consult
a dictionary.

The logical course of action would be to attend Swahili classes or just
let it be. For the purpose of this newsgroup is not to compensate your
lack of basic knowledge _and_ your unwillingness to acquire it.


PointedEars
 
F

Franc Zabkar

Franc said:
[...] Anyway, after a considerable struggle, I came up with this:

Considerable struggle?

My difficulty was not so much in creating a variable, although I would
have done it in a much less elegant way (by using a long concatenation
statement). The main problem was in breaking down several pages of
completely unfamiliar code into a basic requirement, and then finding
a way to direct my browser to a variable URL. Neither of my JS texts
addressed the latter, most important need.
Your code is essentially mine, without even mentioning it!

I had considered acknowledging your var statement by way of a comment
within the body of the code, but wasn't sure whether this would be
deemed too trivial. No disrespect intended.
Hopefully you aware that you will probably set the wrong time half
of the year.

Actually, the modem appears to ignore the DST setting. If I set the
date/time to just before the transition date/time, no time is lost or
gained when the clock passes through midnight. Perhaps it would be
safer to specify "&dst=0", though, just in case the modem firmware
hard codes some other transition date.

- Franc Zabkar
 
F

Franc Zabkar

Franc said:
[...] Thomas 'PointedEars' Lahn [...] wrote:
[Full quote]

Read the FAQ and the FAQ Notes before you post here again.
Thanks very much for your help ... I think. As I confessed elsewhere,
I have absolutely no knowledge of HTML, JS, or C, so RTFM would be a
big ask. I'd liken it to asking someone at comp.lang.swahili to
translate a couple of sentences of English and being told to consult
a dictionary.

The logical course of action would be to attend Swahili classes or just
let it be. For the purpose of this newsgroup is not to compensate your
lack of basic knowledge _and_ your unwillingness to acquire it.

OK, your criticisms are acknowledged and accepted. I'm at page 70 of
chapter 6 of "Javascript by Example" and still reading ...

- Franc Zabkar
 
T

Thomas 'PointedEars' Lahn

Franc said:
[...] Thomas 'PointedEars' Lahn [wrote]:
Franc said:
[...] Anyway, after a considerable struggle, I came up with this:
Considerable struggle?

[...] The main problem was in breaking down several pages of
completely unfamiliar code into a basic requirement, and then finding
a way to direct my browser to a variable URL. Neither of my JS texts
addressed the latter, most important need.
Your code is essentially mine, without even mentioning it!

I had considered acknowledging your var statement by way of a comment
within the body of the code, but wasn't sure whether this would be
deemed too trivial. No disrespect intended.
ACK
Hopefully you aware that you will probably set the wrong time half
of the year.

Actually, the modem appears to ignore the DST setting.

Why would there be such a parameter then?
If I set the date/time to just before the transition date/time, no time
is lost or gained when the clock passes through midnight. [...]

That is not surprising, considering that the standard-to-DST switch (and
vice-versa) does not happen on midnight.


PointedEars
 
F

Franc Zabkar

midnight?

Sorry, brain fart. I tried 2AM and 3AM on the first and last Sundays
of October and the last Sunday of March. There were no DST
corrections.

- Franc Zabkar
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Tue, 7 Feb
2006 08:30:31 remote, seen in Thomas
'PointedEars' Lahn said:
That is not surprising, considering that the standard-to-DST switch (and
vice-versa) does not happen on midnight.

The clock change should occur at local midnight Winter Time in the
Azores, and probably in Easternmost Greenland. Granted the OP is not
there, but your statement is dangerously general.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated
Tue, 7 Feb 2006 18:56:07 remote, seen in
Franc Zabkar said:
Sorry, brain fart. I tried 2AM and 3AM on the first and last Sundays
of October and the last Sunday of March. There were no DST
corrections.

Those dates are not good matches to existing or future US DST, nor to
what I believe to be the NZ change dates.

But I think you should have got one hit for each location.
 
F

Franc Zabkar

Franc Zabkar wrote:

Why would there be such a parameter then?

I don't know. I also tried 1AM for the "UTC" and "Western European"
time zones, but there were no date corrections there either.

BTW, I used this site as my reference:
http://webexhibits.org/daylightsaving/g.html

As for my modem, it is sold as a modem but it is actually a
modem/router, although the router function is somewhat restricted. In
fact D-Link has a tech note describing how to attach a router to this
modem/router <shrug>. One notable distinction between the DSL-302G
modem and D-Link's other "genuine" routers is that the latter have
configurable firewalls. I suspect the difference is principally in the
firmware. Perhaps the nonfunctional DST parameter is a vestigial piece
of code, ie could it be that the DSL-302G's firmware is a cut down
version of the firmware of a more elaborately optioned model, and that
the DST code has been omitted??? In fact the modem firmware contains
an additional configuration page that has been customised for an OEM
(Optus, my former ISP). Perhaps the DST routine was ditched to make
room for it???

- Franc Zabkar
 
F

Franc Zabkar

Why would there be such a parameter then?

On further investigation the modem *does* use the DST setting, but
only when it is configured to sync with an SNTP time server. This
function is essentially undocumented and is accessed via the modem's
telnet interface, not the GUI. The following guide is for a modem with
a similar chipset (Globespan Virata Viking I):

How to use SNTP (Simple Network Time Protocol) to keep the router's
clock accurate:
http://www.sarguide.co.uk/sntp.php

- Franc Zabkar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,147
Latest member
CarenSchni
Top