7
7
/**
8
8
* @file sb_fota_os.h
9
9
*
10
- * @defgroup sb_fota_os Softbank modem FOTA OS layer
10
+ * @defgroup sb_fota_os Softbank FOTA OS layer
11
11
* @{
12
12
*/
13
13
14
- #ifndef MODEM_FOTA_OS_H_
15
- #define MODEM_FOTA_OS_H_
14
+ #ifndef SB_FOTA_OS_H_
15
+ #define SB_FOTA_OS_H_
16
16
17
17
#include <stddef.h>
18
18
#include <stdint.h>
22
22
/**
23
23
* @brief Allocate memory.
24
24
*/
25
- void * modem_fota_os_malloc (size_t size );
25
+ void * sb_fota_os_malloc (size_t size );
26
26
27
27
/**
28
28
* @brief Allocate memory and zero it.
29
29
*/
30
- void * modem_fota_os_calloc (size_t nmemb , size_t size );
30
+ void * sb_fota_os_calloc (size_t nmemb , size_t size );
31
31
32
32
/**
33
33
* @brief Free memory.
34
34
*/
35
- void modem_fota_os_free (void * ptr );
35
+ void sb_fota_os_free (void * ptr );
36
36
37
37
/**
38
38
* @brief Get uptime, in milliseconds.
39
39
*/
40
- int64_t modem_fota_os_uptime_get (void );
40
+ int64_t sb_fota_os_uptime_get (void );
41
41
42
42
/**
43
43
* @brief Get uptime, in milliseconds.
44
44
*/
45
- uint32_t modem_fota_os_uptime_get_32 (void );
45
+ uint32_t sb_fota_os_uptime_get_32 (void );
46
46
47
47
/**
48
48
* @brief Put a thread to a sleep.
49
49
*/
50
- int modem_fota_os_sleep (int ms );
50
+ int sb_fota_os_sleep (int ms );
51
51
52
52
/**
53
53
* @brief Reboot system.
54
54
*/
55
- void modem_fota_os_sys_reset (void );
55
+ void sb_fota_os_sys_reset (void );
56
56
57
57
/**
58
58
* @brief Get a random value.
59
59
*/
60
- uint32_t modem_fota_os_rand_get (void );
60
+ uint32_t sb_fota_os_rand_get (void );
61
61
62
- #define MODEM_FOTA_N_SEMAPHORES 4
62
+ #define SB_FOTA_OS_SEMAPHORE_COUNT 4
63
63
64
64
/** Opaque type for OS semaphore */
65
- struct modem_fota_sem ;
65
+ struct sb_fota_os_sem ;
66
66
67
67
/**
68
68
* @brief Allocate a semaphore from OS
69
69
*
70
70
* @return pointer to allocated semaphore or NULL on failure.
71
71
*/
72
- struct modem_fota_sem * modem_fota_sem_alloc ( );
72
+ struct sb_fota_os_sem * sb_fota_os_sem_alloc ( void );
73
73
74
74
/**
75
75
* @brief Give a semaphore.
76
76
*
77
77
* @param sem pointer to a taken semaphore.
78
78
*/
79
- void modem_fota_sem_give (struct modem_fota_sem * sem );
79
+ void sb_fota_os_sem_give (struct sb_fota_os_sem * sem );
80
80
81
81
/**
82
82
* @brief Take a semaphore.
@@ -85,102 +85,97 @@ void modem_fota_sem_give(struct modem_fota_sem *sem);
85
85
* @param timeout_ms timeout in milliseconds, or negative if call can block forever.
86
86
* @return zero on success or negative error code on failure.
87
87
*/
88
- int modem_fota_sem_take (struct modem_fota_sem * sem , int timeout_ms );
88
+ int sb_fota_os_sem_take (struct sb_fota_os_sem * sem , int timeout_ms );
89
89
90
90
/**
91
91
* @brief Reset semaphore count to zero.
92
92
*
93
93
* @param sem pointer to a semaphore.
94
94
*/
95
- void modem_fota_sem_reset (struct modem_fota_sem * sem );
95
+ void sb_fota_os_sem_reset (struct sb_fota_os_sem * sem );
96
96
97
+ #define SB_FOTA_OS_WORK_COUNT 6
98
+ #define SB_FOTA_OS_DELAYED_WORK_COUNT 1
97
99
98
- #define MODEM_FOTA_N_EVENTS 6
99
- #define MODEM_FOTA_N_DELAYED_EVENTS 1
100
+ /** Generic work callback type */
101
+ typedef void ( * sb_fota_os_work_cb )( void * );
100
102
101
- /** Generic event callback type */
102
- typedef void ( * modem_fota_event_callback )( void * ) ;
103
+ /** Opaque work type */
104
+ struct sb_fota_os_work ;
103
105
104
- /** Opaque event type */
105
- struct modem_fota_event ;
106
+ /** Opaque delayed work type */
107
+ struct sb_fota_os_delayed_work ;
106
108
107
- /** Opaque delayed event type */
108
- struct modem_fota_delayed_event ;
109
+ struct sb_fota_os_work * sb_fota_os_work_init (sb_fota_os_work_cb cb );
110
+ void sb_fota_os_work_schedule (struct sb_fota_os_work * work );
111
+ struct sb_fota_os_delayed_work * sb_fota_os_delayed_work_init (sb_fota_os_work_cb cb );
112
+ void sb_fota_os_delayed_work_schedule (struct sb_fota_os_delayed_work * work , int delay_ms );
109
113
110
- struct modem_fota_event * modem_fota_event_init (modem_fota_event_callback cb );
111
- void modem_fota_event_send (struct modem_fota_event * evt );
112
- struct modem_fota_delayed_event * modem_fota_delayed_event_init (modem_fota_event_callback cb );
113
- void modem_fota_delayed_event_send (struct modem_fota_delayed_event * evt , int delay_ms );
114
-
115
- #define MODEM_FOTA_N_TIMERS 2
114
+ #define SB_FOTA_OS_TIMERS 2
116
115
117
116
/** Opaque timer type */
118
- struct modem_fota_timer ;
119
-
120
- struct modem_fota_timer * modem_fota_timer_init (modem_fota_event_callback cb );
121
- void modem_fota_timer_start (struct modem_fota_timer * timer , uint64_t delay_ms );
122
- void modem_fota_timer_stop (struct modem_fota_timer * timer );
123
- bool modem_fota_timer_is_running (struct modem_fota_timer * timer );
117
+ struct sb_fota_os_timer ;
124
118
125
- int64_t modem_fota_timegm64 (const struct tm * time );
119
+ struct sb_fota_os_timer * sb_fota_os_timer_init (sb_fota_os_work_cb cb );
120
+ void sb_fota_os_timer_start (struct sb_fota_os_timer * timer , uint64_t delay_ms );
121
+ void sb_fota_os_timer_stop (struct sb_fota_os_timer * timer );
122
+ bool sb_fota_os_timer_is_running (struct sb_fota_os_timer * timer );
126
123
124
+ int64_t sb_fota_os_timegm64 (const struct tm * time );
127
125
128
126
#define FOTA_LOG_LEVEL_NONE 0U
129
127
#define FOTA_LOG_LEVEL_ERR 1U
130
128
#define FOTA_LOG_LEVEL_WRN 2U
131
129
#define FOTA_LOG_LEVEL_INF 3U
132
130
#define FOTA_LOG_LEVEL_DBG 4U
133
131
134
- void modem_fota_log (int level , const char * fmt , ...);
135
- const char * modem_fota_log_strdup (const char * str );
136
- void modem_fota_logdump (const char * str , const void * data , size_t len );
137
-
138
- #define FOTA_LOG_ERR (...) modem_fota_log(FOTA_LOG_LEVEL_ERR, __VA_ARGS__);
139
- #define FOTA_LOG_WRN (...) modem_fota_log(FOTA_LOG_LEVEL_WRN, __VA_ARGS__);
140
- #define FOTA_LOG_INF (...) modem_fota_log(FOTA_LOG_LEVEL_INF, __VA_ARGS__);
141
- #define FOTA_LOG_DBG (...) modem_fota_log(FOTA_LOG_LEVEL_DBG, __VA_ARGS__);
132
+ void sb_fota_os_log (int level , const char * fmt , ...);
133
+ const char * sb_fota_os_log_strdup (const char * str );
142
134
135
+ #define FOTA_LOG_ERR (...) sb_fota_os_log(FOTA_LOG_LEVEL_ERR, __VA_ARGS__);
136
+ #define FOTA_LOG_WRN (...) sb_fota_os_log(FOTA_LOG_LEVEL_WRN, __VA_ARGS__);
137
+ #define FOTA_LOG_INF (...) sb_fota_os_log(FOTA_LOG_LEVEL_INF, __VA_ARGS__);
138
+ #define FOTA_LOG_DBG (...) sb_fota_os_log(FOTA_LOG_LEVEL_DBG, __VA_ARGS__);
143
139
144
- #define MODEM_FOTA_SETTINGS_PREFIX "modem_fota "
140
+ #define SB_FOTA_SETTINGS_PREFIX "sb_fota "
145
141
146
142
/** Structure used to load settings from persistent storage */
147
- struct modem_fota_settings {
148
- const char * name ; /** Name of the setting */
149
- size_t len ; /** Size of data, or zero for variable lenght data like strings */
150
- void * ptr ; /** Pointer to runtime storage.
151
- Strings are allocated and ptr stored here. */
143
+ struct sb_fota_settings {
144
+ const char * name ; /** Name of the setting */
145
+ size_t len ; /** Size of data, or zero for variable lenght data like strings */
146
+ void * ptr ; /** Pointer to runtime storage. Strings are allocated and ptr stored here. */
152
147
};
153
148
154
149
/** Load array of settings from persistent storage.
155
150
* Settings should be given as an array that ends with element where name is NULL.
156
151
*/
157
- void modem_fota_load_settings (const struct modem_fota_settings * settings );
152
+ void sb_fota_os_load_settings (const struct sb_fota_settings * settings );
158
153
159
154
/** Store one settings value.
160
- * MODEM_FOTA_SETTINGS_PREFIX is automatically added to the name.
155
+ * SB_FOTA_SETTINGS_PREFIX is automatically added to the name.
161
156
*/
162
- void modem_fota_store_setting (const char * name , size_t len , const void * ptr );
157
+ void sb_fota_os_store_setting (const char * name , size_t len , const void * ptr );
163
158
164
159
/** Apply modem FW update */
165
- void sb_fota_apply_update (void );
160
+ void sb_fota_os_update_apply (void );
166
161
167
162
/** @} */
168
163
169
164
#ifdef UNITTESTING
170
165
/* For unittesting purposes, I need dummy types of every opaque struct */
171
- struct modem_fota_sem
166
+ struct sb_fota_os_sem
172
167
{
173
168
int val ;
174
169
};
175
- struct modem_fota_event
170
+ struct sb_fota_os_work
176
171
{
177
172
int val ;
178
173
};
179
- struct modem_fota_delayed_event
174
+ struct sb_fota_os_delayed_work
180
175
{
181
176
int val ;
182
177
};
183
- struct modem_fota_timer
178
+ struct sb_fota_os_timer
184
179
{
185
180
int val ;
186
181
};
@@ -203,8 +198,8 @@ int get_lte_mode(void);
203
198
bool get_lte_active_status (void );
204
199
bool get_rrc_idle_status (void );
205
200
int get_reg_status (void );
206
- struct modem_fota_timer * get_active_timer (void );
207
- struct modem_fota_event * get_event (void );
201
+ struct sb_fota_os_timer * get_active_timer (void );
202
+ struct sb_fota_os_work * get_work (void );
208
203
#endif
209
204
210
- #endif /* MODEM_FOTA_OS_H_ */
205
+ #endif /* SB_FOTA_OS_H_ */
0 commit comments