Manages the 1-wire bus

Dependents:   oldheating heating

web/web-1wire-ajax.c

Committer:
andrewboyson
Date:
2019-04-27
Revision:
2:79cad6a51fd0
Child:
4:822208cb5a13

File content as of revision 2:79cad6a51fd0:

#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');
    }
}