Announcement

Collapse
No announcement yet.

how can I get the cell phone timing?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • how can I get the cell phone timing?

    Hello,
    I wish to connect my computer to a cell phone thru the USB, I cannot use email or internet. Then I need to get the timing from the cell phone (day, hour, minute) and compare with the timing of my computer and check if they are similar (between a tolerance, for instance 1 day o 30 minutes and so forth). How can I do this?

  • #2
    One simple way is to use the cell phone as a network bridge/adapter. I know my iPhone can operate that way. Then you only really need to setup NTP and it goes out to the internet over the cell connection.

    As for an "API" sort of method, not really sure but I can tell you it is going to be very specific to the phone type/OS etc. On some phones it might even require consent on the device, etc.

    What exactly is your end goal? There are plenty of GPS based "time servers" which might much more easily serve you with much less effort.

    GPS Example: http://k5pa.com/Ham%20Radio/Download...ter%20Time.pdf
    GPS Cost ($29.95): https://www.thegpsstore.com/USGlobal...ver-P3219.aspx
    <b>George W. Bleck</b>
    <img src='http://www.blecktech.com/myemail.gif'>

    Comment


    • #3
      Thank you George, we wish to control date and time that a person may use our course or exam offline (it is very common in Mexico that internet is not available all day long). I think the person may change the time on the computer but I imagine (not sure) she will not change the date and time of a cell phone i shall use as reference. With the data from the cell as a reference I could control the timing to initiate the exam. I do not know how to get the real time. I shall look at the GPS you indicate, Thank you. regards

      Comment


      • #4
        Anyone who can change the date/time on their computer can also change the date/time on their phone.

        I really don't see any way to reliably control when someone does something on a computer that is offline.


        Comment


        • #5
          Stuart McLachlan - All depends on the owner of the phone plugged into the device :-)

          This is the reason for my USB/GPS solution. Cheap and easy to implement and less chance of manipulation.
          <b>George W. Bleck</b>
          <img src='http://www.blecktech.com/myemail.gif'>

          Comment


          • #6
            Agustin,

            Do you know if your phone support the "AT+CCLK?" modem command ?

            Added:
            After some digging, seems "AT+CCLK?" is more for Arduino hardware...
            Last edited by Pierre Bellisle; 19 May 2020, 02:45 AM.

            Comment


            • #7
              If the phone or device is an android, you can use the command "adb shell date" with the ADB utilities to retrieve the time in standard output. So you can pipe the date to your program.
              ====================================================================
              usage: date [-u] [-r FILE] [-d DATE] [+DISPLAY_FORMAT] [-D SET_FORMAT] [SET]

              Set/get the current date/time. With no SET shows the current date.

              Default SET format is "MMDDhhmm[[CC]YY][.ss]", that's (2 digits each)
              month, day, hour (0-23), and minute. Optionally century, year, and second.
              Also accepts "@UNIXTIME[.FRACTION]" as seconds since midnight Jan 1 1970.

              -d Show DATE instead of current time (convert date format)
              -D +FORMAT for SET or -d (instead of MMDDhhmm[[CC]YY][.ss])
              -r Use modification time of FILE instead of current date
              -u Use UTC instead of current timezone

              +FORMAT specifies display format string using strftime(3) syntax:

              %% literal % %n newline %t tab
              %S seconds (00-60) %M minute (00-59) %m month (01-12)
              %H hour (0-23) %I hour (01-12) %p AM/PM
              %y short year (00-99) %Y year %C century
              %a short weekday name %A weekday name %u day of week (1-7, 1=mon)
              %b short month name %B month name %Z timezone name
              %j day of year (001-366) %d day of month (01-31) %e day of month ( 1-31)
              %N nanosec (output only)

              %U Week of year (0-53 start sunday) %W Week of year (0-53 start monday)
              %V Week of year (1-53 start monday, week < 4 days not part of this year)

              %D = "%m/%d/%y" %r = "%I : %M : %S %p" %T = "%H:%M:%S" %h = "%b"
              %x locale date %X locale time %c locale date/time


              usage: date [-u] [-r FILE] [-d DATE] [+DISPLAY_FORMAT] [-D SET_FORMAT] [SET]

              Set/get the current date/time. With no SET shows the current date.

              Default SET format is "MMDDhhmm[[CC]YY][.ss]", that's (2 digits each)
              month, day, hour (0-23), and minute. Optionally century, year, and second.
              Also accepts "@UNIXTIME[.FRACTION]" as seconds since midnight Jan 1 1970.

              -d Show DATE instead of current time (convert date format)
              -D +FORMAT for SET or -d (instead of MMDDhhmm[[CC]YY][.ss])
              -r Use modification time of FILE instead of current date
              -u Use UTC instead of current timezone

              +FORMAT specifies display format string using strftime(3) syntax:

              %% literal % %n newline %t tab
              %S seconds (00-60) %M minute (00-59) %m month (01-12)
              %H hour (0-23) %I hour (01-12) %p AM/PM
              %y short year (00-99) %Y year %C century
              %a short weekday name %A weekday name %u day of week (1-7, 1=mon)
              %b short month name %B month name %Z timezone name
              %j day of year (001-366) %d day of month (01-31) %e day of month ( 1-31)
              %N nanosec (output only)

              %U Week of year (0-53 start sunday) %W Week of year (0-53 start monday)
              %V Week of year (1-53 start monday, week < 4 days not part of this year)

              %D = "%m/%d/%y" %r = "%I : %M : %S %p" %T = "%H:%M:%S" %h = "%b"
              %x locale date %X locale time %c locale date/time
              usage: date [-u] [-r FILE] [-d DATE] [+DISPLAY_FORMAT] [-D SET_FORMAT] [SET]

              Set/get the current date/time. With no SET shows the current date.

              Default SET format is "MMDDhhmm[[CC]YY][.ss]", that's (2 digits each)
              month, day, hour (0-23), and minute. Optionally century, year, and second.
              Also accepts "@UNIXTIME[.FRACTION]" as seconds since midnight Jan 1 1970.

              -d Show DATE instead of current time (convert date format)
              -D +FORMAT for SET or -d (instead of MMDDhhmm[[CC]YY][.ss])
              -r Use modification time of FILE instead of current date
              -u Use UTC instead of current timezone

              +FORMAT specifies display format string using strftime(3) syntax:

              %% literal % %n newline %t tab
              %S seconds (00-60) %M minute (00-59) %m month (01-12)
              %H hour (0-23) %I hour (01-12) %p AM/PM
              %y short year (00-99) %Y year %C century
              %a short weekday name %A weekday name %u day of week (1-7, 1=mon)
              %b short month name %B month name %Z timezone name
              %j day of year (001-366) %d day of month (01-31) %e day of month ( 1-31)
              %N nanosec (output only)

              %U Week of year (0-53 start sunday) %W Week of year (0-53 start monday)
              %V Week of year (1-53 start monday, week < 4 days not part of this year)

              %D = "%m/%d/%y" %r = "%I : %M : %S %p" %T = "%H:%M:%S" %h = "%b"
              %x locale date %X locale time %c locale date/time
              ====================================================================

              time from a samsung tablet via the standard usb cable
              ------------------------------------------------------------------------------
              C:\adb>adb devices
              List of devices attached
              R52M40EZ35V device


              C:\adb>adb shell date
              Tue May 19 01:09:09 CDT 2020

              C:\adb>adb shell date +%m%d%H%M%Y.%S
              051901132020.47


              p purvis

              Comment


              • #8
                If it is only a time factor for a limited time for an exam. You could monitor for a time change on the computer.
                p purvis

                Comment


                • #9
                  Thank you guys for the suggestions, I shall try to see what to do. The GPS distributor wrote to me and he is not able to have a GPS as I need and he sent me to the producer in China. I am waiting for news. I shall look at the other solutions. I know it is very difficult to control my students offline, I shall continue with your ideas. Thanks to everyone. Please be safe during the pandemics.

                  Comment


                  • #10
                    Can also try Amazon... https://www.amazon.com/GlobalSat-BU-...0032459&sr=8-1
                    <b>George W. Bleck</b>
                    <img src='http://www.blecktech.com/myemail.gif'>

                    Comment


                    • #11
                      Hi Agustin,

                      In the hypothesis that a GPS could be used, here is some PowerBASIC code that might help.
                      garmin-gps-protocol-constant-tracking-pvt
                      garmin-gps-interface-app
                      Note that Garmin provide easy to use DLL to access the GPS via a USB cable, maybe other did the same...
                      There is a ReadDateTime function

                      Also, maybe some SMS api coding could be done...

                      Now, to resume, let see if I understand your goal.
                      You have students that pass an exam.
                      You want to be sure that they won't exceed a specific amount of time, like 30 minutes.
                      Or you want to be sure that they won't go over specific time, like at 15h30 the exam is over.
                      So you want some code that will run on their computer to "stop" the exam after a delay.
                      Does this make sense?

                      Comment


                      • #12
                        Originally posted by George Bleck View Post
                        Or AliExpress

                        https://www.aliexpress.com/wholesale...b+gps+receiver

                        Comment


                        • #13
                          Note a lot of those $7-10 simple USB GPS devices can output NMEA 0183 sentences and emulate a standard serial port, so it would be easy to write PB code to monitor the time signals and respond appropriately as long as your application is running.

                          Comment


                          • #14
                            Thank you again guys. Oui Pierre, concerning your comments. I have an application in our Web page, but it depends on Internet and probably you know that this service in Mexico is very variable. So I can provide a PB application in a USB with the exam, so they can answer without Internet. I am controlling several actions by creative students: the USB including encryption for files and content and even if they try to copy to another USB it will not work. I provide a user-password including ID, name and day-hour to answer the exam and once they begin I can control the time so they will not pass more that say 1 hour. Every student may have a different exam but some questions may be the same as our item bank is not infinite. The problem is that I cannot control the initial date-time, if I trust on the computer time, it is easy that one person may initiate at any time and I wish to control that everyone begins and ends at the expected time.

                            Comment


                            • #15
                              How Reliable is the cell network in Mexico?
                              Would something like this work for you?

                              They start your program, program checks if internet available, if yes you can get time from internet and exam begins
                              if not, you generate a code (unixtime + sudent ID + plus anything useful to you) they SMS it to the number displayed. you respond, or something automated, with a validation number, they type it in program to allow exam.
                              Even if they change computer time, you have sms time to double check.

                              Comment


                              • #16
                                thanks for the idea Rod. I shall try that. Reliability depends on the company and the place where you are, then we cannot trust very much...

                                Comment


                                • #17
                                  https://www.keylok.com/products/fort...eal-time-clock

                                  Comment


                                  • #18
                                    Thank you David, I've contacted the producer of keylok. They are more related to security, they have a model of USB with internal clock (no memory) for about 60 dollars plus license fee.

                                    Comment


                                    • #19
                                      Originally posted by agustin tristan View Post
                                      USB with internal clock (no memory) for about 60 dollars plus license fee.
                                      Is that too expensive for your purpose?

                                      if yes you can also use an Time-based One-time Password Algorithm (TOTP), like Google Authenticator.
                                      Available free both IOS and android (many other apps available also)
                                      Can also be used on Ipads, and other tablets.

                                      It would go something like this.

                                      program starts Checks Internet, if not asks for authenticator 6 digit code
                                      Student gets a auth code or qrcode from your program to setup Authenticator on phone. (code could be generated based on Student ID)
                                      student uses phone to get 6 digit code, from phone App
                                      if codes matches, then both phone and computer have same time, neither need to be connected to Internet or cell service. (the codes are time based)
                                      You can build some tolerance +- xx Minutes, Hrs to the code compared, if needed.

                                      Note:
                                      a very savvy student could use an authenticator on PC also and or change time on phone to match PC.
                                      so its not a perfect solution. But they need to really understand how TOTP works.

                                      Comment


                                      • #20
                                        If the computers are able to be centralized in some way, you could also setup a raspberry pi model 4 with an addon RTC(real time clock) with NTP service running on the raspberry PI.
                                        Agustin, You may like to write about your total environment in the section on hardware. Non the less, it would be interesting to read about. A lot of us have seen almost it all all and as you can see there there is a real depth of experience learning the hard way around here over a long period of time of each of ones history.
                                        I mention the raspberry because it is cheap and if you like that word, you can afford more than one so you will have backup equipment for not much moola.

                                        p purvis

                                        Comment

                                        Working...
                                        X