Skip to content

Commit

Permalink
Updated PCB, sensprs as JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
klaus-liebler committed Oct 11, 2024
1 parent 133f53f commit 25d378d
Show file tree
Hide file tree
Showing 8 changed files with 27,139 additions and 28,519 deletions.
3 changes: 3 additions & 0 deletions espidf-component-labathome/cpp/HAL.hh
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,7 @@ class HAL
virtual ErrorCode GetAirRelHumidityAHT21(float *percent)=0;
virtual ErrorCode GetAirRelHumidityBME280(float *percent)=0;
virtual ErrorCode GetDistanceMillimeters(uint16_t *value)=0;

virtual ErrorCode GetSensorsAsJSON(char* buffer, size_t maxLen)=0;

};
5 changes: 5 additions & 0 deletions espidf-component-labathome/cpp/HAL_labathomeV15.hh
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,11 @@ public:
return ErrorCode::OK;
}

ErrorCode GetSensorsAsJSON(char* buffer, size_t maxLen) override{
this->oneWireBus->FormatJSON(buffer, maxLen);
return ErrorCode::OK;
}

ErrorCode GetEncoderValue(int *value)
{
*value = this->stm2esp_buf.Rotenc;
Expand Down
2 changes: 1 addition & 1 deletion labathome_firmware/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"C_Cpp.intelliSenseEngine": "default",
"idf.flashType": "UART",
"idf.portWin": "COM23",
"idf.portWin": "COM28",
"idf.adapterTargetName": "esp32s3",
"idf.openOcdConfigs": [
"board/esp32s3-builtin.cfg"
Expand Down
15 changes: 15 additions & 0 deletions labathome_firmware/main/http_handlers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,13 @@ esp_err_t handle_put_heaterexperiment(httpd_req_t *req)
return ESP_OK;
}

esp_err_t handle_get_sensors(httpd_req_t *req){
DeviceManager *devicemanager = *static_cast<DeviceManager **>(req->user_ctx);
char *buf= static_cast<char*>(httpd_get_global_user_ctx(req->handle));
devicemanager->GetHAL()->GetSensorsAsJSON(buf, CONFIG_SMOPLA_HTTP_SCRATCHPAD_SIZE);
return ESP_OK;
}

esp_err_t handle_put_airspeedexperiment(httpd_req_t *req){
DeviceManager *devicemanager = *static_cast<DeviceManager **>(req->user_ctx);
int ret=0;
Expand Down Expand Up @@ -617,6 +624,13 @@ constexpr httpd_uri_t putptnexperiment = {
.user_ctx = &devicemanager,
};

constexpr httpd_uri_t getsensors = {
.uri = "/sensors",
.method = HTTP_GET,
.handler = handle_get_sensors,
.user_ctx = &devicemanager,
};


void RegisterHandlers(){
ESP_ERROR_CHECK(httpd_register_uri_handler(http_server, &getroot));
Expand All @@ -631,4 +645,5 @@ void RegisterHandlers(){
ESP_ERROR_CHECK(httpd_register_uri_handler(http_server, &postfbddefaultbin));
ESP_ERROR_CHECK(httpd_register_uri_handler(http_server, &postfbddefaultjson));
ESP_ERROR_CHECK(httpd_register_uri_handler(http_server, &putptnexperiment));
ESP_ERROR_CHECK(httpd_register_uri_handler(http_server, &getsensors));
}
Loading

0 comments on commit 25d378d

Please sign in to comment.