Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
build2:
name: Build Simulator
needs: refs
runs-on: windows-latest
runs-on: windows-2022

steps:
- name: Checkout repository
Expand Down Expand Up @@ -620,4 +620,4 @@ jobs:
echo ${{ steps.semantic.outputs.new_release_version }}
echo ${{ steps.semantic.outputs.new_release_major_version }}
echo ${{ steps.semantic.outputs.new_release_minor_version }}
echo ${{ steps.semantic.outputs.new_release_patch_version }}
echo ${{ steps.semantic.outputs.new_release_patch_version }}
35 changes: 35 additions & 0 deletions src/driver/drv_ds1820_full.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,41 @@ void DS1820_full_driver_Init()

};


/*
printer(request, "\"DS1820\":");
// following check will clear NaN values
printer(request, "{");
printer(request, "\"Temperature\": %.1f,", chan_val1);
// close ENERGY block
printer(request, "},");

*/

static char *jsonSensor_reststr = NULL;
char *DS1820_full_jsonSensors(){
if (ds18_count <= 0 ) return NULL;
if (jsonSensor_reststr!=NULL) free(jsonSensor_reststr);
// {"DS1820_<name>":{"Temperature": <temp>},
// {"DS1820_<name - DS18B20namel>":{"Temperature": <temp -127,00>},
// 123456789 123456789012345678 1234567890
// length of str: 10 + DS18B20namel + 18 + 10 --> 40 + DS18B20namel

int size = (40 + DS18B20namel) * ds18_count;
char *str = (char *)malloc(size * sizeof(char));
if (str == NULL) {
return NULL; // string allocation failed
}
str[0] = 0;
for (int i=0; i < ds18_count; i++) {
char tmp[50 + DS18B20namel];
sprintf(tmp, "\"DS1820_%s\":{\"Temperature\": %.1f},",ds18b20devices.name[i],ds18b20devices.lasttemp[i]);
strncat(str, tmp, size - strlen(str) - 1); // Concatenate to the main string
}
jsonSensor_reststr = str;
return jsonSensor_reststr;
}

void DS1820_full_AppendInformationToHTTPIndexPage(http_request_t* request, int bPreState)
{
if (bPreState){
Expand Down
2 changes: 1 addition & 1 deletion src/driver/drv_ds1820_full.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ float ds18b20_getTempC(const uint8_t *deviceAddress);
bool isConversionComplete();
void reset_search();
bool search(uint8_t *newAddr, bool search_mode, int Pin);

char *DS1820_full_jsonSensors();
2 changes: 1 addition & 1 deletion src/driver/drv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ bool DRV_IsMeasuringBattery() {

bool DRV_IsSensor() {
#ifndef OBK_DISABLE_ALL_DRIVERS
return DRV_IsRunning("SHT3X") || DRV_IsRunning("CHT83XX") || DRV_IsRunning("SGP") || DRV_IsRunning("AHT2X");
return DRV_IsRunning("SHT3X") || DRV_IsRunning("CHT83XX") || DRV_IsRunning("SGP") || DRV_IsRunning("AHT2X") || DRV_IsRunning("DS1820") || DRV_IsRunning("DS1820_full");
#else
return false;
#endif
Expand Down
34 changes: 34 additions & 0 deletions src/httpserver/json_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include "../driver/drv_ntp.h"
#include "../driver/drv_local.h"
#include "../driver/drv_bl_shared.h"
#include "../driver/drv_ds1820_simple.h"
#include "../driver/drv_ds1820_full.h"


#if ENABLE_TASMOTA_JSON

Expand Down Expand Up @@ -278,6 +281,36 @@ static int http_tasmota_json_SENSOR(void* request, jsonCb_t printer) {
// close ENERGY block
printer(request, "},");
}
#if (ENABLE_DRIVER_DS1820)
if (DRV_IsRunning("DS1820")) { //DS1820_simple.c with one sensor
g_pin_1 = PIN_FindPinIndexForRole(IOR_DS1820_IO, g_pin_1);
channel_1 = g_cfg.pins.channels[g_pin_1];
chan_val1 = CHANNEL_GetFloat(channel_1) / 100.0f;

// writer header
printer(request, "\"DS1820\":");
// following check will clear NaN values
printer(request, "{");
printer(request, "\"Temperature\": %.1f", chan_val1);
// close ENERGY block
printer(request, "},");
}
#endif
#if (ENABLE_DRIVER_DS1820_FULL)
if (DRV_IsRunning("DS1820_full")) { //DS1820_full.c with possibly multiple sensors
char *str = DS1820_full_jsonSensors();
int toprint = strlen(str);
while (*str && toprint > 250) { // string can be long, longer than request, this would break output if not split
char t = str[250];
str[250]=0;
printer(request, str);
str[250]=t;
str+=250;
toprint -= 250;
}
printer(request, str);
}
#endif
if (DRV_IsRunning("CHT83XX")) {
g_pin_1 = PIN_FindPinIndexForRole(IOR_CHT83XX_DAT, g_pin_1);
channel_1 = g_cfg.pins.channels[g_pin_1];
Expand All @@ -295,6 +328,7 @@ static int http_tasmota_json_SENSOR(void* request, jsonCb_t printer) {
// close ENERGY block
printer(request, "},");
}

for (int i = 0; i < PLATFORM_GPIO_MAX; i++) {
int role = PIN_GetPinRoleForPinIndex(i);
if (role != IOR_DHT11 && role != IOR_DHT12 && role != IOR_DHT21 && role != IOR_DHT22)
Expand Down
Loading