mirror of
				https://github.com/manuelbl/ttn-esp32.git
				synced 2025-10-31 10:40:35 +01:00 
			
		
		
		
	Power off for C++
This commit is contained in:
		| @ -619,6 +619,32 @@ class TheThingsNetwork | ||||
|         return ttn_resume_after_deep_sleep(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @brief Resumes TTN communication after power off. | ||||
|      *  | ||||
|      * The communcation state is restored from data previously saved in NVS (non-volatile storage). | ||||
|      * The RF module and the TTN background task are started. | ||||
|      *  | ||||
|      * This function is called instead of @ref join() or @ref join(const char*, const char*, const char*) | ||||
|      * to continue with the established communication and to avoid a further join procedure. | ||||
|      *  | ||||
|      * In order to advance the clock, the estimated duration the device was powered off has to | ||||
|      * be specified. As the exact duration is probably not known, an estimation of the shortest | ||||
|      * duration between power-off and next power-on can be used instead. | ||||
|      *  | ||||
|      * If the device has access to the real time, set the system time (using `settimeofday()`) | ||||
|      * before calling this function (and before @ref join()) and pass 0 for `off_duration`. | ||||
|      *  | ||||
|      * Before this function is called, `nvs_flash_init()` must have been called once. | ||||
|      * | ||||
|      * @param off_duration duration the device was powered off (in minutes) | ||||
|      * @return `true` if the device was able to resume, `false` otherwise. | ||||
|      */ | ||||
|     bool resumeAfterPowerOff(int off_duration) | ||||
|     { | ||||
|         return ttn_resume_after_power_off(off_duration); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @brief Stops all activies and prepares for deep sleep. | ||||
|      *  | ||||
| @ -639,6 +665,28 @@ class TheThingsNetwork | ||||
|         ttn_prepare_for_deep_sleep(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @brief Stops all activies and prepares for power off. | ||||
|      *  | ||||
|      * This function is called before powering off the device. It saves the current | ||||
|      * communication state in NVS (non-volatile storage) and shuts down the RF module | ||||
|      * and the TTN background task. | ||||
|      *  | ||||
|      * It neither clears the provisioned keys nor the configured pins | ||||
|      * but they will be lost if the device is powered off. | ||||
|      *  | ||||
|      * Before calling this function, use @ref ttn_busy_duration() to check | ||||
|      * that the TTN device is idle and ready to be powered off. | ||||
|      * | ||||
|      * To restart communication, @ref resumeAfterPowerOff(int) must be called. | ||||
|      *  | ||||
|      * Before this function is called, `nvs_flash_init()` must have been called once. | ||||
|      */ | ||||
|     void prepareForPowerOff() | ||||
|     { | ||||
|         ttn_prepare_for_power_off(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @brief Waits until the TTN device is idle. | ||||
|      *  | ||||
|  | ||||
| @ -598,7 +598,7 @@ extern "C" | ||||
|      *  | ||||
|      * In order to advance the clock, the estimated duration the device was powered off has to | ||||
|      * be specified. As the exact duration is probably not known, an estimation of the shortest | ||||
|      * duration between power off and on can be used instead. | ||||
|      * duration between power-off and next power-on can be used instead. | ||||
|      *  | ||||
|      * If the device has access to the real time, set the system time (using `settimeofday()`) | ||||
|      * before calling this function (and before @ref join()) and pass 0 for `off_duration`. | ||||
|  | ||||
		Reference in New Issue
	
	Block a user