Skip to content

Commit 47c5175

Browse files
kacperradoszewskinordic-hani
authored andcommitted
lib: bin: sb_fota: update library
Updated the SB FOTA library along with its APIs and the sample. Signed-off-by: Kacper Radoszewski <kacper.radoszewski@nordicsemi.no>
1 parent aa07704 commit 47c5175

File tree

12 files changed

+159
-170
lines changed

12 files changed

+159
-170
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
.venv
88

99
# build
10-
/build*
10+
/sample/build*
1111
/twister-out*
1212

1313
__pycache__/

lib/bin/sb_fota/CHANGELOG.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _libmodem_fota_carrier_changelog:
1+
.. _libsb_fota_changelog:
22

33
Changelog
44
#########

lib/bin/sb_fota/CMakeLists.txt

-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
#
6-
if (NOT CONFIG_SB_FOTA_SRC)
7-
86
if(CONFIG_FPU)
97
if(CONFIG_FP_HARDABI)
108
set(float_dir hard-float)
@@ -20,7 +18,6 @@ endif()
2018
assert(GCC_M_CPU "GCC_M_CPU must be set to find correct lib.")
2119

2220
set(lib_path lib/${GCC_M_CPU}/${float_dir})
23-
2421
set(SB_FOTA_LIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${lib_path})
2522

2623
if(NOT EXISTS ${SB_FOTA_LIB_PATH})
@@ -38,5 +35,3 @@ zephyr_library_sources(
3835
os/sb_fota_os.c
3936
os/sb_fota_settings.c
4037
)
41-
42-
endif()

lib/bin/sb_fota/include/sb_fota.h

+12-21
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,30 @@ extern "C" {
2020
#endif
2121

2222
/**
23-
* @brief FOTA application events.
23+
* @brief SoftBank FOTA application events.
2424
*
2525
*/
2626
enum sb_fota_event {
2727
/** FOTA client starts networking.
2828
* Application should close all TLS sockets. Modem may change the operation mode
2929
* from NB-IOT to LTE-M, so any network activity is recommended to be paused.
3030
*/
31-
FOTA_EVENT_DOWNLOADING,
31+
SB_FOTA_EVENT_DOWNLOADING,
3232
/** FOTA client is now on idle.
3333
* Application may resume normal network operations.
3434
*/
35-
FOTA_EVENT_IDLE,
35+
SB_FOTA_EVENT_IDLE,
3636
/** Modem FW is going to be updated, so it is shut down.
3737
* Application cannot use the network anymore until firmware is updated and
3838
* device is booted.
3939
*/
40-
FOTA_EVENT_MODEM_SHUTDOWN,
40+
SB_FOTA_EVENT_MODEM_SHUTDOWN,
4141
/** Modem FW is now updated, reboot the device to resume network operations. */
42-
FOTA_EVENT_REBOOT_PENDING,
42+
SB_FOTA_EVENT_REBOOT_PENDING,
4343
};
4444

4545
/**
46-
* @brief Modem FOTA application callback function.
46+
* @brief SoftBank FOTA application callback function.
4747
*
4848
* See also @ref sb_fota_event
4949
*
@@ -52,7 +52,7 @@ enum sb_fota_event {
5252
typedef void (*sb_fota_callback_t)(enum sb_fota_event event);
5353

5454
/**
55-
* @brief Initializes the modem FOTA client.
55+
* @brief Initializes the SoftBank FOTA client.
5656
*
5757
* Initializes the library and registers a callback for FOTA process.
5858
* Subsequent calls may be used to change the callback function.
@@ -61,7 +61,7 @@ typedef void (*sb_fota_callback_t)(enum sb_fota_event event);
6161
* function, but might still want to use it for registering the callback.
6262
*
6363
* If there is no callback set, then the library automatically reboots the device in case of
64-
* FOTA_EVENT_REBOOT_PENDING event.
64+
* SB_FOTA_EVENT_REBOOT_PENDING event.
6565
*
6666
* @param callback Callback for the application events or NULL for no callback.
6767
*
@@ -71,11 +71,11 @@ typedef void (*sb_fota_callback_t)(enum sb_fota_event event);
7171
int sb_fota_init(sb_fota_callback_t callback);
7272

7373
/**
74-
* @brief Sets current time for the modem FOTA client and modem clock.
74+
* @brief Sets current time for the SoftBank FOTA client and modem clock.
7575
*
76-
* Sets the current time used by the modem FOTA client. The given time is also
76+
* Sets the current time used by the SoftBank FOTA client. The given time is also
7777
* set to the modem. If LTE network time is not available, current time has
78-
* to be provided to the modem FOTA client using this function.
78+
* to be provided to the SoftBank FOTA client using this function.
7979
*
8080
* LTE network time overrides the time set using this function. If time is
8181
* available from the LTE network, time doesn't have to be set using this
@@ -91,16 +91,7 @@ int sb_fota_init(sb_fota_callback_t callback);
9191
* @retval 0 If the operation was successful.
9292
* Otherwise, a (negative) error code is returned.
9393
*/
94-
int sb_fota_set_clock(const char *time_str);
95-
96-
/**
97-
* @brief Set client identifier for FOTA library.
98-
*
99-
* If not set, default IMEI or UUID is used depending on the Kconfig option.
100-
*
101-
* @param id Client identifier string, maximum NRF_DEVICE_UUID_STR_LEN characters.
102-
*/
103-
void sb_fota_set_client_id(const char *id);
94+
int sb_fota_clock_set(const char *time_str);
10495

10596
#ifdef __cplusplus
10697
}

lib/bin/sb_fota/include/sb_fota_os.h

+58-63
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
/**
88
* @file sb_fota_os.h
99
*
10-
* @defgroup sb_fota_os Softbank modem FOTA OS layer
10+
* @defgroup sb_fota_os Softbank FOTA OS layer
1111
* @{
1212
*/
1313

14-
#ifndef MODEM_FOTA_OS_H_
15-
#define MODEM_FOTA_OS_H_
14+
#ifndef SB_FOTA_OS_H_
15+
#define SB_FOTA_OS_H_
1616

1717
#include <stddef.h>
1818
#include <stdint.h>
@@ -22,61 +22,61 @@
2222
/**
2323
* @brief Allocate memory.
2424
*/
25-
void *modem_fota_os_malloc(size_t size);
25+
void *sb_fota_os_malloc(size_t size);
2626

2727
/**
2828
* @brief Allocate memory and zero it.
2929
*/
30-
void *modem_fota_os_calloc(size_t nmemb, size_t size);
30+
void *sb_fota_os_calloc(size_t nmemb, size_t size);
3131

3232
/**
3333
* @brief Free memory.
3434
*/
35-
void modem_fota_os_free(void *ptr);
35+
void sb_fota_os_free(void *ptr);
3636

3737
/**
3838
* @brief Get uptime, in milliseconds.
3939
*/
40-
int64_t modem_fota_os_uptime_get(void);
40+
int64_t sb_fota_os_uptime_get(void);
4141

4242
/**
4343
* @brief Get uptime, in milliseconds.
4444
*/
45-
uint32_t modem_fota_os_uptime_get_32(void);
45+
uint32_t sb_fota_os_uptime_get_32(void);
4646

4747
/**
4848
* @brief Put a thread to a sleep.
4949
*/
50-
int modem_fota_os_sleep(int ms);
50+
int sb_fota_os_sleep(int ms);
5151

5252
/**
5353
* @brief Reboot system.
5454
*/
55-
void modem_fota_os_sys_reset(void);
55+
void sb_fota_os_sys_reset(void);
5656

5757
/**
5858
* @brief Get a random value.
5959
*/
60-
uint32_t modem_fota_os_rand_get(void);
60+
uint32_t sb_fota_os_rand_get(void);
6161

62-
#define MODEM_FOTA_N_SEMAPHORES 4
62+
#define SB_FOTA_OS_SEMAPHORE_COUNT 4
6363

6464
/** Opaque type for OS semaphore */
65-
struct modem_fota_sem;
65+
struct sb_fota_os_sem;
6666

6767
/**
6868
* @brief Allocate a semaphore from OS
6969
*
7070
* @return pointer to allocated semaphore or NULL on failure.
7171
*/
72-
struct modem_fota_sem *modem_fota_sem_alloc();
72+
struct sb_fota_os_sem *sb_fota_os_sem_alloc(void);
7373

7474
/**
7575
* @brief Give a semaphore.
7676
*
7777
* @param sem pointer to a taken semaphore.
7878
*/
79-
void modem_fota_sem_give(struct modem_fota_sem *sem);
79+
void sb_fota_os_sem_give(struct sb_fota_os_sem *sem);
8080

8181
/**
8282
* @brief Take a semaphore.
@@ -85,102 +85,97 @@ void modem_fota_sem_give(struct modem_fota_sem *sem);
8585
* @param timeout_ms timeout in milliseconds, or negative if call can block forever.
8686
* @return zero on success or negative error code on failure.
8787
*/
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);
8989

9090
/**
9191
* @brief Reset semaphore count to zero.
9292
*
9393
* @param sem pointer to a semaphore.
9494
*/
95-
void modem_fota_sem_reset(struct modem_fota_sem *sem);
95+
void sb_fota_os_sem_reset(struct sb_fota_os_sem *sem);
9696

97+
#define SB_FOTA_OS_WORK_COUNT 6
98+
#define SB_FOTA_OS_DELAYED_WORK_COUNT 1
9799

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 *);
100102

101-
/** Generic event callback type */
102-
typedef void (*modem_fota_event_callback)(void *);
103+
/** Opaque work type */
104+
struct sb_fota_os_work;
103105

104-
/** Opaque event type */
105-
struct modem_fota_event;
106+
/** Opaque delayed work type */
107+
struct sb_fota_os_delayed_work;
106108

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);
109113

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
116115

117116
/** 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;
124118

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);
126123

124+
int64_t sb_fota_os_timegm64(const struct tm *time);
127125

128126
#define FOTA_LOG_LEVEL_NONE 0U
129127
#define FOTA_LOG_LEVEL_ERR 1U
130128
#define FOTA_LOG_LEVEL_WRN 2U
131129
#define FOTA_LOG_LEVEL_INF 3U
132130
#define FOTA_LOG_LEVEL_DBG 4U
133131

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);
142134

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__);
143139

144-
#define MODEM_FOTA_SETTINGS_PREFIX "modem_fota"
140+
#define SB_FOTA_SETTINGS_PREFIX "sb_fota"
145141

146142
/** 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. */
152147
};
153148

154149
/** Load array of settings from persistent storage.
155150
* Settings should be given as an array that ends with element where name is NULL.
156151
*/
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);
158153

159154
/** 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.
161156
*/
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);
163158

164159
/** Apply modem FW update */
165-
void sb_fota_apply_update(void);
160+
void sb_fota_os_update_apply(void);
166161

167162
/** @} */
168163

169164
#ifdef UNITTESTING
170165
/* For unittesting purposes, I need dummy types of every opaque struct */
171-
struct modem_fota_sem
166+
struct sb_fota_os_sem
172167
{
173168
int val;
174169
};
175-
struct modem_fota_event
170+
struct sb_fota_os_work
176171
{
177172
int val;
178173
};
179-
struct modem_fota_delayed_event
174+
struct sb_fota_os_delayed_work
180175
{
181176
int val;
182177
};
183-
struct modem_fota_timer
178+
struct sb_fota_os_timer
184179
{
185180
int val;
186181
};
@@ -203,8 +198,8 @@ int get_lte_mode(void);
203198
bool get_lte_active_status(void);
204199
bool get_rrc_idle_status(void);
205200
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);
208203
#endif
209204

210-
#endif /* MODEM_FOTA_OS_H_ */
205+
#endif /* SB_FOTA_OS_H_ */

0 commit comments

Comments
 (0)