Part 1
요약·해설
bt_conn_ref·unref, connection callback과 Central create 흐름을 설명합니다.
bt_conn
Reference counted
bt_conn_cb
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
6963F7BFD11BDA17AF749E0F6EC8765472B36159D792A575D231EA403A05013D
.. _bluetooth_connection_mgmt:
Connection Management
#####################
The Zephyr Bluetooth stack uses an abstraction called :c:struct:`bt_conn`
to represent connections to other devices. The internals of this struct
are not exposed to the application, but a limited amount of information
(such as the remote address) can be acquired using the
:c:func:`bt_conn_get_info` API. Connection objects are reference
counted, and the application is expected to use the
:c:func:`bt_conn_ref` API whenever storing a connection pointer for a
longer period of time, since this ensures that the object remains valid
(even if the connection would get disconnected). Similarly the
:c:func:`bt_conn_unref` API is to be used when releasing a reference
to a connection.
An application may track connections by registering a
:c:struct:`bt_conn_cb` struct using the :c:func:`bt_conn_cb_register`
or :c:macro:`BT_CONN_CB_DEFINE` APIs. This struct lets the application
define callbacks for connection & disconnection events, as well as other
events related to a connection such as a change in the security level or
the connection parameters. When acting as a central the application will
also get hold of the connection object through the return value of the
:c:func:`bt_conn_le_create` API.
API Reference
*************
.. doxygengroup:: bt_conn
Part 3
한국어 전문 번역
Connection Management
Zephyr Bluetooth stack은 다른 device와의 connection을 bt_conn abstraction으로 나타냅니다. Struct 내부는 application에 공개하지 않지만 bt_conn_get_info로 remote address 같은 제한된 정보를 얻을 수 있습니다.
Reference counting
Connection object는 reference count로 수명을 관리합니다. Application이 connection pointer를 오래 저장할 때는 bt_conn_ref를 호출해야 disconnect 이후에도 object가 유효합니다. 저장한 reference를 놓을 때는 bt_conn_unref를 호출합니다.
Connection event 추적
bt_conn_cb_register 또는 BT_CONN_CB_DEFINE으로 bt_conn_cb callback struct를 등록합니다. Connection·disconnection, security level 변경과 connection parameter 변경 event를 받을 수 있습니다. Central로 동작하면 bt_conn_le_create 반환값으로 connection object를 얻습니다.
API Reference
공식 bt_conn Doxygen group이 connection management API 전체를 생성합니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.