MiraOS  1.26
mira_sleep.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (C) 2016 LumenRadio AB *
3  * *
4  * This file is part of MiraOS. *
5  * *
6  * MiraOS contains software components that are patented by LumenRadio. *
7  * Use of this software is under the terms of the LumenRadio MiraOS *
8  * license.
9  * *
10  * You should have received a copy of the MiraOS license from your *
11  * LumenRadio representative. If not, email to <licenses@lumenradio.com> *
12  ****************************************************************************/
13 
25 #ifndef LIBMIRA_SLEEP_H_
26 #define LIBMIRA_SLEEP_H_
27 
28 #include "sys/process.h"
29 
35 extern process_event_t mira_wake_up_event;
36 
46 void mira_prepare_sleep(uint16_t sleep_time);
47 
55 void mira_restore_from_sleep(void);
56 
67 #define mira_deep_sleep(sleep_time) \
68  { \
69  mira_prepare_sleep(sleep_time); \
70  PROCESS_WAIT_EVENT_UNTIL(ev == mira_wake_up_event); \
71  mira_restore_from_sleep(); \
72  }
73 
82 void mira_wake_up_process(void);
83 
84 
94 void mira_sleepy_node_poll_for_fw(uint16_t firmware_image_id);
95 
103 uint8_t mira_sleepy_node_poll_done(void);
104 
113 #define mira_sleepy_node_poll_firmware(firmware_image_id) \
114  { \
115  mira_sleepy_node_poll_for_fw(firmware_image_id); \
116  PROCESS_WAIT_UNTIL(mira_sleepy_node_poll_done()); \
117  }
118 
119 
120 #endif /* LIBMIRA_SLEEP_H_ */
uint8_t mira_sleepy_node_poll_done(void)
Checks if firmware polling is done.
process_event_t mira_wake_up_event
Event that gets sent to wake up the sleeping thread.
void mira_wake_up_process(void)
Wake up the thread that went to deep sleep.
void mira_prepare_sleep(uint16_t sleep_time)
Prepare for sleep.
void mira_restore_from_sleep(void)
Restore from sleep.
void mira_sleepy_node_poll_for_fw(uint16_t firmware_image_id)
Polls neighbors for new firmware.