From 76d50ec5176bc1755184f20e5f6a5c7cd1cf81bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Procha=CC=81zka?= <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Wed, 16 Mar 2022 13:47:21 +0100 Subject: [PATCH] CmakeList + Rainmaker src files edit --- CMakeLists.txt | 2 +- libraries/RainMaker/src/RMaker.cpp | 7 ++++--- libraries/RainMaker/src/RMaker.h | 21 ++++++++++++++++---- libraries/RainMaker/src/RMakerDevice.cpp | 6 +++--- libraries/RainMaker/src/RMakerDevice.h | 19 +++++++++++++++--- libraries/RainMaker/src/RMakerNode.cpp | 5 +++-- libraries/RainMaker/src/RMakerNode.h | 19 +++++++++++++++--- libraries/RainMaker/src/RMakerParam.cpp | 4 ++-- libraries/RainMaker/src/RMakerParam.h | 19 +++++++++++++++--- libraries/RainMaker/src/RMakerQR.h | 21 ++++++++++++++++---- libraries/RainMaker/src/RMakerType.cpp | 4 ++-- libraries/RainMaker/src/RMakerType.h | 19 +++++++++++++++--- libraries/RainMaker/src/RMakerUtils.h | 25 ++++++++++++++++++------ 13 files changed, 132 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 629ac58345d..42e75f6d5f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,7 +237,7 @@ endfunction() maybe_add_component(esp-dsp) -if(IDF_TARGET MATCHES "esp32" AND CONFIG_ESP_RMAKER_TASK_STACK) +if(CONFIG_ESP_RMAKER_TASK_STACK) maybe_add_component(esp_rainmaker) maybe_add_component(qrcode) endif() diff --git a/libraries/RainMaker/src/RMaker.cpp b/libraries/RainMaker/src/RMaker.cpp index de6903c0538..4e6afe3586d 100644 --- a/libraries/RainMaker/src/RMaker.cpp +++ b/libraries/RainMaker/src/RMaker.cpp @@ -1,11 +1,12 @@ +#include "sdkconfig.h" +#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK #include "RMaker.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 #include #include bool wifiLowLevelInit(bool persistent); static esp_err_t err; -static void event_handler(void *arg, esp_event_base_t event_base, int event_id, void *event_data) +static void event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) { if (event_base == RMAKER_EVENT) { switch (event_id) { @@ -113,4 +114,4 @@ esp_err_t RMakerClass::enableOTA(ota_type_t type, const char *cert) } RMakerClass RMaker; -#endif +#endif \ No newline at end of file diff --git a/libraries/RainMaker/src/RMaker.h b/libraries/RainMaker/src/RMaker.h index 53c60bce189..dbfbe5c49f5 100644 --- a/libraries/RainMaker/src/RMaker.h +++ b/libraries/RainMaker/src/RMaker.h @@ -1,6 +1,20 @@ +// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#pragma once +#include "sdkconfig.h" +#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK #include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 - #include "Arduino.h" #include "RMakerNode.h" #include "RMakerQR.h" @@ -26,5 +40,4 @@ class RMakerClass }; extern RMakerClass RMaker; - -#endif +#endif \ No newline at end of file diff --git a/libraries/RainMaker/src/RMakerDevice.cpp b/libraries/RainMaker/src/RMakerDevice.cpp index e0108c32963..303c5f09130 100644 --- a/libraries/RainMaker/src/RMakerDevice.cpp +++ b/libraries/RainMaker/src/RMakerDevice.cpp @@ -1,5 +1,6 @@ +#include "sdkconfig.h" +#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK #include "RMakerDevice.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 static esp_err_t err; typedef void (*deviceWriteCb)(Device*, Param*, const param_val_t val, void *priv_data, write_ctx_t *ctx); @@ -205,5 +206,4 @@ esp_err_t Device::updateAndReportParam(const char *param_name, const char *my_va } return ESP_OK; } - -#endif +#endif \ No newline at end of file diff --git a/libraries/RainMaker/src/RMakerDevice.h b/libraries/RainMaker/src/RMakerDevice.h index 13cb67ac302..f813359a25a 100644 --- a/libraries/RainMaker/src/RMakerDevice.h +++ b/libraries/RainMaker/src/RMakerDevice.h @@ -1,6 +1,20 @@ +// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#pragma once +#include "sdkconfig.h" +#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK #include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 - #include "RMakerParam.h" #include #include @@ -150,5 +164,4 @@ class TemperatureSensor : public Device } } }; - #endif \ No newline at end of file diff --git a/libraries/RainMaker/src/RMakerNode.cpp b/libraries/RainMaker/src/RMakerNode.cpp index 3f2555f8b05..5cae9e8dea9 100644 --- a/libraries/RainMaker/src/RMakerNode.cpp +++ b/libraries/RainMaker/src/RMakerNode.cpp @@ -1,5 +1,6 @@ +#include "sdkconfig.h" +#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK #include "RMakerNode.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 static esp_err_t err; esp_err_t Node::addDevice(Device device) @@ -38,4 +39,4 @@ esp_err_t Node::addNodeAttr(const char *attr_name, const char *val) } return err; } -#endif +#endif \ No newline at end of file diff --git a/libraries/RainMaker/src/RMakerNode.h b/libraries/RainMaker/src/RMakerNode.h index 733ca407f96..d169870f591 100644 --- a/libraries/RainMaker/src/RMakerNode.h +++ b/libraries/RainMaker/src/RMakerNode.h @@ -1,6 +1,20 @@ +// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#pragma once +#include "sdkconfig.h" +#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK #include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 - #include "RMakerDevice.h" class Node @@ -29,5 +43,4 @@ class Node node_info_t *getNodeInfo(); esp_err_t addNodeAttr(const char *attr_name, const char *val); }; - #endif \ No newline at end of file diff --git a/libraries/RainMaker/src/RMakerParam.cpp b/libraries/RainMaker/src/RMakerParam.cpp index e1de774017f..38a3cabceda 100644 --- a/libraries/RainMaker/src/RMakerParam.cpp +++ b/libraries/RainMaker/src/RMakerParam.cpp @@ -1,5 +1,6 @@ +#include "sdkconfig.h" +#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK #include "RMakerParam.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 static esp_err_t err; @@ -29,5 +30,4 @@ esp_err_t Param::updateAndReport(param_val_t val) } return err; } - #endif \ No newline at end of file diff --git a/libraries/RainMaker/src/RMakerParam.h b/libraries/RainMaker/src/RMakerParam.h index 0bd9aedb116..d1b4ea6d9d6 100644 --- a/libraries/RainMaker/src/RMakerParam.h +++ b/libraries/RainMaker/src/RMakerParam.h @@ -1,6 +1,20 @@ +// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#pragma once +#include "sdkconfig.h" +#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK #include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 - #include "RMakerType.h" class Param @@ -34,5 +48,4 @@ class Param esp_err_t addBounds(param_val_t min, param_val_t max, param_val_t step); esp_err_t updateAndReport(param_val_t val); }; - #endif \ No newline at end of file diff --git a/libraries/RainMaker/src/RMakerQR.h b/libraries/RainMaker/src/RMakerQR.h index fd5053d0dde..7b666557fcd 100644 --- a/libraries/RainMaker/src/RMakerQR.h +++ b/libraries/RainMaker/src/RMakerQR.h @@ -1,6 +1,20 @@ +// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#pragma once +#include "sdkconfig.h" +#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK #include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 - #include #define PROV_QR_VERSION "v1" @@ -20,5 +34,4 @@ static void printQR(const char *name, const char *pop, const char *transport) qrcode_display(payload); Serial.printf("If QR code is not visible, copy paste the below URL in a browser.\n%s?data=%s\n", QRCODE_BASE_URL, payload); } - -#endif +#endif \ No newline at end of file diff --git a/libraries/RainMaker/src/RMakerType.cpp b/libraries/RainMaker/src/RMakerType.cpp index a4f6f2f381f..d94337cec4c 100644 --- a/libraries/RainMaker/src/RMakerType.cpp +++ b/libraries/RainMaker/src/RMakerType.cpp @@ -1,5 +1,6 @@ +#include "sdkconfig.h" +#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK #include "RMakerType.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 param_val_t value(int ival) { @@ -20,5 +21,4 @@ param_val_t value(float fval) { return esp_rmaker_float(fval); } - #endif \ No newline at end of file diff --git a/libraries/RainMaker/src/RMakerType.h b/libraries/RainMaker/src/RMakerType.h index 09029f9e8a0..003bd32a523 100644 --- a/libraries/RainMaker/src/RMakerType.h +++ b/libraries/RainMaker/src/RMakerType.h @@ -1,6 +1,20 @@ +// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#pragma once +#include "sdkconfig.h" +#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK #include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 - #include #include #include @@ -19,5 +33,4 @@ param_val_t value(int); param_val_t value(bool); param_val_t value(char *); param_val_t value(float); - #endif \ No newline at end of file diff --git a/libraries/RainMaker/src/RMakerUtils.h b/libraries/RainMaker/src/RMakerUtils.h index 41745d2e027..710b0e9a8a4 100644 --- a/libraries/RainMaker/src/RMakerUtils.h +++ b/libraries/RainMaker/src/RMakerUtils.h @@ -1,16 +1,29 @@ +// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#pragma once +#include "sdkconfig.h" +#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK #include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32 - #include static void RMakerFactoryReset(int seconds) { - esp_rmaker_factory_reset(seconds); + esp_rmaker_factory_reset(0, seconds); } static void RMakerWiFiReset(int seconds) { - esp_rmaker_wifi_reset(seconds); + esp_rmaker_wifi_reset(0, seconds); } - -#endif +#endif \ No newline at end of file