Skip to content

Rainmaker: Added enableSystemService API #7875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2023
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 docs/source/api/espnow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ Examples
ESP-NOW Master
**************

.. literalinclude:: ../../../libraries/ESP32/examples/ESPNow/Basic/Master/Master.ino
.. literalinclude:: ../../../libraries/ESP32/examples/ESPNow/ESPNow_Basic_Master/ESPNow_Basic_Master.ino
:language: arduino

ESP-NOW Slave
*************

.. literalinclude:: ../../../libraries/ESP32/examples/ESPNow/Basic/Slave/Slave.ino
.. literalinclude:: ../../../libraries/ESP32/examples/ESPNow/ESPNow_Basic_Slave/ESPNow_Basic_Slave.ino
:language: arduino

Resources
Expand Down
20 changes: 20 additions & 0 deletions docs/source/api/rainmaker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,26 @@ This function will return
1. `ESP_OK` : On success
2. Error in case of failure

RMaker.enableSystemService
**************************

This API enables the System service for the node. It should be called after `RMaker.initNode()` and before `RMaker.start()`.
For more information, check `here <https://rainmaker.espressif.com/docs/sys-service.html>`__.

.. code-block:: arduino

esp_err_t enableSystemService(uint16_t flags, int8_t reboot_seconds, int8_t reset_seconds, int8_t reset_reboot_seconds)

* ``flags`` : Logical OR of system service flags (SYSTEM_SERV_FLAG_REBOOT, SYSTEM_SERV_FLAG_FACTORY_RESET, SYSTEM_SERV_FLAG_WIFI_RESET) as required or SYSTEM_SERV_FLAGS_ALL.
* ``reboot_seconds`` Time in seconds after which the device should reboot. Recommended value: 2
* ``reset_seconds`` Time in seconds after which the device should reset(Wi-Fi or Factory). Recommended value: 2
* ``reset_reboot_seconds`` Time in seconds after which the device should reboot after it has been reset. Zero as a value would mean there won't be any reboot after the reset. Recommended value: 2

This function will return

1. `ESP_OK` : On success
2. Error in case of failure

RMaker.setTimeZone
******************

Expand Down
2 changes: 2 additions & 0 deletions libraries/RainMaker/examples/RMakerSwitch/RMakerSwitch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ void setup()

RMaker.enableScenes();

RMaker.enableSystemService(SYSTEM_SERV_FLAGS_ALL, 2, 2, 2);

RMaker.start();

WiFi.onEvent(sysProvEvent);
Expand Down
13 changes: 13 additions & 0 deletions libraries/RainMaker/src/RMaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,18 @@ esp_err_t RMakerClass::enableScenes()
}
return err;
}

esp_err_t RMakerClass::enableSystemService(uint16_t flags, int8_t reboot_seconds, int8_t reset_seconds, int8_t reset_reboot_seconds)
{
esp_rmaker_system_serv_config_t config = {
.flags = flags,
.reboot_seconds = reboot_seconds,
.reset_seconds = reset_seconds,
.reset_reboot_seconds = reset_reboot_seconds
};
err = esp_rmaker_system_service_enable(&config);
return err;
}

RMakerClass RMaker;
#endif
1 change: 1 addition & 0 deletions libraries/RainMaker/src/RMaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class RMakerClass
esp_err_t enableTZService();
esp_err_t enableOTA(ota_type_t type, const char *cert = ESP_RMAKER_OTA_DEFAULT_SERVER_CERT);
esp_err_t enableScenes();
esp_err_t enableSystemService(uint16_t flags, int8_t reboot_seconds = 2, int8_t reset_seconds = 2, int8_t reset_reboot_seconds = 2);
esp_err_t start();
esp_err_t stop();
};
Expand Down