Jump to content
IGNORED

OLD CS1's Blog - Powershell to set clock on SonyEricsson phone via Blue


RSS Bot

Recommended Posts

SonyEricsson's PC Suite had a nice feature which would synchronize your phone's clock to your PC's clock when establishing a connection. I found more often than not my frequently-synchronized computer time differed by a minute or more from the Cingular/AT&T network time.

(quick bitching about Sony)

Spoiler

SonyEricsson discontinued the PC Suite (sad, since it could also compose and send MMS messages) for the PC Companion. Sony has since discontinued the PC Companion in favor of its Android-only software for its Xperia line of mobiles. Fair enough, since the SonyEricsson phones are, while functional, defunct. Two problems arise for me: first, that while I can install the PC Companion software, none of its modules are part of the installer and are downloaded from the Sony website upon first use, including text messaging and PC synchronization. I long ago null-routed the Sony website from which PC Companion downloads its modules because it would also determine a new program was available and prevent you from using the PC Companion, thus forcing the upgrade.

F.U. Sony.

At this point, once I move to a new machine I have limited options for continuing to use the PC Companion software, meaning I will lose my ability to synchronize Outlook with my phone and use my laptop to send and receive text messages via the phone. Why I stick to my old SonyEricsson phone is a discussion for later and I have wandered off-point.


Since PC Companion no longer synchronizes my phone's clock with my PC, using the SonyEricsson AT Commands reference guide I wrote a Powershell script to take up the slack. The script opens the Bluetooth COM port set in the first line (no error checking, sorry so lazy) which is COM14 on my laptop, then sends the AT*EDST and AT+CCLK commands to set daylight saving time status and the clock, respectively. Setting DST is extremely important for setting appointments as I do not enjoy being an hour late or early.

Since Get-Date returns the local time adjusted for DST, the time submitted to the phone must compensate. The IsDaylightSavingTime() return from the Get-Date object is perfect for this as it returns 0 for "not DST" and 1 for "DST," so this is subtracted from the current hour. *EDST is sent to the phone first, per SE recommendations, then +CCLK. $seTZ holds the time zone offset, which is the offset from UTC in quarter-hours, calculated by comparing the local time to UTC, adjusting for local DST, then multiplying by 4.

One other trick is to clear DST before setting the time. Otherwise, the phone accepts the given time as the current time including DST, but since DST has already been accounted for the time gets set an hour off.

I put one-second pauses between sending each of the three commands to the phone. Without this pause commands will sometimes get missed. I suspect this is due to not reading the phone's responses which I do not try to read. This is a very primitive script which does not check to make sure the port is even open, so why even bother registering an event for reading the port? ;)


http://atariage.com/forums/blog/600/entry-15612-powershell-to-set-clock-on-sonyericsson-phone-via-bluetooth/
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...