Monitor motorhome leisure battery and provide simple control of habitation
Dependencies: net lpc1768 crypto clock web fram log
settings/settings.c@4:f38b5bb8adac, 2021-04-24 (annotated)
- Committer:
- andrewboyson
- Date:
- Sat Apr 24 10:59:17 2021 +0000
- Revision:
- 4:f38b5bb8adac
- Parent:
- 3:b96c6f6bbffc
- Child:
- 5:4cf7ee162c4e
Improvements to WIZ module
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 4:f38b5bb8adac | 1 | |
andrewboyson | 4:f38b5bb8adac | 2 | |
andrewboyson | 0:b843d647695c | 3 | #include <stdbool.h> |
andrewboyson | 0:b843d647695c | 4 | #include <stdlib.h> |
andrewboyson | 0:b843d647695c | 5 | #include <string.h> |
andrewboyson | 0:b843d647695c | 6 | |
andrewboyson | 0:b843d647695c | 7 | #include "clkgov.h" |
andrewboyson | 0:b843d647695c | 8 | #include "fram.h" |
andrewboyson | 0:b843d647695c | 9 | #include "log.h" |
andrewboyson | 0:b843d647695c | 10 | #include "net.h" |
andrewboyson | 0:b843d647695c | 11 | #include "link.h" |
andrewboyson | 0:b843d647695c | 12 | #include "dnsname.h" |
andrewboyson | 0:b843d647695c | 13 | #include "dnsquery.h" |
andrewboyson | 0:b843d647695c | 14 | #include "dnsreply.h" |
andrewboyson | 0:b843d647695c | 15 | #include "dnsserver.h" |
andrewboyson | 0:b843d647695c | 16 | #include "dnslabel.h" |
andrewboyson | 0:b843d647695c | 17 | #include "ntp.h" |
andrewboyson | 0:b843d647695c | 18 | #include "dhcp.h" |
andrewboyson | 0:b843d647695c | 19 | #include "ns.h" |
andrewboyson | 0:b843d647695c | 20 | #include "nr.h" |
andrewboyson | 0:b843d647695c | 21 | #include "ntpclient.h" |
andrewboyson | 0:b843d647695c | 22 | #include "1-wire.h" |
andrewboyson | 0:b843d647695c | 23 | #include "echo4.h" |
andrewboyson | 0:b843d647695c | 24 | #include "echo6.h" |
andrewboyson | 0:b843d647695c | 25 | #include "dest6.h" |
andrewboyson | 0:b843d647695c | 26 | #include "ra.h" |
andrewboyson | 0:b843d647695c | 27 | #include "rs.h" |
andrewboyson | 0:b843d647695c | 28 | #include "ar4.h" |
andrewboyson | 0:b843d647695c | 29 | #include "ar6.h" |
andrewboyson | 0:b843d647695c | 30 | #include "arp.h" |
andrewboyson | 0:b843d647695c | 31 | #include "ip4.h" |
andrewboyson | 0:b843d647695c | 32 | #include "ip6.h" |
andrewboyson | 0:b843d647695c | 33 | #include "udp.h" |
andrewboyson | 0:b843d647695c | 34 | #include "tcp.h" |
andrewboyson | 0:b843d647695c | 35 | #include "web.h" |
andrewboyson | 0:b843d647695c | 36 | #include "tftp.h" |
andrewboyson | 0:b843d647695c | 37 | #include "dns.h" |
andrewboyson | 0:b843d647695c | 38 | #include "led.h" |
andrewboyson | 4:f38b5bb8adac | 39 | #include "wiz.h" |
andrewboyson | 4:f38b5bb8adac | 40 | #include "wiz-list.h" |
andrewboyson | 0:b843d647695c | 41 | |
andrewboyson | 0:b843d647695c | 42 | static int iClkGovSlewDivisor ; |
andrewboyson | 0:b843d647695c | 43 | static int iClkGovSlewMaxMs ; |
andrewboyson | 0:b843d647695c | 44 | static int iClkGovPpbDivisor ; |
andrewboyson | 0:b843d647695c | 45 | static int iClkGovPpbChangeMax ; |
andrewboyson | 0:b843d647695c | 46 | static int iClkGovSyncedLimitNs ; |
andrewboyson | 0:b843d647695c | 47 | static int iClkGovSyncedLimitPpb ; |
andrewboyson | 0:b843d647695c | 48 | static int iClkGovSyncedHysterisNs ; |
andrewboyson | 0:b843d647695c | 49 | static int iClkGovSyncedHysterisPpb; |
andrewboyson | 0:b843d647695c | 50 | static int iClkGovMaxOffsetSecs ; |
andrewboyson | 0:b843d647695c | 51 | static int iClkGov; |
andrewboyson | 0:b843d647695c | 52 | |
andrewboyson | 0:b843d647695c | 53 | static int iOneWire; |
andrewboyson | 0:b843d647695c | 54 | |
andrewboyson | 0:b843d647695c | 55 | static int iDnsSendRequestsViaIp4 ; |
andrewboyson | 0:b843d647695c | 56 | static int iNtpSendRequestsViaIp4 ; |
andrewboyson | 0:b843d647695c | 57 | static int iTftpSendRequestsViaIp4; |
andrewboyson | 0:b843d647695c | 58 | |
andrewboyson | 0:b843d647695c | 59 | static int iNetHost; |
andrewboyson | 0:b843d647695c | 60 | static int iLogUart; |
andrewboyson | 0:b843d647695c | 61 | static int iNetStack; |
andrewboyson | 0:b843d647695c | 62 | static int iNetNewLine; |
andrewboyson | 0:b843d647695c | 63 | static int iNetVerbose; |
andrewboyson | 0:b843d647695c | 64 | static int iLink; |
andrewboyson | 0:b843d647695c | 65 | static int iDnsName; |
andrewboyson | 0:b843d647695c | 66 | static int iDnsQuery; |
andrewboyson | 0:b843d647695c | 67 | static int iDnsReply; |
andrewboyson | 0:b843d647695c | 68 | static int iDnsServer; |
andrewboyson | 0:b843d647695c | 69 | static int iNtp; |
andrewboyson | 0:b843d647695c | 70 | static int iDhcp; |
andrewboyson | 0:b843d647695c | 71 | static int iNsRecvSol; |
andrewboyson | 0:b843d647695c | 72 | static int iNsRecvAdv; |
andrewboyson | 0:b843d647695c | 73 | static int iNsSendSol; |
andrewboyson | 0:b843d647695c | 74 | static int iNr4; |
andrewboyson | 0:b843d647695c | 75 | static int iNr; |
andrewboyson | 0:b843d647695c | 76 | static int iNtpClient; |
andrewboyson | 0:b843d647695c | 77 | static int iEcho4; |
andrewboyson | 0:b843d647695c | 78 | static int iEcho6; |
andrewboyson | 0:b843d647695c | 79 | static int iDest6; |
andrewboyson | 0:b843d647695c | 80 | static int iRa; |
andrewboyson | 0:b843d647695c | 81 | static int iRs; |
andrewboyson | 0:b843d647695c | 82 | static int iAr4; |
andrewboyson | 0:b843d647695c | 83 | static int iAr6; |
andrewboyson | 0:b843d647695c | 84 | static int iArp; |
andrewboyson | 0:b843d647695c | 85 | static int iIp4; |
andrewboyson | 0:b843d647695c | 86 | static int iIp6; |
andrewboyson | 0:b843d647695c | 87 | static int iUdp; |
andrewboyson | 0:b843d647695c | 88 | static int iTcp; |
andrewboyson | 0:b843d647695c | 89 | static int iHttp; |
andrewboyson | 0:b843d647695c | 90 | static int iTftp; |
andrewboyson | 0:b843d647695c | 91 | |
andrewboyson | 4:f38b5bb8adac | 92 | //Values |
andrewboyson | 4:f38b5bb8adac | 93 | static int iValuesServerName; |
andrewboyson | 4:f38b5bb8adac | 94 | void SetValuesServerName(char* value) { FramWrite(iValuesServerName, DNS_MAX_LABEL_LENGTH, value); } |
andrewboyson | 4:f38b5bb8adac | 95 | void GetValuesServerName(char* value) { FramRead (iValuesServerName, DNS_MAX_LABEL_LENGTH, value); value[DNS_MAX_LABEL_LENGTH] = 0; } |
andrewboyson | 4:f38b5bb8adac | 96 | |
andrewboyson | 4:f38b5bb8adac | 97 | static int iValuesFileName; |
andrewboyson | 4:f38b5bb8adac | 98 | void SetValuesFileName(char* value) { FramWrite(iValuesFileName, DNS_MAX_LABEL_LENGTH, value); } |
andrewboyson | 4:f38b5bb8adac | 99 | void GetValuesFileName(char* value) { FramRead (iValuesFileName, DNS_MAX_LABEL_LENGTH, value); value[DNS_MAX_LABEL_LENGTH] = 0; } |
andrewboyson | 4:f38b5bb8adac | 100 | |
andrewboyson | 4:f38b5bb8adac | 101 | static int iValuesWriteSize; |
andrewboyson | 4:f38b5bb8adac | 102 | void SetValuesWriteSize(int* pValue) { FramWrite(iValuesWriteSize, 4, pValue); } |
andrewboyson | 4:f38b5bb8adac | 103 | void GetValuesWriteSize(int* pValue) { FramRead (iValuesWriteSize, 4, pValue); } |
andrewboyson | 4:f38b5bb8adac | 104 | |
andrewboyson | 4:f38b5bb8adac | 105 | static int iValuesReadInterval; |
andrewboyson | 4:f38b5bb8adac | 106 | void SetValuesReadInterval(int* pValue) { FramWrite(iValuesReadInterval, 4, pValue); } |
andrewboyson | 4:f38b5bb8adac | 107 | void GetValuesReadInterval(int* pValue) { FramRead (iValuesReadInterval, 4, pValue); } |
andrewboyson | 4:f38b5bb8adac | 108 | |
andrewboyson | 4:f38b5bb8adac | 109 | static int iValuesStartTime; |
andrewboyson | 4:f38b5bb8adac | 110 | void SetValuesStartTime(int64_t* pValue) { FramWrite(iValuesStartTime, 8, pValue); } |
andrewboyson | 4:f38b5bb8adac | 111 | void GetValuesStartTime(int64_t* pValue) { FramRead (iValuesStartTime, 8, pValue); } |
andrewboyson | 4:f38b5bb8adac | 112 | |
andrewboyson | 4:f38b5bb8adac | 113 | static int iValuesCount; |
andrewboyson | 4:f38b5bb8adac | 114 | void SetValuesCount(int* pValue) { FramWrite(iValuesCount, 4, pValue); } |
andrewboyson | 4:f38b5bb8adac | 115 | void GetValuesCount(int* pValue) { FramRead (iValuesCount, 4, pValue); } |
andrewboyson | 4:f38b5bb8adac | 116 | |
andrewboyson | 4:f38b5bb8adac | 117 | static int iValuesData; |
andrewboyson | 4:f38b5bb8adac | 118 | void GetValuesData(int index, char* pValue) { FramRead (iValuesData + index, 1, pValue); } |
andrewboyson | 4:f38b5bb8adac | 119 | void SetValuesData(int count, void* pValue) { FramWrite(iValuesData + 8 * count, 8, pValue); } |
andrewboyson | 4:f38b5bb8adac | 120 | |
andrewboyson | 4:f38b5bb8adac | 121 | //Wiz settings |
andrewboyson | 4:f38b5bb8adac | 122 | static int iWizMacs [WIZ_LIST_MAX_ITEMS]; |
andrewboyson | 4:f38b5bb8adac | 123 | static int iWizNames[WIZ_LIST_MAX_ITEMS]; |
andrewboyson | 4:f38b5bb8adac | 124 | static int iWizTrace; |
andrewboyson | 4:f38b5bb8adac | 125 | |
andrewboyson | 4:f38b5bb8adac | 126 | void ChgTraceWiz () { WizTrace = !WizTrace ; FramWrite(iWizTrace, 1, &WizTrace); } |
andrewboyson | 4:f38b5bb8adac | 127 | void SetWizListMac (int i, char* pMac ) { WizListSetMac (i, pMac ); FramWrite(iWizMacs [i], 6, pMac ); } |
andrewboyson | 4:f38b5bb8adac | 128 | void SetWizListName(int i, char* pText) { WizListSetName(i, pText); FramWrite(iWizNames[i], WIZ_LIST_NAME_LENGTH, pText ); } |
andrewboyson | 4:f38b5bb8adac | 129 | |
andrewboyson | 4:f38b5bb8adac | 130 | |
andrewboyson | 0:b843d647695c | 131 | //Clock settings |
andrewboyson | 0:b843d647695c | 132 | void SetClockSlewDivisor (int value) { ClkGovSlewDivisor = value; FramWrite(iClkGovSlewDivisor, 4, &ClkGovSlewDivisor ); } |
andrewboyson | 0:b843d647695c | 133 | void SetClockSlewMaxMs (int value) { ClkGovSlewChangeMaxMs = value; FramWrite(iClkGovSlewMaxMs, 4, &ClkGovSlewChangeMaxMs ); } |
andrewboyson | 0:b843d647695c | 134 | void SetClockPpbDivisor (int value) { ClkGovFreqDivisor = value; FramWrite(iClkGovPpbDivisor, 4, &ClkGovFreqDivisor ); } |
andrewboyson | 0:b843d647695c | 135 | void SetClockPpbChangeMax (int value) { ClkGovFreqChangeMaxPpb = value; FramWrite(iClkGovPpbChangeMax, 4, &ClkGovFreqChangeMaxPpb ); } |
andrewboyson | 0:b843d647695c | 136 | void SetClockSyncedLimitNs (int value) { ClkGovSlewSyncedLimNs = value; FramWrite(iClkGovSyncedLimitNs, 4, &ClkGovSlewSyncedLimNs ); } |
andrewboyson | 0:b843d647695c | 137 | void SetClockSyncedLimitPpb (int value) { ClkGovFreqSyncedLimPpb = value; FramWrite(iClkGovSyncedLimitPpb, 4, &ClkGovFreqSyncedLimPpb ); } |
andrewboyson | 0:b843d647695c | 138 | void SetClockSyncedHysterisNs (int value) { ClkGovSlewSyncedHysNs = value; FramWrite(iClkGovSyncedHysterisNs, 4, &ClkGovSlewSyncedHysNs ); } |
andrewboyson | 0:b843d647695c | 139 | void SetClockSyncedHysterisPpb(int value) { ClkGovFreqSyncedHysPpb = value; FramWrite(iClkGovSyncedHysterisPpb, 4, &ClkGovFreqSyncedHysPpb ); } |
andrewboyson | 0:b843d647695c | 140 | void SetClockMaxOffsetSecs (int value) { ClkGovSlewOffsetMaxSecs = value; FramWrite(iClkGovMaxOffsetSecs, 4, &ClkGovSlewOffsetMaxSecs); } |
andrewboyson | 0:b843d647695c | 141 | void ChgTraceSync () { ClkGovTrace = !ClkGovTrace ; FramWrite(iClkGov, 1, &ClkGovTrace ); } |
andrewboyson | 0:b843d647695c | 142 | |
andrewboyson | 0:b843d647695c | 143 | //Log settings |
andrewboyson | 0:b843d647695c | 144 | void ChgLogUart () { LogUart = !LogUart; FramWrite(iLogUart, 1, &LogUart ); } |
andrewboyson | 0:b843d647695c | 145 | |
andrewboyson | 0:b843d647695c | 146 | //Heating settings |
andrewboyson | 0:b843d647695c | 147 | void ChgTraceOneWire () { OneWireTrace = !OneWireTrace ; FramWrite(iOneWire, 1, &OneWireTrace ); } |
andrewboyson | 0:b843d647695c | 148 | |
andrewboyson | 0:b843d647695c | 149 | //Net settings |
andrewboyson | 0:b843d647695c | 150 | void ChgDnsSendRequestsViaIp4 () { DnsSendRequestsViaIp4 = !DnsSendRequestsViaIp4; FramWrite( iDnsSendRequestsViaIp4, 1, &DnsSendRequestsViaIp4); } |
andrewboyson | 0:b843d647695c | 151 | void ChgNtpSendRequestsViaIp4 () { NtpClientQuerySendRequestsViaIp4 = !NtpClientQuerySendRequestsViaIp4; FramWrite( iNtpSendRequestsViaIp4, 1, &NtpClientQuerySendRequestsViaIp4); } |
andrewboyson | 0:b843d647695c | 152 | void ChgTftpSendRequestsViaIp4 () { TftpSendRequestsViaIp4 = !TftpSendRequestsViaIp4; FramWrite(iTftpSendRequestsViaIp4, 1, &TftpSendRequestsViaIp4); } |
andrewboyson | 0:b843d647695c | 153 | |
andrewboyson | 0:b843d647695c | 154 | void SetTraceNetHost (char* text) |
andrewboyson | 0:b843d647695c | 155 | { |
andrewboyson | 0:b843d647695c | 156 | int value = strtol(text, NULL, 16); |
andrewboyson | 0:b843d647695c | 157 | NetTraceHost[1] = value & 0xFF; |
andrewboyson | 0:b843d647695c | 158 | NetTraceHost[0] = (value >> 8) & 0xFF; |
andrewboyson | 0:b843d647695c | 159 | FramWrite(iNetHost, 2, NetTraceHost); |
andrewboyson | 0:b843d647695c | 160 | } |
andrewboyson | 0:b843d647695c | 161 | void ChgTraceNetStack () { NetTraceStack = !NetTraceStack; FramWrite(iNetStack, 1, &NetTraceStack ); } |
andrewboyson | 0:b843d647695c | 162 | void ChgTraceNetNewLine() { NetTraceNewLine = !NetTraceNewLine; FramWrite(iNetNewLine, 1, &NetTraceNewLine); } |
andrewboyson | 0:b843d647695c | 163 | void ChgTraceNetVerbose() { NetTraceVerbose = !NetTraceVerbose; FramWrite(iNetVerbose, 1, &NetTraceVerbose); } |
andrewboyson | 0:b843d647695c | 164 | void ChgTraceLink () { LinkTrace = !LinkTrace; FramWrite(iLink, 1, &LinkTrace ); } |
andrewboyson | 0:b843d647695c | 165 | void ChgTraceDnsName () { DnsNameTrace = !DnsNameTrace; FramWrite(iDnsName, 1, &DnsNameTrace ); } |
andrewboyson | 0:b843d647695c | 166 | void ChgTraceDnsQuery () { DnsQueryTrace = !DnsQueryTrace; FramWrite(iDnsQuery, 1, &DnsQueryTrace ); } |
andrewboyson | 0:b843d647695c | 167 | void ChgTraceDnsReply () { DnsReplyTrace = !DnsReplyTrace; FramWrite(iDnsReply, 1, &DnsReplyTrace ); } |
andrewboyson | 0:b843d647695c | 168 | void ChgTraceDnsServer () { DnsServerTrace = !DnsServerTrace; FramWrite(iDnsServer, 1, &DnsServerTrace ); } |
andrewboyson | 0:b843d647695c | 169 | void ChgTraceNtp () { NtpTrace = !NtpTrace; FramWrite(iNtp, 1, &NtpTrace ); } |
andrewboyson | 0:b843d647695c | 170 | void ChgTraceDhcp () { DhcpTrace = !DhcpTrace; FramWrite(iDhcp, 1, &DhcpTrace ); } |
andrewboyson | 0:b843d647695c | 171 | void ChgTraceNsRecvSol () { NsTraceRecvSol = !NsTraceRecvSol; FramWrite(iNsRecvSol, 1, &NsTraceRecvSol); } |
andrewboyson | 0:b843d647695c | 172 | void ChgTraceNsRecvAdv () { NsTraceRecvAdv = !NsTraceRecvAdv; FramWrite(iNsRecvAdv, 1, &NsTraceRecvAdv); } |
andrewboyson | 0:b843d647695c | 173 | void ChgTraceNsSendSol () { NsTraceSendSol = !NsTraceSendSol; FramWrite(iNsSendSol, 1, &NsTraceSendSol); } |
andrewboyson | 0:b843d647695c | 174 | void ChgTraceNr4 () { Nr4Trace = !Nr4Trace ; FramWrite(iNr4, 1, &Nr4Trace ); } |
andrewboyson | 1:3a341b6ca233 | 175 | void ChgTraceNr () { NrTrace = !NrTrace ; FramWrite(iNr, 1, &NrTrace ); } |
andrewboyson | 0:b843d647695c | 176 | void ChgTraceNtpClient () { NtpClientTrace = !NtpClientTrace ; FramWrite(iNtpClient, 1, &NtpClientTrace ); } |
andrewboyson | 0:b843d647695c | 177 | void ChgTraceEcho4 () { Echo4Trace = !Echo4Trace ; FramWrite(iEcho4, 1, &Echo4Trace ); } |
andrewboyson | 0:b843d647695c | 178 | void ChgTraceEcho6 () { Echo6Trace = !Echo6Trace ; FramWrite(iEcho6, 1, &Echo6Trace ); } |
andrewboyson | 0:b843d647695c | 179 | void ChgTraceDest6 () { Dest6Trace = !Dest6Trace ; FramWrite(iDest6, 1, &Dest6Trace ); } |
andrewboyson | 0:b843d647695c | 180 | void ChgTraceRa () { RaTrace = !RaTrace ; FramWrite(iRa, 1, &RaTrace ); } |
andrewboyson | 0:b843d647695c | 181 | void ChgTraceRs () { RsTrace = !RsTrace ; FramWrite(iRs, 1, &RsTrace ); } |
andrewboyson | 0:b843d647695c | 182 | void ChgTraceAr4 () { Ar4Trace = !Ar4Trace ; FramWrite(iAr4, 1, &Ar4Trace ); } |
andrewboyson | 0:b843d647695c | 183 | void ChgTraceAr6 () { Ar6Trace = !Ar6Trace ; FramWrite(iAr6, 1, &Ar6Trace ); } |
andrewboyson | 0:b843d647695c | 184 | void ChgTraceArp () { ArpTrace = !ArpTrace ; FramWrite(iArp, 1, &ArpTrace ); } |
andrewboyson | 0:b843d647695c | 185 | void ChgTraceIp4 () { Ip4Trace = !Ip4Trace ; FramWrite(iIp4, 1, &Ip4Trace ); } |
andrewboyson | 0:b843d647695c | 186 | void ChgTraceIp6 () { Ip6Trace = !Ip6Trace ; FramWrite(iIp6, 1, &Ip6Trace ); } |
andrewboyson | 0:b843d647695c | 187 | void ChgTraceUdp () { UdpTrace = !UdpTrace ; FramWrite(iUdp, 1, &UdpTrace ); } |
andrewboyson | 0:b843d647695c | 188 | void ChgTraceTcp () { TcpTrace = !TcpTrace ; FramWrite(iTcp, 1, &TcpTrace ); } |
andrewboyson | 0:b843d647695c | 189 | void ChgTraceHttp () { WebTrace = !WebTrace ; FramWrite(iHttp, 1, &WebTrace ); } |
andrewboyson | 0:b843d647695c | 190 | void ChgTraceTftp () { TftpTrace = !TftpTrace ; FramWrite(iTftp, 1, &TftpTrace ); } |
andrewboyson | 0:b843d647695c | 191 | |
andrewboyson | 0:b843d647695c | 192 | |
andrewboyson | 0:b843d647695c | 193 | |
andrewboyson | 0:b843d647695c | 194 | static int iServerName; |
andrewboyson | 0:b843d647695c | 195 | static int iInitialInterval; |
andrewboyson | 0:b843d647695c | 196 | static int iNormalInterval; |
andrewboyson | 0:b843d647695c | 197 | static int iRetryInterval; |
andrewboyson | 0:b843d647695c | 198 | static int iOffsetMs; |
andrewboyson | 0:b843d647695c | 199 | static int iMaxDelayMs; |
andrewboyson | 0:b843d647695c | 200 | |
andrewboyson | 0:b843d647695c | 201 | void SetNtpClientServerName ( char* value) { DnsLabelCopy(NtpClientQueryServerName, value); FramWrite(iServerName, DNS_MAX_LABEL_LENGTH, NtpClientQueryServerName ); } |
andrewboyson | 0:b843d647695c | 202 | void SetNtpClientInitialInterval ( int value) { NtpClientQueryInitialInterval = (int32_t)value ; FramWrite(iInitialInterval, 4, &NtpClientQueryInitialInterval ); } |
andrewboyson | 0:b843d647695c | 203 | void SetNtpClientNormalInterval ( int value) { NtpClientQueryNormalInterval = (int32_t)value ; FramWrite(iNormalInterval, 4, &NtpClientQueryNormalInterval ); } |
andrewboyson | 0:b843d647695c | 204 | void SetNtpClientRetryInterval ( int value) { NtpClientQueryRetryInterval = (int32_t)value ; FramWrite(iRetryInterval, 4, &NtpClientQueryRetryInterval ); } |
andrewboyson | 0:b843d647695c | 205 | void SetNtpClientOffsetMs ( int value) { NtpClientReplyOffsetMs = (int32_t)value ; FramWrite(iOffsetMs, 4, &NtpClientReplyOffsetMs ); } |
andrewboyson | 0:b843d647695c | 206 | void SetNtpClientMaxDelayMs ( int value) { NtpClientReplyMaxDelayMs = (int32_t)value ; FramWrite(iMaxDelayMs, 4, &NtpClientReplyMaxDelayMs ); } |
andrewboyson | 0:b843d647695c | 207 | |
andrewboyson | 0:b843d647695c | 208 | int SettingsNtpInit() |
andrewboyson | 0:b843d647695c | 209 | { |
andrewboyson | 0:b843d647695c | 210 | int address; |
andrewboyson | 0:b843d647695c | 211 | int32_t def4; |
andrewboyson | 0:b843d647695c | 212 | |
andrewboyson | 0:b843d647695c | 213 | def4 = 0; address = FramLoad( DNS_MAX_LABEL_LENGTH+1, NtpClientQueryServerName, NULL ); if (address < 0) return -1; iServerName = address; |
andrewboyson | 0:b843d647695c | 214 | def4 = 1; address = FramLoad( 4, &NtpClientQueryInitialInterval, &def4); if (address < 0) return -1; iInitialInterval = address; |
andrewboyson | 0:b843d647695c | 215 | def4 = 600; address = FramLoad( 4, &NtpClientQueryNormalInterval, &def4); if (address < 0) return -1; iNormalInterval = address; |
andrewboyson | 0:b843d647695c | 216 | def4 = 60; address = FramLoad( 4, &NtpClientQueryRetryInterval, &def4); if (address < 0) return -1; iRetryInterval = address; |
andrewboyson | 0:b843d647695c | 217 | def4 = 0; address = FramLoad( 4, &NtpClientReplyOffsetMs, &def4); if (address < 0) return -1; iOffsetMs = address; |
andrewboyson | 0:b843d647695c | 218 | def4 = 50; address = FramLoad( 4, &NtpClientReplyMaxDelayMs, &def4); if (address < 0) return -1; iMaxDelayMs = address; |
andrewboyson | 0:b843d647695c | 219 | |
andrewboyson | 0:b843d647695c | 220 | return 0; |
andrewboyson | 0:b843d647695c | 221 | } |
andrewboyson | 0:b843d647695c | 222 | |
andrewboyson | 0:b843d647695c | 223 | int SettingsInit() |
andrewboyson | 0:b843d647695c | 224 | { |
andrewboyson | 0:b843d647695c | 225 | int address; |
andrewboyson | 0:b843d647695c | 226 | int32_t def4; |
andrewboyson | 4:f38b5bb8adac | 227 | int64_t def8; |
andrewboyson | 0:b843d647695c | 228 | char b; |
andrewboyson | 0:b843d647695c | 229 | |
andrewboyson | 0:b843d647695c | 230 | def4 = 10; address = FramLoad( 4, &ClkGovSlewDivisor, &def4); if (address < 0) return -1; iClkGovSlewDivisor = address; |
andrewboyson | 0:b843d647695c | 231 | def4 = 20; address = FramLoad( 4, &ClkGovSlewChangeMaxMs, &def4); if (address < 0) return -1; iClkGovSlewMaxMs = address; |
andrewboyson | 0:b843d647695c | 232 | def4 = 1000; address = FramLoad( 4, &ClkGovFreqDivisor, &def4); if (address < 0) return -1; iClkGovPpbDivisor = address; |
andrewboyson | 0:b843d647695c | 233 | def4 = 10000000; address = FramLoad( 4, &ClkGovFreqChangeMaxPpb, &def4); if (address < 0) return -1; iClkGovPpbChangeMax = address; |
andrewboyson | 0:b843d647695c | 234 | def4 = 100000; address = FramLoad( 4, &ClkGovSlewSyncedLimNs, &def4); if (address < 0) return -1; iClkGovSyncedLimitNs = address; |
andrewboyson | 0:b843d647695c | 235 | def4 = 100000; address = FramLoad( 4, &ClkGovFreqSyncedLimPpb, &def4); if (address < 0) return -1; iClkGovSyncedLimitPpb = address; |
andrewboyson | 0:b843d647695c | 236 | def4 = 10000; address = FramLoad( 4, &ClkGovSlewSyncedHysNs, &def4); if (address < 0) return -1; iClkGovSyncedHysterisNs = address; |
andrewboyson | 0:b843d647695c | 237 | def4 = 1000; address = FramLoad( 4, &ClkGovFreqSyncedHysPpb, &def4); if (address < 0) return -1; iClkGovSyncedHysterisPpb = address; |
andrewboyson | 0:b843d647695c | 238 | def4 = 3; address = FramLoad( 4, &ClkGovSlewOffsetMaxSecs, &def4); if (address < 0) return -1; iClkGovMaxOffsetSecs = address; |
andrewboyson | 0:b843d647695c | 239 | address = FramLoad( 1, &b, NULL); ClkGovTrace = b; if (address < 0) return -1; iClkGov = address; |
andrewboyson | 0:b843d647695c | 240 | address = FramLoad( 1, &b, NULL); OneWireTrace = b; if (address < 0) return -1; iOneWire = address; |
andrewboyson | 0:b843d647695c | 241 | address = FramLoad( 1, &b, NULL); DnsSendRequestsViaIp4 = b; if (address < 0) return -1; iDnsSendRequestsViaIp4 = address; |
andrewboyson | 0:b843d647695c | 242 | address = FramLoad( 1, &b, NULL); NtpClientQuerySendRequestsViaIp4 = b; if (address < 0) return -1; iNtpSendRequestsViaIp4 = address; |
andrewboyson | 0:b843d647695c | 243 | address = FramLoad( 1, &b, NULL); TftpSendRequestsViaIp4 = b; if (address < 0) return -1; iTftpSendRequestsViaIp4 = address; |
andrewboyson | 0:b843d647695c | 244 | address = FramLoad( 1, &b, NULL); LogUart = b; if (address < 0) return -1; iLogUart = address; |
andrewboyson | 0:b843d647695c | 245 | address = FramLoad( 2, NetTraceHost, NULL) ; if (address < 0) return -1; iNetHost = address; |
andrewboyson | 0:b843d647695c | 246 | address = FramLoad( 1, &b, NULL); NetTraceStack = b; if (address < 0) return -1; iNetStack = address; |
andrewboyson | 0:b843d647695c | 247 | address = FramLoad( 1, &b, NULL); NetTraceNewLine = b; if (address < 0) return -1; iNetNewLine = address; |
andrewboyson | 0:b843d647695c | 248 | address = FramLoad( 1, &b, NULL); NetTraceVerbose = b; if (address < 0) return -1; iNetVerbose = address; |
andrewboyson | 0:b843d647695c | 249 | address = FramLoad( 1, &b, NULL); LinkTrace = b; if (address < 0) return -1; iLink = address; |
andrewboyson | 0:b843d647695c | 250 | address = FramLoad( 1, &b, NULL); DnsNameTrace = b; if (address < 0) return -1; iDnsName = address; |
andrewboyson | 0:b843d647695c | 251 | address = FramLoad( 1, &b, NULL); DnsQueryTrace = b; if (address < 0) return -1; iDnsQuery = address; |
andrewboyson | 0:b843d647695c | 252 | address = FramLoad( 1, &b, NULL); DnsReplyTrace = b; if (address < 0) return -1; iDnsReply = address; |
andrewboyson | 0:b843d647695c | 253 | address = FramLoad( 1, &b, NULL); DnsServerTrace = b; if (address < 0) return -1; iDnsServer = address; |
andrewboyson | 0:b843d647695c | 254 | address = FramLoad( 1, &b, NULL); NtpTrace = b; if (address < 0) return -1; iNtp = address; |
andrewboyson | 0:b843d647695c | 255 | address = FramLoad( 1, &b, NULL); DhcpTrace = b; if (address < 0) return -1; iDhcp = address; |
andrewboyson | 0:b843d647695c | 256 | address = FramLoad( 1, &b, NULL); NsTraceRecvSol = b; if (address < 0) return -1; iNsRecvSol = address; |
andrewboyson | 0:b843d647695c | 257 | address = FramLoad( 1, &b, NULL); NsTraceRecvAdv = b; if (address < 0) return -1; iNsRecvAdv = address; |
andrewboyson | 0:b843d647695c | 258 | address = FramLoad( 1, &b, NULL); NsTraceSendSol = b; if (address < 0) return -1; iNsSendSol = address; |
andrewboyson | 0:b843d647695c | 259 | address = FramLoad( 1, &b, NULL); Nr4Trace = b; if (address < 0) return -1; iNr4 = address; |
andrewboyson | 0:b843d647695c | 260 | address = FramLoad( 1, &b, NULL); NrTrace = b; if (address < 0) return -1; iNr = address; |
andrewboyson | 0:b843d647695c | 261 | address = FramLoad( 1, &b, NULL); NtpClientTrace = b; if (address < 0) return -1; iNtpClient = address; |
andrewboyson | 0:b843d647695c | 262 | address = FramLoad( 1, &b, NULL); Echo4Trace = b; if (address < 0) return -1; iEcho4 = address; |
andrewboyson | 0:b843d647695c | 263 | address = FramLoad( 1, &b, NULL); Echo6Trace = b; if (address < 0) return -1; iEcho6 = address; |
andrewboyson | 0:b843d647695c | 264 | address = FramLoad( 1, &b, NULL); Dest6Trace = b; if (address < 0) return -1; iDest6 = address; |
andrewboyson | 0:b843d647695c | 265 | address = FramLoad( 1, &b, NULL); RaTrace = b; if (address < 0) return -1; iRa = address; |
andrewboyson | 0:b843d647695c | 266 | address = FramLoad( 1, &b, NULL); RsTrace = b; if (address < 0) return -1; iRs = address; |
andrewboyson | 0:b843d647695c | 267 | address = FramLoad( 1, &b, NULL); Ar4Trace = b; if (address < 0) return -1; iAr4 = address; |
andrewboyson | 0:b843d647695c | 268 | address = FramLoad( 1, &b, NULL); Ar6Trace = b; if (address < 0) return -1; iAr6 = address; |
andrewboyson | 0:b843d647695c | 269 | address = FramLoad( 1, &b, NULL); ArpTrace = b; if (address < 0) return -1; iArp = address; |
andrewboyson | 0:b843d647695c | 270 | address = FramLoad( 1, &b, NULL); Ip4Trace = b; if (address < 0) return -1; iIp4 = address; |
andrewboyson | 0:b843d647695c | 271 | address = FramLoad( 1, &b, NULL); Ip6Trace = b; if (address < 0) return -1; iIp6 = address; |
andrewboyson | 0:b843d647695c | 272 | address = FramLoad( 1, &b, NULL); UdpTrace = b; if (address < 0) return -1; iUdp = address; |
andrewboyson | 0:b843d647695c | 273 | address = FramLoad( 1, &b, NULL); TcpTrace = b; if (address < 0) return -1; iTcp = address; |
andrewboyson | 0:b843d647695c | 274 | address = FramLoad( 1, &b, NULL); WebTrace = b; if (address < 0) return -1; iHttp = address; |
andrewboyson | 0:b843d647695c | 275 | address = FramLoad( 1, &b, NULL); TftpTrace = b; if (address < 0) return -1; iTftp = address; |
andrewboyson | 0:b843d647695c | 276 | |
andrewboyson | 4:f38b5bb8adac | 277 | address = FramAllocate(DNS_MAX_LABEL_LENGTH); if (address < 0) return -1; iValuesServerName = address; |
andrewboyson | 4:f38b5bb8adac | 278 | FramAllocate(1); //Spare |
andrewboyson | 4:f38b5bb8adac | 279 | address = FramAllocate(DNS_MAX_LABEL_LENGTH); if (address < 0) return -1; iValuesFileName = address; |
andrewboyson | 4:f38b5bb8adac | 280 | FramAllocate(1); //Spare |
andrewboyson | 4:f38b5bb8adac | 281 | address = FramAllocate( 4); if (address < 0) return -1; iValuesWriteSize = address; |
andrewboyson | 4:f38b5bb8adac | 282 | address = FramAllocate( 4); if (address < 0) return -1; iValuesReadInterval = address; |
andrewboyson | 4:f38b5bb8adac | 283 | address = FramAllocate( 8); if (address < 0) return -1; iValuesStartTime = address; |
andrewboyson | 4:f38b5bb8adac | 284 | address = FramAllocate( 4); if (address < 0) return -1; iValuesCount = address; |
andrewboyson | 4:f38b5bb8adac | 285 | address = FramAllocate( 1); if (address < 0) return -1; iValuesData = address; |
andrewboyson | 4:f38b5bb8adac | 286 | if (FramEmpty) |
andrewboyson | 4:f38b5bb8adac | 287 | { |
andrewboyson | 4:f38b5bb8adac | 288 | b = 0; FramWrite(iValuesServerName , 1, &b ); |
andrewboyson | 4:f38b5bb8adac | 289 | b = 0; FramWrite(iValuesFileName , 1, &b ); |
andrewboyson | 4:f38b5bb8adac | 290 | def4 = 100; FramWrite(iValuesWriteSize , 4, &def4); |
andrewboyson | 4:f38b5bb8adac | 291 | def4 = 15; FramWrite(iValuesReadInterval, 4, &def4); |
andrewboyson | 4:f38b5bb8adac | 292 | def8 = 0; FramWrite(iValuesStartTime , 8, &def8); |
andrewboyson | 4:f38b5bb8adac | 293 | def4 = 0; FramWrite(iValuesCount , 4, &def4); |
andrewboyson | 4:f38b5bb8adac | 294 | } |
andrewboyson | 4:f38b5bb8adac | 295 | |
andrewboyson | 4:f38b5bb8adac | 296 | address = FramLoad( 1, &b, NULL); WizTrace = b; if (address < 0) return -1; iWizTrace = address; |
andrewboyson | 4:f38b5bb8adac | 297 | |
andrewboyson | 4:f38b5bb8adac | 298 | for (int i = 0; i < WIZ_LIST_MAX_ITEMS; i++) |
andrewboyson | 4:f38b5bb8adac | 299 | { |
andrewboyson | 4:f38b5bb8adac | 300 | char mac [6]; |
andrewboyson | 4:f38b5bb8adac | 301 | char name[WIZ_LIST_NAME_LENGTH]; |
andrewboyson | 4:f38b5bb8adac | 302 | address = FramLoad(6 , mac , NULL); if (address < 0) return -1; iWizMacs [i] = address; |
andrewboyson | 4:f38b5bb8adac | 303 | address = FramLoad(WIZ_LIST_NAME_LENGTH, name, NULL); if (address < 0) return -1; iWizNames[i] = address; |
andrewboyson | 4:f38b5bb8adac | 304 | WizListSetMac (i, mac ); |
andrewboyson | 4:f38b5bb8adac | 305 | WizListSetName(i, name); |
andrewboyson | 4:f38b5bb8adac | 306 | } |
andrewboyson | 4:f38b5bb8adac | 307 | |
andrewboyson | 4:f38b5bb8adac | 308 | iValuesData = FramUsed; |
andrewboyson | 4:f38b5bb8adac | 309 | |
andrewboyson | 0:b843d647695c | 310 | return 0; |
andrewboyson | 4:f38b5bb8adac | 311 | |
andrewboyson | 0:b843d647695c | 312 | } |
andrewboyson | 4:f38b5bb8adac | 313 | |
andrewboyson | 4:f38b5bb8adac | 314 | |
andrewboyson | 4:f38b5bb8adac | 315 | |
andrewboyson | 4:f38b5bb8adac | 316 | |
andrewboyson | 4:f38b5bb8adac | 317 | |
andrewboyson | 4:f38b5bb8adac | 318 |