Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
base/clock/web-clock-ajax.c@133:98c6bf14bc37, 2020-03-11 (annotated)
- Committer:
- andrewboyson
- Date:
- Wed Mar 11 16:00:21 2020 +0000
- Revision:
- 133:98c6bf14bc37
- Parent:
- 110:8ab752842d25
Addewd more fields to TCP connections
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| andrewboyson | 103:91194cc19bbb | 1 | #include <stdint.h> |
| andrewboyson | 103:91194cc19bbb | 2 | #include <stdio.h> |
| andrewboyson | 103:91194cc19bbb | 3 | |
| andrewboyson | 103:91194cc19bbb | 4 | #include "http.h" |
| andrewboyson | 103:91194cc19bbb | 5 | #include "rtc.h" |
| andrewboyson | 103:91194cc19bbb | 6 | #include "clk.h" |
| andrewboyson | 103:91194cc19bbb | 7 | #include "clktime.h" |
| andrewboyson | 103:91194cc19bbb | 8 | #include "clkgov.h" |
| andrewboyson | 103:91194cc19bbb | 9 | #include "clkutc.h" |
| andrewboyson | 109:3e82f62c7e1f | 10 | #include "ntpclient.h" |
| andrewboyson | 103:91194cc19bbb | 11 | #include "scan.h" |
| andrewboyson | 103:91194cc19bbb | 12 | |
| andrewboyson | 103:91194cc19bbb | 13 | void WebClockAjax() |
| andrewboyson | 103:91194cc19bbb | 14 | { |
| andrewboyson | 103:91194cc19bbb | 15 | HttpOk("text/plain; charset=UTF-8", "no-cache", NULL, NULL); |
| andrewboyson | 103:91194cc19bbb | 16 | |
| andrewboyson | 103:91194cc19bbb | 17 | //Time and UTC |
| andrewboyson | 103:91194cc19bbb | 18 | clktime now = ClkNowTai(); |
| andrewboyson | 103:91194cc19bbb | 19 | clktime fraction = now & ((1UL << CLK_TIME_ONE_SECOND_SHIFT) - 1); |
| andrewboyson | 103:91194cc19bbb | 20 | clktime ms = (fraction * 1000) >> CLK_TIME_ONE_SECOND_SHIFT; |
| andrewboyson | 103:91194cc19bbb | 21 | HttpAddInt16AsHex(ms ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 22 | char byte = 0; |
| andrewboyson | 103:91194cc19bbb | 23 | if (RtcIsSet() ) byte |= 0x01; |
| andrewboyson | 103:91194cc19bbb | 24 | if (ClkTimeIsSet() ) byte |= 0x02; |
| andrewboyson | 103:91194cc19bbb | 25 | if (ClkGovIsReceivingTime ) byte |= 0x04; |
| andrewboyson | 103:91194cc19bbb | 26 | if (ClkGovRateIsSynced ) byte |= 0x08; |
| andrewboyson | 103:91194cc19bbb | 27 | if (ClkGovTimeIsSynced ) byte |= 0x10; |
| andrewboyson | 103:91194cc19bbb | 28 | if (ClkUtcGetNextLeapEnable() ) byte |= 0x20; |
| andrewboyson | 103:91194cc19bbb | 29 | if (ClkUtcGetNextLeapForward()) byte |= 0x40; |
| andrewboyson | 103:91194cc19bbb | 30 | if (ClkGovTrace) byte |= 0x80; |
| andrewboyson | 103:91194cc19bbb | 31 | HttpAddByteAsHex (byte ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 32 | HttpAddInt12AsHex(ClkUtcGetNextEpochMonth1970()); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 33 | HttpAddInt16AsHex(ClkUtcGetEpochOffset() ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 34 | HttpAddChar('\f'); |
| andrewboyson | 103:91194cc19bbb | 35 | |
| andrewboyson | 103:91194cc19bbb | 36 | //Governer |
| andrewboyson | 103:91194cc19bbb | 37 | HttpAddInt32AsHex(ClkGovGetPpb() ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 38 | HttpAddInt32AsHex(ClkGovFreqDivisor ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 39 | HttpAddInt32AsHex(ClkGovFreqChangeMaxPpb ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 40 | HttpAddInt32AsHex(ClkGovFreqSyncedLimPpb ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 41 | HttpAddInt32AsHex(ClkGovFreqSyncedHysPpb ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 42 | HttpAddInt32AsHex(ClkGovSlewDivisor ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 43 | HttpAddInt32AsHex(ClkGovSlewChangeMaxMs ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 44 | HttpAddInt32AsHex(ClkGovSlewSyncedLimNs ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 45 | HttpAddInt32AsHex(ClkGovSlewSyncedHysNs ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 46 | HttpAddInt32AsHex(ClkGovSlewOffsetMaxSecs ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 47 | HttpAddChar('\f'); |
| andrewboyson | 103:91194cc19bbb | 48 | |
| andrewboyson | 103:91194cc19bbb | 49 | //NTP |
| andrewboyson | 103:91194cc19bbb | 50 | HttpAddText (NtpClientQueryServerName ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 51 | HttpAddInt32AsHex(NtpClientQueryInitialInterval); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 52 | HttpAddInt32AsHex(NtpClientQueryNormalInterval ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 53 | HttpAddInt32AsHex(NtpClientQueryRetryInterval ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 54 | HttpAddInt32AsHex(NtpClientReplyOffsetMs ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 55 | HttpAddInt32AsHex(NtpClientReplyMaxDelayMs ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 56 | HttpAddChar('\f'); |
| andrewboyson | 103:91194cc19bbb | 57 | |
| andrewboyson | 103:91194cc19bbb | 58 | //Scan |
| andrewboyson | 103:91194cc19bbb | 59 | HttpAddInt32AsHex(ScanAverage ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 60 | HttpAddInt32AsHex(ScanMaximum ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 61 | HttpAddInt32AsHex(ScanMinimum ); HttpAddChar('\n'); |
| andrewboyson | 103:91194cc19bbb | 62 | HttpAddChar('\f'); |
| andrewboyson | 103:91194cc19bbb | 63 | } |
| andrewboyson | 103:91194cc19bbb | 64 |