mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
system_api: return error on repeated registration of shutdown handler
This commit is contained in:
parent
bd309a133f
commit
b1a722b2ca
@ -211,14 +211,15 @@ esp_err_t esp_read_mac(uint8_t* mac, esp_mac_type_t type)
|
||||
|
||||
esp_err_t esp_register_shutdown_handler(shutdown_handler_t handler)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < SHUTDOWN_HANDLERS_NO; i++) {
|
||||
if (shutdown_handlers[i] == NULL) {
|
||||
for (int i = 0; i < SHUTDOWN_HANDLERS_NO; i++) {
|
||||
if (shutdown_handlers[i] == handler) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
} else if (shutdown_handlers[i] == NULL) {
|
||||
shutdown_handlers[i] = handler;
|
||||
return ESP_OK;
|
||||
}
|
||||
}
|
||||
return ESP_FAIL;
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
esp_err_t esp_unregister_shutdown_handler(shutdown_handler_t handler)
|
||||
|
@ -80,6 +80,11 @@ typedef void (*shutdown_handler_t)(void);
|
||||
*
|
||||
* This function allows you to register a handler that gets invoked before
|
||||
* the application is restarted using esp_restart function.
|
||||
* @param handle function to execute on restart
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if the handler has already been registered
|
||||
* - ESP_ERR_NO_MEM if no more shutdown handler slots are available
|
||||
*/
|
||||
esp_err_t esp_register_shutdown_handler(shutdown_handler_t handle);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user