Skip to content

Commit

Permalink
Rainmaker: Added enableSystemService API
Browse files Browse the repository at this point in the history
  • Loading branch information
sanketwadekar committed Feb 21, 2023
1 parent 0d84018 commit c5fecb0
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
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. Value of zero would mean that 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

0 comments on commit c5fecb0

Please sign in to comment.