|
Home > Archive > SQL Anywhere Mobile > March 2005 > Sync the time to the device
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Sync the time to the device
|
|
|
| I need to set the time on the device to the time that is on the server
running the mobilink service.
I could create a field in the db and sync it down then read it on the device
and set the time but there could be a lot of variance in accuracy. We sync a
lot of data and sometimes sync's take an hour or longer to complete. This
would make the time 1 hour off.
What I would like to do is select GETDATE() on sql server in the end sync or
end connection event and somehow read it on the device at that time. I
already have a procedure in the end sync event to update some data on my sql
server/mobilink machine.
Is this even possible to do with a minute or two of accuracy and if so what
would be the best way to approach it?
We are using ASA 9.0.1.1994
Tommy
| |
| Greg Fenton 2005-03-30, 9:43 am |
| Tommy wrote:
> I need to set the time on the device to the time that is on the server
> running the mobilink service.
>
Tommy,
What devices are you using?
Would you consider using some type of NTP time synchronization rather
than the "hack" that the proposed GETDATE() approach is?
greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/
| |
|
| Possibly.
We are using Symbol PDT 8100's and Symbol MC3000's.
Tommy
"Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> wrote in message
news:4239c45c$1@foru
ms-1-dub...
> Tommy wrote:
>
> Tommy,
>
> What devices are you using?
>
> Would you consider using some type of NTP time synchronization rather than
> the "hack" that the proposed GETDATE() approach is?
>
> greg.fenton
> --
> Greg Fenton
> Consultant, Solution Services, iAnywhere Solutions
> --------
> Visit the iAnywhere Solutions Developer Community
> Whitepapers, TechDocs, Downloads
> http://www.ianywhere.com/developer/
| |
|
| If I am forced to use mobilink to accomplish this what would be the best way
to minimize the time lag?
Our customers will be running this and some are really reluctant to run
anything else on their servers. For some it was hard enough to get them to
run mobilink on it.
Tommy
"Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> wrote in message
news:4239c45c$1@foru
ms-1-dub...
> Tommy wrote:
>
> Tommy,
>
> What devices are you using?
>
> Would you consider using some type of NTP time synchronization rather than
> the "hack" that the proposed GETDATE() approach is?
>
> greg.fenton
> --
> Greg Fenton
> Consultant, Solution Services, iAnywhere Solutions
> --------
> Visit the iAnywhere Solutions Developer Community
> Whitepapers, TechDocs, Downloads
> http://www.ianywhere.com/developer/
| |
| Greg Fenton 2005-03-30, 9:43 am |
| Tommy wrote:
> If I am forced to use mobilink to accomplish this what would be the best way
> to minimize the time lag?
>
Since you mention ASA and SQL Server[sic] in your original post, and
Symbol devices in your followup, I assume that you are using "ASA on CE"
for your remotes.
It gets a bit complicated, but there are some things you can do to
minimze the time difference. Here is a "timeline":
1. in your ML's prepare_for_download
synch script, grab GETDATE() and
stick it into a table (e.g. UPDATE cons_time SET start_download =
GETDATE() WHERE ? IS NOT NULL and remote_db = ?)
2. in your remote, code a sp_hook_dbmlsync_dow
nload_begin that grabs
GETDATE() and stick it into another table (e.g. UPDATE remote_time SET
start_download = NOW())
3. in your remote, code a sp_hook_dbmlsync_end
, check that the exit code
is zero (i.e. success) and then calculate the time difference:
SELECT DATEDIFF(SECOND, c.start_download, r.start_download)
INTO @time_diff
FROM cons_time c, remote_time r
...
4. apply the value of @time_diff to the remote's system clock
The application of this time difference is a where the trick is. Since
ASA on CE does not support external procedures, you need to find a way
to get the time difference and apply it. If you have the ability to
detect the end of synchronization from within your application, or if
your app can check from time-to-time (or upon startup) that a new
@time_diff has been calculated, you can apply it then.
Does this help?
greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/
| |
| Greg Fenton 2005-03-30, 9:43 am |
| Greg Fenton wrote:
>
> 4. apply the value of @time_diff to the remote's system clock
>
Again, just to stress the point, this is a HACK (I'm good at those ;-) )
The right answer (or at least one of them is) to synchronizing time is
to use a server and protocol designed to handle the situation, which the
NTP protocol is and I believe that most fairly recent OS'es support some
form of NTP server.
greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/
| |
|
| I understand. I wrote code to set the time via NTP yesterday. I'm pretty
sure they will balk at having to open another port to the users. I just want
to be able to cover all of my bases.
"Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> wrote in message
news:423a102c$1@foru
ms-2-dub...
> Greg Fenton wrote:
>
> Again, just to stress the point, this is a HACK (I'm good at those ;-) )
>
> The right answer (or at least one of them is) to synchronizing time is to
> use a server and protocol designed to handle the situation, which the NTP
> protocol is and I believe that most fairly recent OS'es support some form
> of NTP server.
>
> greg.fenton
> --
> Greg Fenton
> Consultant, Solution Services, iAnywhere Solutions
> --------
> Visit the iAnywhere Solutions Developer Community
> Whitepapers, TechDocs, Downloads
> http://www.ianywhere.com/developer/
| |
| Reg Domaratzki \(iAnywhere Solutions\) 2005-03-30, 9:43 am |
| I may be jumping in a little late here, but why do you need to synchronize
the time? If it's only to filter out previously downloaded rows for remote
users, there is no requirement that the times (or time zones even) need to
be in synch on the remote and consolidated. It's only the time returned by
the RDBMS that will have any bearing on this.
--
Reg Domaratzki, Sybase iAnywhere Solutions
Sybase Certified Professional - Sybase ASA Developer Version 8
Please reply only to the newsgroup
iAnywhere Developer Community : http://www.ianywhere.com/developer
iAnywhere Documentation : http://www.ianywhere.com/developer/product_manuals
ASA Patches and EBFs : http://downloads.sybase.com/swx/sdmain.stm
-> Choose SQL Anywhere Studio
-> Set "Platform Preview" and "Time Frame" to ALL
"Tommy" <tommy@dontspamme.com> wrote in message
news:423994b3$1@foru
ms-1-dub...
> I need to set the time on the device to the time that is on the server
> running the mobilink service.
>
> I could create a field in the db and sync it down then read it on the
device
> and set the time but there could be a lot of variance in accuracy. We sync
a
> lot of data and sometimes sync's take an hour or longer to complete. This
> would make the time 1 hour off.
>
> What I would like to do is select GETDATE() on sql server in the end sync
or
> end connection event and somehow read it on the device at that time. I
> already have a procedure in the end sync event to update some data on my
sql
> server/mobilink machine.
>
> Is this even possible to do with a minute or two of accuracy and if so
what
> would be the best way to approach it?
>
> We are using ASA 9.0.1.1994
>
> Tommy
>
>
| |
| Mark Hampton 2005-03-30, 9:43 am |
| Sad to say, I use that hack today for Symbol 8800's and soon MK2000. I
populate a record using a stored procedure called by the begin_download
event (script).
"Tommy" <tommy.martin@software-plus.net> wrote in message
news:4239dc1a@forums
-2-dub...
> Possibly.
>
> We are using Symbol PDT 8100's and Symbol MC3000's.
>
> Tommy
>
>
> "Greg Fenton" <greg. fenton_NOSPAM_@ianyw
here.com> wrote in message
> news:4239c45c$1@foru
ms-1-dub...
>
>
|
|
|
|
|