samples: mgmt: hawkbit: runtime configuration for server address and port
Add runtime configuration for hawkbit server address and port
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
diff --git a/samples/subsys/mgmt/hawkbit/README.rst b/samples/subsys/mgmt/hawkbit/README.rst
index b674b89..6c472e5 100644
--- a/samples/subsys/mgmt/hawkbit/README.rst
+++ b/samples/subsys/mgmt/hawkbit/README.rst
@@ -86,6 +86,15 @@
:conf: "prj.conf"
:goals: build
+If you want to build it with the ability to set the hawkBit server address
+and port during runtime, you can use the following command:
+
+.. zephyr-app-commands::
+ :zephyr-app: samples/subsys/mgmt/hawkbit
+ :board: frdm_k64f
+ :conf: "prj.conf overlay-runtime.conf"
+ :goals: build
+
.. _hawkbit_sample_sign:
Step 5: Sign and confirm the first image
diff --git a/samples/subsys/mgmt/hawkbit/overlay-runtime.conf b/samples/subsys/mgmt/hawkbit/overlay-runtime.conf
new file mode 100644
index 0000000..2b1b004
--- /dev/null
+++ b/samples/subsys/mgmt/hawkbit/overlay-runtime.conf
@@ -0,0 +1 @@
+CONFIG_HAWKBIT_SET_SETTINGS_RUNTIME=y
diff --git a/samples/subsys/mgmt/hawkbit/prj.conf b/samples/subsys/mgmt/hawkbit/prj.conf
index ebbd3b0..469d871 100644
--- a/samples/subsys/mgmt/hawkbit/prj.conf
+++ b/samples/subsys/mgmt/hawkbit/prj.conf
@@ -14,6 +14,7 @@
CONFIG_DNS_RESOLVER=y
CONFIG_JSON_LIBRARY=y
CONFIG_BOOTLOADER_MCUBOOT=y
+CONFIG_SETTINGS=y
#Main Stack Size
CONFIG_MAIN_STACK_SIZE=4096
diff --git a/samples/subsys/mgmt/hawkbit/src/main.c b/samples/subsys/mgmt/hawkbit/src/main.c
index 6cf6ea0..6374b02 100644
--- a/samples/subsys/mgmt/hawkbit/src/main.c
+++ b/samples/subsys/mgmt/hawkbit/src/main.c
@@ -76,11 +76,15 @@
#endif /* CONFIG_HAWKBIT_CUSTOM_ATTRIBUTES */
ret = hawkbit_init();
-
if (ret < 0) {
LOG_ERR("Failed to init hawkBit");
}
+#ifdef CONFIG_HAWKBIT_SET_SETTINGS_RUNTIME
+ hawkbit_set_server_addr(CONFIG_HAWKBIT_SERVER);
+ hawkbit_set_server_port(CONFIG_HAWKBIT_PORT);
+#endif
+
#if defined(CONFIG_HAWKBIT_POLLING)
LOG_INF("Starting hawkBit polling mode");
hawkbit_autohandler();