FreeCalypso > hg > freecalypso-tools
annotate uptools/atcmd/settime.c @ 963:b515a97e5dff
sms-pdu-decode family: fix VP-Relative header spacing
When VP-Relative is small enough to be reckoned in 5 min or 30 min units,
it was printed incorrectly, with a cosmetic defect of one extra space.
Fix this bug.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 28 Aug 2023 03:52:53 +0000 |
parents | dc2fd8e6f42c |
children |
rev | line source |
---|---|
387
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This utility sends an AT+CCLK command to the GSM device to set its time |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * to the host's notion of local time. |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <time.h> |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdlib.h> |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <unistd.h> |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include "../../rvinterf/include/exitcodes.h" |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 main(argc, argv) |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 char **argv; |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 { |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 int c; |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern int optind; |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 time_t unixtime; |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 struct tm *tm; |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 char command[32]; |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 while ((c = getopt(argc, argv, "B:np:RX:")) != EOF) |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 if (!atinterf_cmdline_opt(c)) { |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 /* error msg already printed */ |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 exit(ERROR_USAGE); |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 } |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 if (argc != optind) { |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 fprintf(stderr, "usage: %s [options]\n", argv[0]); |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 exit(ERROR_USAGE); |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 } |
407
19e5a3e2f9c0
fcup-settime: moved time() retrieval a little closer to the output
Mychaela Falconia <falcon@freecalypso.org>
parents:
387
diff
changeset
|
30 atinterf_init(); |
387
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 time(&unixtime); |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 tm = localtime(&unixtime); |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 sprintf(command, "AT+CCLK=\"%02d/%02d/%02d,%02d:%02d:%02d%+03d\"", |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 tm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday, |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_gmtoff / (15*60)); |
467
dc2fd8e6f42c
uptools/atcmd: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
407
diff
changeset
|
36 atinterf_exec_cmd_needok(command, (char *) 0, (void *) 0); |
387
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 exit(0); |
b61b81d3cece
fcup-settime program written, compiles, produces expected AT+CCLK command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 } |