Central Heating controller using the real time clock, PHY module for internet, 1-wire interface for temperature sensors, a system log and a configuration file

Dependencies:   net 1-wire lpc1768 crypto clock web fram log

/media/uploads/andrewboyson/heating.sch

/media/uploads/andrewboyson/heating.brd

/media/uploads/andrewboyson/eagle.epf

Committer:
andrewboyson
Date:
Thu Jul 25 21:17:40 2019 +0000
Revision:
67:2d379b0c5f05
Parent:
64:c736b8924574
Child:
68:19c5efffc900
Updated libraries

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 49:9491c966dc60 1 #include <stdio.h>
andrewboyson 67:2d379b0c5f05 2 #include <string.h>
andrewboyson 49:9491c966dc60 3
andrewboyson 49:9491c966dc60 4 #include "http.h"
andrewboyson 53:c1bf7d9db507 5 #include "web-nav-this.h"
andrewboyson 51:c7c6ce0d57ad 6 #include "web-add.h"
andrewboyson 67:2d379b0c5f05 7 #include "log.h"
andrewboyson 63:ae264156d655 8 #include "bignum.h"
andrewboyson 67:2d379b0c5f05 9 #include "sha-256.h"
andrewboyson 67:2d379b0c5f05 10 #include "hmac-sha-256.h"
andrewboyson 49:9491c966dc60 11
andrewboyson 49:9491c966dc60 12 void WebSystemHtml()
andrewboyson 49:9491c966dc60 13 {
andrewboyson 49:9491c966dc60 14 HttpOk("text/html; charset=UTF-8", "no-cache", NULL, NULL);
andrewboyson 51:c7c6ce0d57ad 15 WebAddHeader("System", "settings.css", "system.js");
andrewboyson 51:c7c6ce0d57ad 16 WebAddNav(SYSTEM_PAGE);
andrewboyson 51:c7c6ce0d57ad 17 WebAddH1("System");
andrewboyson 49:9491c966dc60 18
andrewboyson 51:c7c6ce0d57ad 19 WebAddH2("TFTP");
andrewboyson 51:c7c6ce0d57ad 20 WebAddAjaxInput ("Server url", 5, "ajax-server-name", "tftpserver" );
andrewboyson 51:c7c6ce0d57ad 21 WebAddAjaxInput ("File (strftime)", 11, "ajax-file-name", "tftpfilename" );
andrewboyson 51:c7c6ce0d57ad 22 WebAddAjaxInput ("Interval (secs) 0=no", 5, "ajax-read-interval", "tftpreadint" );
andrewboyson 51:c7c6ce0d57ad 23 WebAddAjaxInput ("Records per backup 0=no", 5, "ajax-write-size", "tftpwriteint" );
andrewboyson 51:c7c6ce0d57ad 24 WebAddAjaxLabelled("Count", "ajax-count" );
andrewboyson 51:c7c6ce0d57ad 25 WebAddAjaxLabelled("Started", "ajax-start-time" );
andrewboyson 49:9491c966dc60 26
andrewboyson 51:c7c6ce0d57ad 27 WebAddH2("FRAM");
andrewboyson 51:c7c6ce0d57ad 28 WebAddAjaxLabelled("Used", "ajax-fram-used" );
andrewboyson 49:9491c966dc60 29
andrewboyson 51:c7c6ce0d57ad 30 WebAddH2("Compiler");
andrewboyson 51:c7c6ce0d57ad 31 WebAddLabelledInt("Version Vvvbbbb", __ARMCC_VERSION);
andrewboyson 49:9491c966dc60 32
andrewboyson 67:2d379b0c5f05 33 WebAddH2("SHA 256 test");
andrewboyson 67:2d379b0c5f05 34 char hash[32];
andrewboyson 67:2d379b0c5f05 35 char* input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
andrewboyson 67:2d379b0c5f05 36 Sha256(input, strlen(input), hash);
andrewboyson 67:2d379b0c5f05 37 HttpAddText("<code>");
andrewboyson 67:2d379b0c5f05 38 HttpAddBytesAsHex(hash, sizeof(hash));
andrewboyson 67:2d379b0c5f05 39 HttpAddText("</code>");
andrewboyson 67:2d379b0c5f05 40
andrewboyson 67:2d379b0c5f05 41 WebAddH2("HMAC SHA 256 test");
andrewboyson 67:2d379b0c5f05 42 char* key = "Jefe";
andrewboyson 67:2d379b0c5f05 43 char* msg = "what do ya want for nothing?";
andrewboyson 67:2d379b0c5f05 44 char mac[32];
andrewboyson 67:2d379b0c5f05 45 HmacSha256(key, strlen(key), msg, strlen(msg), mac);
andrewboyson 67:2d379b0c5f05 46 HttpAddText("<code>");
andrewboyson 67:2d379b0c5f05 47 HttpAddBytesAsHex(mac, sizeof(mac));
andrewboyson 67:2d379b0c5f05 48 HttpAddText("</code>");
andrewboyson 67:2d379b0c5f05 49
andrewboyson 63:ae264156d655 50 WebAddH2("Big num test");
andrewboyson 63:ae264156d655 51
andrewboyson 63:ae264156d655 52 char* n =
andrewboyson 63:ae264156d655 53 "E08973398DD8F5F5E88776397F4EB005BB5383DE0FB7ABDC7DC775290D052E6D"
andrewboyson 63:ae264156d655 54 "12DFA68626D4D26FAA5829FC97ECFA82510F3080BEB1509E4644F12CBBD832CF"
andrewboyson 63:ae264156d655 55 "C6686F07D9B060ACBEEE34096A13F5F7050593DF5EBA3556D961FF197FC981E6"
andrewboyson 63:ae264156d655 56 "F86CEA874070EFAC6D2C749F2DFA553AB9997702A648528C4EF357385774575F";
andrewboyson 63:ae264156d655 57
andrewboyson 63:ae264156d655 58 char* d =
andrewboyson 63:ae264156d655 59 "00A403C327477634346CA686B57949014B2E8AD2C862B2C7D748096A8B91F736"
andrewboyson 63:ae264156d655 60 "F275D6E8CD15906027314735644D95CD6763CEB49F56AC2F376E1CEE0EBF282D"
andrewboyson 63:ae264156d655 61 "F439906F34D86E085BD5656AD841F313D72D395EFE33CBFF29E4030B3D05A28F"
andrewboyson 63:ae264156d655 62 "B7F18EA27637B07957D32F2BDE8706227D04665EC91BAF8B1AC3EC9144AB7F21";
andrewboyson 64:c736b8924574 63
andrewboyson 63:ae264156d655 64 char* m =
andrewboyson 63:ae264156d655 65 "0001FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
andrewboyson 63:ae264156d655 66 "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
andrewboyson 63:ae264156d655 67 "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00302130"
andrewboyson 63:ae264156d655 68 "0906052B0E03021A05000414A9993E364706816ABA3E25717850C26C9CD0D89D";
andrewboyson 49:9491c966dc60 69
andrewboyson 64:c736b8924574 70 uint32_t message [32];
andrewboyson 64:c736b8924574 71 uint32_t exponent[32];
andrewboyson 64:c736b8924574 72 uint32_t modulus [32];
andrewboyson 63:ae264156d655 73
andrewboyson 64:c736b8924574 74 BnParseHex1024(message, m);
andrewboyson 64:c736b8924574 75 BnParseHex1024(exponent, d);
andrewboyson 64:c736b8924574 76 BnParseHex1024(modulus, n);
andrewboyson 63:ae264156d655 77
andrewboyson 64:c736b8924574 78 static uint32_t result[32];
andrewboyson 63:ae264156d655 79
andrewboyson 63:ae264156d655 80 static bool started = false;
andrewboyson 63:ae264156d655 81 if (!started)
andrewboyson 63:ae264156d655 82 {
andrewboyson 63:ae264156d655 83 BnExpModStart(message, exponent, modulus, result);
andrewboyson 63:ae264156d655 84 started = true;
andrewboyson 63:ae264156d655 85 }
andrewboyson 63:ae264156d655 86
andrewboyson 63:ae264156d655 87 HttpAddText("<code>");
andrewboyson 63:ae264156d655 88 HttpAddText("Message\r\n");
andrewboyson 64:c736b8924574 89 BnAsHttp1024(message);
andrewboyson 63:ae264156d655 90 HttpAddText("\r\nExponent\r\n");
andrewboyson 64:c736b8924574 91 BnAsHttp1024(exponent);
andrewboyson 63:ae264156d655 92 HttpAddText("\r\nModulus\r\n");
andrewboyson 64:c736b8924574 93 BnAsHttp1024(modulus);
andrewboyson 63:ae264156d655 94 HttpAddText("\r\nResult\r\n");
andrewboyson 63:ae264156d655 95 switch(BnExpModStatus)
andrewboyson 63:ae264156d655 96 {
andrewboyson 63:ae264156d655 97 case BIGNUM_CALC_NONE:
andrewboyson 63:ae264156d655 98 HttpAddText("Not started\r\n");
andrewboyson 63:ae264156d655 99 break;
andrewboyson 63:ae264156d655 100 case BIGNUM_CALC_STARTED:
andrewboyson 63:ae264156d655 101 HttpAddF("Progress %d\r\n", BnExpModProgress);
andrewboyson 64:c736b8924574 102 BnAsHttp1024(result);
andrewboyson 63:ae264156d655 103 break;
andrewboyson 63:ae264156d655 104 case BIGNUM_CALC_FINISHED:
andrewboyson 63:ae264156d655 105 HttpAddText("Finished\r\n");
andrewboyson 64:c736b8924574 106 BnAsHttp1024(result);
andrewboyson 63:ae264156d655 107 HttpAddF("Time to multiply %llu ms\r\n", BnMulHr / 96000);
andrewboyson 63:ae264156d655 108 HttpAddF("Time to modulus %llu ms\r\n", BnModHr / 96000);
andrewboyson 63:ae264156d655 109 break;
andrewboyson 63:ae264156d655 110 }
andrewboyson 63:ae264156d655 111 HttpAddText("</code>");
andrewboyson 63:ae264156d655 112
andrewboyson 63:ae264156d655 113 WebAddEnd();
andrewboyson 49:9491c966dc60 114 }