Manages the 1-wire bus
Dependents: oldheating heating
web/web-1wire-ajax.c@2:79cad6a51fd0, 2019-04-27 (annotated)
- Committer:
- andrewboyson
- Date:
- Sat Apr 27 09:26:15 2019 +0000
- Revision:
- 2:79cad6a51fd0
- Child:
- 4:822208cb5a13
Updated web library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 2:79cad6a51fd0 | 1 | #include <stdint.h> |
andrewboyson | 2:79cad6a51fd0 | 2 | #include <stdio.h> |
andrewboyson | 2:79cad6a51fd0 | 3 | |
andrewboyson | 2:79cad6a51fd0 | 4 | #include "http.h" |
andrewboyson | 2:79cad6a51fd0 | 5 | #include "web-base.h" |
andrewboyson | 2:79cad6a51fd0 | 6 | #include "ds18b20.h" |
andrewboyson | 2:79cad6a51fd0 | 7 | #include "1-wire.h" |
andrewboyson | 2:79cad6a51fd0 | 8 | #include "1-wire-bus.h" |
andrewboyson | 2:79cad6a51fd0 | 9 | #include "1-wire-device.h" |
andrewboyson | 2:79cad6a51fd0 | 10 | #include "radiator.h" |
andrewboyson | 2:79cad6a51fd0 | 11 | #include "boiler.h" |
andrewboyson | 2:79cad6a51fd0 | 12 | |
andrewboyson | 2:79cad6a51fd0 | 13 | static void addRomToHttp(char* pRom) |
andrewboyson | 2:79cad6a51fd0 | 14 | { |
andrewboyson | 2:79cad6a51fd0 | 15 | for (char* p = pRom; p < pRom + 8; p++) HttpAddByteAsHex(*p); |
andrewboyson | 2:79cad6a51fd0 | 16 | } |
andrewboyson | 2:79cad6a51fd0 | 17 | |
andrewboyson | 2:79cad6a51fd0 | 18 | void WebOneWireAjax() |
andrewboyson | 2:79cad6a51fd0 | 19 | { |
andrewboyson | 2:79cad6a51fd0 | 20 | HttpOk("text/plain; charset=UTF-8", "no-cache", NULL, NULL); |
andrewboyson | 2:79cad6a51fd0 | 21 | |
andrewboyson | 2:79cad6a51fd0 | 22 | HttpAddInt16AsHex (DeviceScanMs); HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 23 | HttpAddInt16AsHex (OneWireBusLowTweak); HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 24 | HttpAddInt16AsHex (OneWireBusFloatTweak); HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 25 | HttpAddInt16AsHex (OneWireBusReadTweak); HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 26 | HttpAddInt16AsHex (OneWireBusHighTweak); HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 27 | HttpAddInt16AsHex (OneWireBusReleaseTweak); HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 28 | HttpAddNibbleAsHex(OneWireTrace); HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 29 | HttpAddChar('\f'); |
andrewboyson | 2:79cad6a51fd0 | 30 | |
andrewboyson | 2:79cad6a51fd0 | 31 | for (int device = 0; device < DeviceCount; device++) |
andrewboyson | 2:79cad6a51fd0 | 32 | { |
andrewboyson | 2:79cad6a51fd0 | 33 | addRomToHttp ( DeviceList + device * 8); |
andrewboyson | 2:79cad6a51fd0 | 34 | HttpAddInt16AsHex(*(DS18B20Value + device) ); |
andrewboyson | 2:79cad6a51fd0 | 35 | HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 36 | } |
andrewboyson | 2:79cad6a51fd0 | 37 | HttpAddChar('\f'); |
andrewboyson | 2:79cad6a51fd0 | 38 | |
andrewboyson | 2:79cad6a51fd0 | 39 | for (int rom = 0; rom < DS18B20RomCount; rom++) |
andrewboyson | 2:79cad6a51fd0 | 40 | { |
andrewboyson | 2:79cad6a51fd0 | 41 | addRomToHttp(DS18B20Roms + rom * 8); |
andrewboyson | 2:79cad6a51fd0 | 42 | HttpAddText(DS18B20RomNames[rom]); |
andrewboyson | 2:79cad6a51fd0 | 43 | HttpAddChar('\n'); |
andrewboyson | 2:79cad6a51fd0 | 44 | } |
andrewboyson | 2:79cad6a51fd0 | 45 | } |
andrewboyson | 2:79cad6a51fd0 | 46 |