Part 1
요약·해설
Group/error/event 정의부터 zcbor handler, callback, build 연결과 재사용 가능한 Zephyr module 구성까지 이어서 설명합니다.
16-bit group · 8-bit command
Header · source · Kconfig · CMake
Application or module
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
5BEED280C7E0E7CBB8FC9F647D0A4D228E7B5EB02B9E1CCA4379D4EB289E5FA6
.. _mcumgr_handlers:
MCUmgr handlers
###############
Overview
********
MCUmgr functions by having group handlers which identify a group of functions relating to a
specific management area, which is addressed with a 16-bit identification value,
:c:enum:`mcumgr_group_t` contains the management groups available in Zephyr with their
corresponding group ID values. The group ID is included in SMP headers to identify which
group a command belongs to, there is also an 8-bit command ID which identifies the function of
that group to execute - see :ref:`mcumgr_smp_protocol_specification` for details on the SMP
protocol and header. There can only be one registered group per unique ID.
Implementation
**************
MCUmgr handlers can be added externally by application code or by module code, they do not have
to reside in the upstream Zephyr tree to be usable. The first step to creating a handler is to
create the folder structure for it, the typical Zephyr MCUmgr group layout is as follows:
.. code-block:: none
<dir>/grp/<grp_name>_mgmt/
├── CMakeLists.txt
├── Kconfig
├── include
├──── <grp_name>_mgmt.h
├──── <grp_name>_mgmt_callbacks.h
├── src
└──── <grp_name>_mgmt.c
Note that the header files in upstream Zephyr MCUmgr handlers reside in the
``zephyr/include/zephyr/mgmt/mcumgr/grp/<grp_name>_mgmt`` directory to allow the files to be
globally included by applications.
Initial header <grp_name>_mgmt.h
================================
The purpose of the header file is to provide defines which can be used by the MCUmgr handler
itself and application code, e.g. to reference the command IDs for executing functions. An example
file would look similar to:
.. literalinclude:: ../../../../../tests/subsys/mgmt/mcumgr/handler_demo/example_as_module/include/example_mgmt.h
:language: c
:linenos:
This provides the defines for 2 command ``test`` and ``other`` and sets up the SMP version 2 error
responses (which have unique error codes per group as opposed to the legacy SMP version 1 error
responses that return a :c:enum:`mcumgr_err_t` - there should always be an OK error code with the
value 0 and an unknown error code with the value 1. The above example then adds an error code of
``not wanted`` with value 2. In addition, the group ID is set to be
:c:enumerator:`MGMT_GROUP_ID_PERUSER`, which is the start group ID for user-defined groups, note
that group IDs need to be unique so other custom groups should use different values, a central index
header file (as upstream Zephyr has) can be used to distribute group IDs more easily.
Initial header <grp_name>_mgmt_callbacks.h
==========================================
The purpose of the header file is to provide defines which can be used by the MCUmgr handler
itself and application code, e.g. to reference the command IDs for executing functions. An example
file would look similar to:
.. literalinclude:: ../../../../../tests/subsys/mgmt/mcumgr/handler_demo/example_as_module/include/example_mgmt_callbacks.h
:language: c
:linenos:
This sets up a single event which application (or module) code can register for to receive a
callback when the function handler is executed, which allows the flow of the handler to be
changed (i.e. to return an error instead of continuing). The event group ID is set to
:c:enumerator:`MGMT_EVT_GRP_USER_CUSTOM_START`, which is the start event ID for user-defined groups,
note that event IDs need to be unique so other custom groups should use different values, a
central index header file (as upstream Zephyr has) can be used to distribute event IDs more
easily.
Initial source <grp_name>_mgmt.c
================================
The purpose of this source file is to handle the incoming MCUmgr commands, provide responses, and
register the transport with MCUmgr so that commands will be sent to it. An example file would
look similar to:
.. literalinclude:: ../../../../../tests/subsys/mgmt/mcumgr/handler_demo/example_as_module/src/example_mgmt.c
:language: c
:linenos:
The above code creates 2 function handlers, ``test`` which supports read requests and takes 2
required parameters, and ``other`` which supports write requests and takes 1 optional parameter,
this function handler has an optional notification callback feature that allows other parts of
the code to listen for the event and take any required actions that are necessary or prevent
further execution of the function by returning an error, further details on MCUmgr callback
functionality can be found on :ref:`mcumgr_callbacks`.
Note that other code referencing callbacks for custom MCUmgr handlers needs to include both the
base Zephyr callback include file and the custom handler callback file, only in-tree Zephyr
handler headers are included when including the upstream Zephyr callback header file.
Initial Kconfig
===============
The purpose of the Kconfig file is to provide options which users can enable or change relating
to the functionality of the handler being implemented. An example file would look similar to:
.. literalinclude:: ../../../../../tests/subsys/mgmt/mcumgr/handler_demo/Kconfig
:language: kconfig
Initial CMakeLists.txt
======================
The CMakeLists.txt file is used by the build system to setup files to compile, include
directories to add and specify options that can be changed. A basic file only need to include the
source files if the Kconfig options are enabled. An example file would look similar to:
.. tabs::
.. group-tab:: Zephyr module
.. literalinclude:: ../../../../../tests/subsys/mgmt/mcumgr/handler_demo/example_as_module/CMakeLists.txt
:language: cmake
.. group-tab:: Application
.. literalinclude:: ../../../../../tests/subsys/mgmt/mcumgr/handler_demo/CMakeLists.txt
:language: cmake
:start-after: Include handler files
Including from application
**************************
Application-specific MCUmgr handlers can be added by creating/editing application build files.
Example modifications are shown below.
Example CMakeLists.txt
======================
The application ``CMakeLists.txt`` file can load the CMake file for the example MCUmgr handler by
adding the following:
.. code-block:: cmake
add_subdirectory(mcumgr/grp/<grp_name>)
Example Kconfig
===============
The application Kconfig file can include the Kconfig file for the example MCUmgr handler by adding
the following to the ``Kconfig`` file in the application directory (or creating it if it does not
exist):
.. code-block:: kconfig
rsource "mcumgr/grp/<grp_name>/Kconfig"
# Include Zephyr's Kconfig
source "Kconfig.zephyr"
Including from Zephyr Module
****************************
Zephyr :ref:`modules` can be used to add custom MCUmgr handlers to multiple different applications
without needing to duplicate the code in each application's source tree, see :ref:`module-yml` for
details on how to set up the module files. Example files are shown below.
Example zephyr/module.yml
=========================
This is an example file which can be used to load the Kconfig and CMake files from the root of the
module directory, and would be placed at ``zephyr/module.yml``:
.. code-block:: yaml
build:
kconfig: Kconfig
cmake: .
Example CMakeLists.txt
======================
This is an example CMakeLists.txt file which loads the CMake file for the example MCUmgr handler,
and would be placed at ``CMakeLists.txt``:
.. code-block:: cmake
add_subdirectory(mcumgr/grp/<grp_name>)
Example Kconfig
===============
This is an example Kconfig file which loads the Kconfig file for the example MCUmgr handler, and
would be placed at ``Kconfig``:
.. code-block:: kconfig
rsource "mcumgr/grp/<grp_name>/Kconfig"
Demonstration handler
*********************
There is a demonstration project which includes configuration for both application and zephyr
module-MCUmgr handlers which can be used as a basis for created your own in
:zephyr_file:`tests/subsys/mgmt/mcumgr/handler_demo/`.
Part 3
한국어 전문 번역
개요
MCUmgr는 특정 management 영역과 관련된 function 묶음을 식별하는 group handler로 동작합니다. 각 group은 16-bit 식별 값으로 address되며 mcumgr_group_t에는 Zephyr에서 사용할 수 있는 management group과 대응 group ID가 들어 있습니다. SMP header에는 command가 어느 group에 속하는지 나타내는 group ID가 포함되고, 그 group에서 실행할 function을 나타내는 8-bit command ID도 있습니다. SMP protocol과 header의 세부 사항은 SMP Protocol Specification을 참고합니다. 고유 ID 하나에는 group 하나만 등록할 수 있습니다.
구현
MCUmgr handler는 application code나 module code에서 외부로 추가할 수 있으며 upstream Zephyr tree 안에 있을 필요가 없습니다. Handler를 만들 때 첫 단계는 directory 구조를 준비하는 것입니다. 일반적인 Zephyr MCUmgr group layout은 다음과 같습니다.
<dir>/grp/<grp_name>_mgmt/
├── CMakeLists.txt
├── Kconfig
├── include
├──── <grp_name>_mgmt.h
├──── <grp_name>_mgmt_callbacks.h
├── src
└──── <grp_name>_mgmt.c
Upstream Zephyr의 MCUmgr handler header는 application 어디서든 include할 수 있도록 zephyr/include/zephyr/mgmt/mcumgr/grp/<grp_name>_mgmt directory에 있습니다.
초기 header <grp_name>_mgmt.h
이 header file은 MCUmgr handler 자체와 application code가 사용할 define을 제공합니다. 예를 들어 function을 실행할 때 command ID를 참조하는 데 사용합니다. 예제 file은 다음과 비슷합니다.
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef H_EXAMPLE_MGMT_
#define H_EXAMPLE_MGMT_
#ifdef __cplusplus
extern "C" {
#endif
/**
* Group ID for example management group.
*/
#define MGMT_GROUP_ID_EXAMPLE MGMT_GROUP_ID_PERUSER
/**
* Command IDs for example management group.
*/
#define EXAMPLE_MGMT_ID_TEST 0
#define EXAMPLE_MGMT_ID_OTHER 1
/**
* Command result codes for example management group.
*/
enum example_mgmt_err_code_t {
/** No error, this is implied if there is no ret value in the response */
EXAMPLE_MGMT_ERR_OK = 0,
/** Unknown error occurred. */
EXAMPLE_MGMT_ERR_UNKNOWN,
/** The provided value is not wanted at this time. */
EXAMPLE_MGMT_ERR_NOT_WANTED,
/** The provided value was rejected by a hook. */
EXAMPLE_MGMT_ERR_REJECTED_BY_HOOK,
};
#ifdef __cplusplus
}
#endif
#endif
이 예제는 test와 other라는 command 2개의 define을 제공하고 SMP version 2 error response를 설정합니다. Group마다 고유 error code를 갖는 version 2와 달리 legacy SMP version 1 response는 mcumgr_err_t를 반환합니다. OK error code는 항상 값 0, unknown error code는 항상 값 1이어야 합니다. 예제는 여기에 값 2인 not wanted error code를 추가합니다.
Group ID는 user-defined group의 시작 ID인 MGMT_GROUP_ID_PERUSER로 정합니다. Group ID는 고유해야 하므로 다른 custom group은 다른 값을 사용해야 합니다. Upstream Zephyr처럼 중앙 index header file을 두면 group ID를 더 쉽게 배분할 수 있습니다.
초기 header <grp_name>_mgmt_callbacks.h
이 header file도 MCUmgr handler와 application code가 사용할 define을 제공합니다. 예제 file은 다음과 비슷합니다.
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef H_MCUMGR_EXAMPLE_MGMT_CALLBACKS_
#define H_MCUMGR_EXAMPLE_MGMT_CALLBACKS_
#include <stdint.h>
#include <zephyr/mgmt/mcumgr/mgmt/callbacks.h>
#ifdef __cplusplus
extern "C" {
#endif
/* This is the event ID for the example group */
#define MGMT_EVT_GRP_EXAMPLE MGMT_EVT_GRP_USER_CUSTOM_START
/* MGMT event opcodes for example management group */
enum example_mgmt_group_events {
/* Callback when the other command is received, data is example_mgmt_other_data */
MGMT_EVT_OP_EXAMPLE_OTHER = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_EXAMPLE, 0),
/* Used to enable all smp_group events */
MGMT_EVT_OP_EXAMPLE_MGMT_ALL = MGMT_DEF_EVT_OP_ALL(MGMT_EVT_GRP_EXAMPLE),
};
/* Structure provided in the #MGMT_EVT_OP_EXAMPLE_OTHER notification callback */
struct example_mgmt_other_data {
/* Contains the user supplied value */
uint32_t user_value;
};
#ifdef __cplusplus
}
#endif
#endif
이 예제는 function handler가 실행될 때 application 또는 module code가 등록해 callback을 받을 event 하나를 설정합니다. Callback은 handler flow를 바꿀 수 있으며, 예를 들어 계속 실행하는 대신 error를 반환할 수 있습니다.
Event group ID는 user-defined group의 시작 event ID인 MGMT_EVT_GRP_USER_CUSTOM_START로 정합니다. Event ID도 고유해야 하므로 다른 custom group은 다른 값을 사용해야 합니다. Upstream Zephyr처럼 중앙 index header file을 사용하면 event ID를 더 쉽게 배분할 수 있습니다.
초기 source <grp_name>_mgmt.c
이 source file은 들어오는 MCUmgr command를 처리하고 response를 만들며, command가 이 handler로 전달되도록 transport를 MCUmgr에 등록합니다. 예제 file은 다음과 비슷합니다.
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <zephyr/mgmt/mcumgr/mgmt/mgmt.h>
#include <zephyr/mgmt/mcumgr/smp/smp.h>
#include <zephyr/mgmt/mcumgr/mgmt/handlers.h>
/* The below should be updated with the real name of the file */
#include <example_mgmt.h>
#include <zephyr/logging/log.h>
#include <assert.h>
#include <limits.h>
#include <string.h>
#include <stdio.h>
#include <zcbor_common.h>
#include <zcbor_decode.h>
#include <zcbor_encode.h>
#include <mgmt/mcumgr/util/zcbor_bulk.h>
#if defined(CONFIG_MCUMGR_MGMT_NOTIFICATION_HOOKS)
#include <zephyr/mgmt/mcumgr/mgmt/callbacks.h>
#if defined(CONFIG_MCUMGR_GRP_EXAMPLE_OTHER_HOOK)
/* The below should be updated with the real name of the file */
#include <example_mgmt_callbacks.h>
#endif
#endif
LOG_MODULE_REGISTER(mcumgr_example_grp, CONFIG_MCUMGR_GRP_EXAMPLE_LOG_LEVEL);
/* Example function with "read" command support, requires both parameters are supplied */
static int example_mgmt_test(struct smp_streamer *ctxt)
{
uint32_t uint_value = 0;
zcbor_state_t *zse = ctxt->writer->zs;
zcbor_state_t *zsd = ctxt->reader->zs;
bool ok;
struct zcbor_string string_value = { 0 };
size_t decoded;
struct zcbor_map_decode_key_val example_test_decode[] = {
ZCBOR_MAP_DECODE_KEY_DECODER("uint_key", zcbor_uint32_decode, &uint_value),
ZCBOR_MAP_DECODE_KEY_DECODER("string_key", zcbor_tstr_decode, &string_value),
};
LOG_DBG("Example test function called");
ok = zcbor_map_decode_bulk(zsd, example_test_decode, ARRAY_SIZE(example_test_decode),
&decoded) == 0;
/* Check that both parameters were supplied and that the value of "string_key" is not
* empty
*/
if (!ok || string_value.len == 0 || !zcbor_map_decode_bulk_key_found(
example_test_decode, ARRAY_SIZE(example_test_decode), "uint_key")) {
return MGMT_ERR_EINVAL;
}
/* If the value of "uint_key" is over 50, return an error of "not wanted" */
if (uint_value > 50) {
ok = smp_add_cmd_err(zse, MGMT_GROUP_ID_EXAMPLE, EXAMPLE_MGMT_ERR_NOT_WANTED);
goto end;
}
/* Otherwise, return an integer value of 4691 */
ok = zcbor_tstr_put_lit(zse, "return_int") &&
zcbor_int32_put(zse, 4691);
end:
/* If "ok" is false, then there was an error processing the output cbor message, which
* likely indicates a lack of available memory
*/
return (ok ? MGMT_ERR_EOK : MGMT_ERR_EMSGSIZE);
}
/* Example function with "write" command support */
static int example_mgmt_other(struct smp_streamer *ctxt)
{
uint32_t user_value = 0;
zcbor_state_t *zse = ctxt->writer->zs;
zcbor_state_t *zsd = ctxt->reader->zs;
bool ok;
size_t decoded;
struct zcbor_map_decode_key_val example_other_decode[] = {
ZCBOR_MAP_DECODE_KEY_DECODER("user_value", zcbor_uint32_decode, &user_value),
};
#if defined(CONFIG_MCUMGR_GRP_EXAMPLE_OTHER_HOOK)
struct example_mgmt_other_data other_data;
enum mgmt_cb_return status;
int32_t err_rc;
uint16_t err_group;
#endif
LOG_DBG("Example other function called");
ok = zcbor_map_decode_bulk(zsd, example_other_decode, ARRAY_SIZE(example_other_decode),
&decoded) == 0;
/* The supplied value is optional, therefore do not return an error if it was not
* provided
*/
if (!ok) {
return MGMT_ERR_EINVAL;
}
#if defined(CONFIG_MCUMGR_GRP_EXAMPLE_OTHER_HOOK)
/* Send request to application to check what to do */
other_data.user_value = user_value;
status = mgmt_callback_notify(MGMT_EVT_OP_EXAMPLE_OTHER, &other_data, sizeof(other_data),
&err_rc, &err_group);
if (status != MGMT_CB_OK) {
/* If a callback returned an RC error, exit out, if it returned a group error
* code, add the error code to the response and return to the calling function to
* have it sent back to the client
*/
if (status == MGMT_CB_ERROR_RC) {
return err_rc;
}
ok = smp_add_cmd_err(zse, err_group, (uint16_t)err_rc);
goto end;
}
#endif
/* Return some dummy data to the client */
ok = zcbor_tstr_put_lit(zse, "return_string") &&
zcbor_tstr_put_lit(zse, "some dummy data!");
#if defined(CONFIG_MCUMGR_GRP_EXAMPLE_OTHER_HOOK)
end:
#endif
/* If "ok" is false, then there was an error processing the output cbor message, which
* likely indicates a lack of available memory
*/
return (ok ? MGMT_ERR_EOK : MGMT_ERR_EMSGSIZE);
}
#ifdef CONFIG_MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL
/* This is a lookup function that converts from SMP version 2 group error codes to legacy
* MCUmgr error codes, it is only included if support for the original protocol is enabled.
* Note that in SMP version 2, MCUmgr error codes can still be returned, but are to be used
* only for general SMP/MCUmgr errors. The success/OK error code is not used in translation
* functions as it is automatically handled by the base SMP code.
*/
static int example_mgmt_translate_error_code(uint16_t err)
{
int rc;
switch (err) {
case EXAMPLE_MGMT_ERR_NOT_WANTED:
rc = MGMT_ERR_ENOENT;
break;
case EXAMPLE_MGMT_ERR_REJECTED_BY_HOOK:
rc = MGMT_ERR_EBADSTATE;
break;
case EXAMPLE_MGMT_ERR_UNKNOWN:
default:
rc = MGMT_ERR_EUNKNOWN;
}
return rc;
}
#endif
static const struct mgmt_handler example_mgmt_handlers[] = {
[EXAMPLE_MGMT_ID_TEST] = {
.mh_read = example_mgmt_test,
.mh_write = NULL,
},
[EXAMPLE_MGMT_ID_OTHER] = {
.mh_read = NULL,
.mh_write = example_mgmt_other,
},
};
static struct mgmt_group example_mgmt_group = {
.mg_handlers = example_mgmt_handlers,
.mg_handlers_count = ARRAY_SIZE(example_mgmt_handlers),
.mg_group_id = MGMT_GROUP_ID_EXAMPLE,
#ifdef CONFIG_MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL
.mg_translate_error = example_mgmt_translate_error_code,
#endif
};
static void example_mgmt_register_group(void)
{
/* This function is called during system init before main() is invoked, if the
* handler needs to set anything up before it can be used, it should do it here.
* This register the group so that clients can call the function handlers.
*/
mgmt_register_group(&example_mgmt_group);
}
MCUMGR_HANDLER_DEFINE(example_mgmt, example_mgmt_register_group);
위 code는 function handler 2개를 만듭니다. test는 read request를 지원하고 필수 parameter 2개를 받습니다. other는 write request를 지원하며 선택 parameter 1개를 받습니다.
other handler에는 선택적인 notification callback 기능도 있습니다. 다른 code가 event를 듣고 필요한 action을 수행하거나 error를 반환해 function의 추가 실행을 막을 수 있습니다. MCUmgr callback 기능의 자세한 내용은 MCUmgr Callbacks를 참고합니다.
Custom MCUmgr handler의 callback을 참조하는 다른 code는 Zephyr 기본 callback include file과 custom handler callback file을 모두 include해야 합니다. Upstream Zephyr callback header file을 include할 때 자동으로 들어오는 것은 Zephyr tree 내부 handler header뿐입니다.
초기 Kconfig
Kconfig file은 구현 중인 handler 기능과 관련해 사용자가 활성화하거나 바꿀 수 있는 option을 제공합니다. 예제 file은 다음과 비슷합니다.
# Copyright Nordic Semiconductor ASA 2023. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# The Kconfig file is dedicated to example management group of
# of MCUmgr subsystem and provides Kconfig options to configure
# group commands behaviour and other aspects.
#
# Options defined in this file should be prefixed:
# MCUMGR_GRP_EXAMPLE_ -- general group options;
#
# When adding Kconfig options, that control the same feature,
# try to group them together by the same stem after prefix.
if MCUMGR
menuconfig MCUMGR_GRP_EXAMPLE_APP
bool "MCUmgr handlers for example management (app)"
select MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
default y
help
Enables MCUmgr handlers for example management. This demonstrates the
file at application-level.
if MCUMGR_GRP_EXAMPLE_APP
config MCUMGR_GRP_EXAMPLE_OTHER_HOOK
bool "Other hook"
depends on MCUMGR_MGMT_NOTIFICATION_HOOKS
help
Allows applications to receive callback when the "other" example
management function is called
module = MCUMGR_GRP_EXAMPLE
module-str = mcumgr_grp_example
source "subsys/logging/Kconfig.template.log_config"
endif
endif
source "Kconfig.zephyr"
초기 CMakeLists.txt
CMakeLists.txt는 compile할 file과 추가할 include directory를 build system에 설정하고 변경 가능한 option을 지정합니다. 기본 file은 Kconfig option이 활성화됐을 때 source file을 포함하기만 하면 됩니다. Zephyr module과 application에 쓰는 예는 다음과 같습니다.
# Copyright (c) 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
if(CONFIG_MCUMGR_GRP_EXAMPLE_MODULE)
zephyr_library(mgmt_mcumgr_grp_example)
# The below should be updated with the real name of the file
zephyr_library_sources(src/example_mgmt.c)
zephyr_include_directories(include)
endif()
if(CONFIG_MCUMGR_GRP_EXAMPLE_APP)
target_sources(app PRIVATE example_as_module/src/example_mgmt.c)
zephyr_include_directories(example_as_module/include)
endif()
Application에서 포함
Application 전용 MCUmgr handler는 application build file을 만들거나 수정해 추가할 수 있습니다. 아래는 수정 예입니다.
CMakeLists.txt 예
Application의 CMakeLists.txt에 다음 내용을 추가하면 MCUmgr handler 예제의 CMake file을 불러옵니다.
add_subdirectory(mcumgr/grp/<grp_name>)
Kconfig 예
Application directory의 Kconfig file에 다음 내용을 추가하면 MCUmgr handler 예제의 Kconfig file을 포함합니다. File이 없다면 새로 만듭니다.
rsource "mcumgr/grp/<grp_name>/Kconfig"
# Include Zephyr's Kconfig
source "Kconfig.zephyr"
Zephyr module에서 포함
Zephyr module을 사용하면 application마다 source tree에 code를 복제하지 않고 여러 application에 custom MCUmgr handler를 추가할 수 있습니다. Module file 설정 방법은 같은 문서의 module YAML 설명을 참고합니다. 아래에 예제 file을 제시합니다.
zephyr/module.yml 예
다음 file은 module root directory의 Kconfig와 CMake file을 불러오는 예이며 zephyr/module.yml에 둡니다.
build:
kconfig: Kconfig
cmake: .
CMakeLists.txt 예
다음 CMakeLists.txt는 MCUmgr handler 예제의 CMake file을 불러오며 module root의 CMakeLists.txt에 둡니다.
add_subdirectory(mcumgr/grp/<grp_name>)
Kconfig 예
다음 Kconfig file은 MCUmgr handler 예제의 Kconfig file을 불러오며 module root의 Kconfig에 둡니다.
rsource "mcumgr/grp/<grp_name>/Kconfig"
Demonstration handler
Application 방식과 Zephyr module 방식의 MCUmgr handler 설정을 모두 포함한 demonstration project가 있습니다. tests/subsys/mgmt/mcumgr/handler_demo/를 자체 handler 작성의 출발점으로 사용할 수 있습니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.