Andrew Boyson / motorhome

Dependencies:   net lpc1768 crypto clock web fram log

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers web-battery-ajax.c Source File

web-battery-ajax.c

00001 #include  <stdint.h>
00002 #include   <stdio.h>
00003 
00004 #include "http.h"
00005 #include "comms.h"
00006 
00007 void WebBatteryAjax()
00008 {
00009     HttpOk("text/plain; charset=UTF-8", "no-cache", NULL, NULL);
00010     
00011     HttpAddInt32AsHex(BatteryGetCountedCapacity());
00012     HttpAddChar('\n');
00013     
00014     HttpAddByteAsHex(BatteryGetCountedError());
00015     HttpAddChar('\n');
00016     
00017     HttpAddInt32AsHex(BatteryGetCurrentMa());
00018     HttpAddChar('\n');
00019     
00020     HttpAddByteAsHex(BatteryGetCapacitySetPointPercent());
00021     HttpAddChar('\n');
00022     
00023     HttpAddChar(BatteryGetOutputState());
00024     HttpAddChar('\n');
00025     
00026     int nibble = 0;
00027     if (BatteryGetChargeEnabled()   ) nibble |= 1;
00028     if (BatteryGetDischargeEnabled()) nibble |= 2;
00029     HttpAddNibbleAsHex (nibble);
00030     HttpAddChar('\n');
00031     
00032     HttpAddInt16AsHex(BatteryGetTemperatureTenths());
00033     HttpAddChar('\n');
00034     
00035     HttpAddInt16AsHex(BatteryGetTemperatureSetPoint());
00036     HttpAddChar('\n');
00037     
00038     HttpAddByteAsHex(BatteryGetHeaterOutputPercent());
00039     HttpAddChar('\n');
00040     
00041     HttpAddInt16AsHex(BatteryGetVoltageMv());
00042     HttpAddChar('\n');
00043     
00044     HttpAddByteAsHex(BatteryGetMeasuredPercent());
00045     HttpAddChar('\n');
00046     
00047     HttpAddByteAsHex(BatteryGetMeasuredError());
00048     HttpAddChar('\n');
00049     
00050     HttpAddByteAsHex(BatteryGetCapacityAutoUpdate());
00051     HttpAddChar('\n');
00052 }
00053