Please tell me about rudimentary things. Can I add dis_init to ble_app_uart with nRF 52832-SDK, for example?
Please tell me about rudimentary things. Can I add dis_init to ble_app_uart with nRF 52832-SDK, for example?
Hi,
Yes, that is possible. Below are the steps required to add DIS to the ble_app_uart project in SDK 12
Add ble_dis.c
to your project. It's located in the folder:
SDK_INSTALL_FOLDER/components/ble/ble_services/ble_dis
Include the ble_dis header file in main.c:
#include "ble_dis.h"
Add the DIS to the m_adv_uuids
array:
static ble_uuid_t m_adv_uuids[] = {{BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE},
{BLE_UUID_DEVICE_INFORMATION_SERVICE, BLE_UUID_TYPE_BLE}}; /**< Universally unique service identifier. */
Add the manufacture name to be used by the DIS:
#define MANUFACTURER_NAME "NordicSemiconductor" /**< Manufacturer. Will be passed to Device Information Service. */
Enable BLE_DIS_ENABLED in sdk_config.h
:
#ifndef BLE_DIS_ENABLED
#define BLE_DIS_ENABLED 1
#endif
Add the DIS initialization to the services_init()
function:
static void services_init(void)
{
uint32_t err_code;
ble_nus_init_t nus_init;
memset(&nus_init, 0, sizeof(nus_init));
nus_init.data_handler = nus_data_handler;
err_code = ble_nus_init(&m_nus, &nus_init);
APP_ERROR_CHECK(err_code);
// Initialize Device Information Service.
ble_dis_init_t dis_init;
memset(&dis_init, 0, sizeof(dis_init));
ble_srv_ascii_to_utf8(&dis_init.manufact_name_str, (char *)MANUFACTURER_NAME);
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&dis_init.dis_attr_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&dis_init.dis_attr_md.write_perm);
err_code = ble_dis_init(&dis_init);
APP_ERROR_CHECK(err_code);
}
It worked. Thank you very much. Next, I will challenge bas_init, hrs_init, .... Please help me when I am in trouble because I do not understand.
If you run into new problems, just post a new question on the main page :) If I answered this question I would appreciate if you could accept my answer by clicking the grey circle with a check mark in it. Thank you.