Manages the 1-wire bus
Dependents: oldheating heating
Diff: web/web-1wire-ajax.c
- Revision:
- 2:79cad6a51fd0
- Child:
- 4:822208cb5a13
diff -r c272b1fcc834 -r 79cad6a51fd0 web/web-1wire-ajax.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/web-1wire-ajax.c Sat Apr 27 09:26:15 2019 +0000 @@ -0,0 +1,46 @@ +#include <stdint.h> +#include <stdio.h> + +#include "http.h" +#include "web-base.h" +#include "ds18b20.h" +#include "1-wire.h" +#include "1-wire-bus.h" +#include "1-wire-device.h" +#include "radiator.h" +#include "boiler.h" + +static void addRomToHttp(char* pRom) +{ + for (char* p = pRom; p < pRom + 8; p++) HttpAddByteAsHex(*p); +} + +void WebOneWireAjax() +{ + HttpOk("text/plain; charset=UTF-8", "no-cache", NULL, NULL); + + HttpAddInt16AsHex (DeviceScanMs); HttpAddChar('\n'); + HttpAddInt16AsHex (OneWireBusLowTweak); HttpAddChar('\n'); + HttpAddInt16AsHex (OneWireBusFloatTweak); HttpAddChar('\n'); + HttpAddInt16AsHex (OneWireBusReadTweak); HttpAddChar('\n'); + HttpAddInt16AsHex (OneWireBusHighTweak); HttpAddChar('\n'); + HttpAddInt16AsHex (OneWireBusReleaseTweak); HttpAddChar('\n'); + HttpAddNibbleAsHex(OneWireTrace); HttpAddChar('\n'); + HttpAddChar('\f'); + + for (int device = 0; device < DeviceCount; device++) + { + addRomToHttp ( DeviceList + device * 8); + HttpAddInt16AsHex(*(DS18B20Value + device) ); + HttpAddChar('\n'); + } + HttpAddChar('\f'); + + for (int rom = 0; rom < DS18B20RomCount; rom++) + { + addRomToHttp(DS18B20Roms + rom * 8); + HttpAddText(DS18B20RomNames[rom]); + HttpAddChar('\n'); + } +} +