Skip to content

Commit 98d80df

Browse files
nordic-hanikacperradoszewski
authored andcommitted
Update to the latest library
update to the latest library, including removal of reboot event. Signed-off-by: Håvard Vermeer <havard.vermeer@nordicsemi.no>
1 parent da1c314 commit 98d80df

File tree

10 files changed

+74
-55
lines changed

10 files changed

+74
-55
lines changed

lib/bin/sb_fota/CMakeLists.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ if(NOT EXISTS ${SB_FOTA_LIB_PATH})
2525
"(${SB_FOTA_LIB_PATH} doesn't exist.)")
2626
endif()
2727

28-
set( SB_FOTA_TARGET libsb_fota)
29-
zephyr_library_import(${SB_FOTA_TARGET} ${SB_FOTA_LIB_PATH}/libsb_fota.a)
28+
set(SB_FOTA_TARGET libsb_fota)
29+
if(CONFIG_SB_FOTA_LOG)
30+
zephyr_library_import(${SB_FOTA_TARGET} ${SB_FOTA_LIB_PATH}/libsb_fota_log.a)
31+
else()
32+
zephyr_library_import(${SB_FOTA_TARGET} ${SB_FOTA_LIB_PATH}/libsb_fota.a)
33+
endif()
3034
target_link_libraries(${SB_FOTA_TARGET} INTERFACE modem -lc)
3135

3236
zephyr_include_directories(include)

lib/bin/sb_fota/Kconfig

+7-1
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,15 @@ config SB_FOTA_ID_PREFIX
6464
be used on provisioning. Prefix is only appended on IMEI or UUID. Not appended on
6565
client ID changed on runtime API.
6666

67+
config SB_FOTA_LOG
68+
bool "Link binary with logs"
69+
help
70+
Links the application with the library version capable of emitting logs.
71+
This increases the final size of the application.
72+
6773
module=SB_FOTA
6874
module-dep=LOG
69-
module-str=Modem Firmware Over the Air client
75+
module-str=SoftBank FOTA library
7076
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"
7177

7278
endif # SB_FOTA

lib/bin/sb_fota/include/sb_fota.h

-5
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ enum sb_fota_event {
3838
* device is booted.
3939
*/
4040
SB_FOTA_EVENT_MODEM_SHUTDOWN,
41-
/** Modem FW is now updated, reboot the device to resume network operations. */
42-
SB_FOTA_EVENT_REBOOT_PENDING,
4341
};
4442

4543
/**
@@ -60,9 +58,6 @@ typedef void (*sb_fota_callback_t)(enum sb_fota_event event);
6058
* If Kconfig value CONFIG_SB_FOTA_AUTOINIT is set, then application is not required to call this
6159
* function, but might still want to use it for registering the callback.
6260
*
63-
* If there is no callback set, then the library automatically reboots the device in case of
64-
* SB_FOTA_EVENT_REBOOT_PENDING event.
65-
*
6661
* @param callback Callback for the application events or NULL for no callback.
6762
*
6863
* @retval 0 If the operation was successful.

lib/bin/sb_fota/include/sb_fota_os.h

+7-16
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ uint32_t sb_fota_os_uptime_get_32(void);
4949
*/
5050
int sb_fota_os_sleep(int ms);
5151

52-
/**
53-
* @brief Reboot system.
54-
*/
55-
void sb_fota_os_sys_reset(void);
56-
5752
/**
5853
* @brief Get a random value.
5954
*/
@@ -123,19 +118,15 @@ bool sb_fota_os_timer_is_running(struct sb_fota_os_timer *timer);
123118

124119
int64_t sb_fota_os_timegm64(const struct tm *time);
125120

126-
#define FOTA_LOG_LEVEL_NONE 0U
127-
#define FOTA_LOG_LEVEL_ERR 1U
128-
#define FOTA_LOG_LEVEL_WRN 2U
129-
#define FOTA_LOG_LEVEL_INF 3U
130-
#define FOTA_LOG_LEVEL_DBG 4U
121+
enum sb_fota_os_log_level {
122+
SB_FOTA_OS_LOG_LEVEL_NONE,
123+
SB_FOTA_OS_LOG_LEVEL_ERR,
124+
SB_FOTA_OS_LOG_LEVEL_WRN,
125+
SB_FOTA_OS_LOG_LEVEL_INF,
126+
SB_FOTA_OS_LOG_LEVEL_DBG,
127+
};
131128

132129
void sb_fota_os_log(int level, const char *fmt, ...);
133-
const char *sb_fota_os_log_strdup(const char *str);
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__);
139130

140131
#define SB_FOTA_SETTINGS_PREFIX "sb_fota"
141132

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

lib/bin/sb_fota/os/sb_fota_os.c

+49-29
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <zephyr/device.h>
1212
#include <zephyr/types.h>
1313
#include <zephyr/random/random.h>
14-
#include <zephyr/sys/reboot.h>
1514
#include <zephyr/sys/timeutil.h>
1615
#include <zephyr/logging/log.h>
1716
#include <zephyr/logging/log_msg.h>
@@ -56,12 +55,6 @@ int sb_fota_os_sleep(int ms)
5655

5756
/* OS functions */
5857

59-
void sb_fota_os_sys_reset(void)
60-
{
61-
sys_reboot(SYS_REBOOT_COLD);
62-
CODE_UNREACHABLE;
63-
}
64-
6558
uint32_t sb_fota_os_rand_get(void)
6659
{
6760
return sys_rand32_get();
@@ -215,30 +208,57 @@ int64_t sb_fota_os_timegm64(const struct tm *time)
215208
}
216209

217210
/* Logging */
218-
219211
LOG_MODULE_REGISTER(sb_fota, CONFIG_SB_FOTA_LOG_LEVEL);
220212

221-
void sb_fota_os_log(int level, const char *fmt, ...)
213+
#if defined(CONFIG_LOG)
214+
static uint8_t log_level_translate(uint8_t level)
222215
{
223-
if (!IS_ENABLED(CONFIG_LOG_MODE_MINIMAL)) {
224-
va_list ap;
225-
226-
va_start(ap, fmt);
227-
log_generic(level, fmt, ap);
228-
va_end(ap);
216+
switch (level) {
217+
case SB_FOTA_OS_LOG_LEVEL_ERR:
218+
return LOG_LEVEL_ERR;
219+
case SB_FOTA_OS_LOG_LEVEL_WRN:
220+
return LOG_LEVEL_WRN;
221+
case SB_FOTA_OS_LOG_LEVEL_INF:
222+
return LOG_LEVEL_INF;
223+
case SB_FOTA_OS_LOG_LEVEL_DBG:
224+
return LOG_LEVEL_DBG;
225+
default:
226+
return LOG_LEVEL_NONE;
229227
}
230228
}
229+
#endif
231230

232-
const char *sb_fota_os_log_strdup(const char *str)
233-
{
234-
return str;
235-
}
236-
237-
void sb_fota_os_logdump(const char *str, const void *data, size_t len)
231+
void sb_fota_os_log(int level, const char *fmt, ...)
238232
{
239-
if (IS_ENABLED(CONFIG_LOG)) {
240-
LOG_HEXDUMP_DBG(data, len, str);
233+
#if defined(CONFIG_LOG)
234+
level = log_level_translate(level);
235+
if (level > CONFIG_SB_FOTA_LOG_LEVEL) {
236+
return;
241237
}
238+
239+
va_list ap;
240+
va_start(ap, fmt);
241+
242+
#if CONFIG_LOG_MODE_MINIMAL
243+
/* Fallback to minimal implementation. */
244+
printk("%c: ", z_log_minimal_level_to_char(level));
245+
z_log_minimal_vprintk(fmt, ap);
246+
printk("\n");
247+
#else
248+
void *source;
249+
250+
if (IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING)) {
251+
source = (void *)__log_current_dynamic_data;
252+
} else {
253+
source = (void *)__log_current_const_data;
254+
}
255+
256+
z_log_msg_runtime_vcreate(Z_LOG_LOCAL_DOMAIN_ID, source, level,
257+
NULL, 0, 0, fmt, ap);
258+
#endif /* CONFIG_LOG_MODE_MINIMAL */
259+
260+
va_end(ap);
261+
#endif /* CONFIG_LOG */
242262
}
243263

244264
/* Settings */
@@ -304,19 +324,19 @@ void sb_fota_os_store_setting(const char *name, size_t len, const void *ptr)
304324

305325
void sb_fota_os_update_apply(void)
306326
{
307-
FOTA_LOG_INF("Applying modem firmware update...");
308-
FOTA_LOG_DBG("Shutting down modem");
327+
LOG_INF("Applying modem firmware update...");
328+
LOG_DBG("Shutting down modem");
309329

310330
if (fota_download_util_apply_update(DFU_TARGET_IMAGE_TYPE_MODEM_DELTA) == 0) {
311-
FOTA_LOG_DBG("Modem update OK");
331+
LOG_DBG("Modem update OK");
312332
} else {
313-
FOTA_LOG_ERR("Modem update failed");
333+
LOG_ERR("Modem update failed");
314334
}
315335

316336
int err = lte_lc_connect();
317337

318338
if (err) {
319-
FOTA_LOG_ERR("Connecting to network failed, err %d\n", err);
339+
LOG_ERR("Connecting to network failed, err %d", err);
320340
}
321341
}
322342

@@ -329,7 +349,7 @@ static void sb_fota_on_modem_init(int ret, void *ctx)
329349
if (IS_ENABLED(CONFIG_SB_FOTA_AUTOINIT)) {
330350
err = sb_fota_init(NULL);
331351
if (err) {
332-
FOTA_LOG_ERR("Failed to initialize FOTA client");
352+
LOG_ERR("Failed to initialize FOTA client");
333353
}
334354
}
335355
}

lib/bin/sb_fota/os/sb_fota_settings.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
#include <modem/modem_jwt.h>
1313
#include <modem/modem_info.h>
1414
#include <zephyr/sys/util_macro.h>
15+
#include <zephyr/logging/log.h>
1516

1617
#define IMEI_LEN 15
1718

19+
LOG_MODULE_REGISTER(sb_fota_settings, CONFIG_SB_FOTA_LOG_LEVEL);
20+
1821
int sb_fota_settings_cloud_sec_tag_get(void)
1922
{
2023
return CONFIG_SB_FOTA_TLS_SECURITY_TAG;
@@ -71,11 +74,11 @@ const char *sb_fota_settings_client_id_get(void)
7174
int ret;
7275
if (IS_ENABLED(CONFIG_SB_FOTA_ID_UUID)) {
7376
if ((ret = get_uuid())) {
74-
FOTA_LOG_ERR("Failed to read UUID (err %d)", ret);
77+
LOG_ERR("Failed to read UUID (err %d)", ret);
7578
}
7679
} else {
7780
if ((ret = get_imei())) {
78-
FOTA_LOG_ERR("Failed to read IMEI (err %d)", ret);
81+
LOG_ERR("Failed to read IMEI (err %d)", ret);
7982
}
8083
}
8184
}

0 commit comments

Comments
 (0)