You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
864 B
36 lines
864 B
/* |
|
* Copyright (c) 2024 Croxel, Inc. |
|
* |
|
* SPDX-License-Identifier: Apache-2.0 |
|
*/ |
|
|
|
#include <zephyr/kernel.h> |
|
#include <zephyr/bluetooth/bluetooth.h> |
|
#include <zephyr/bluetooth/services/nus.h> |
|
|
|
#define DEVICE_NAME CONFIG_BT_DEVICE_NAME |
|
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) |
|
|
|
static const struct bt_data ad[] = { |
|
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), |
|
BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN), |
|
}; |
|
|
|
static const struct bt_data sd[] = { |
|
BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_SRV_VAL), |
|
}; |
|
|
|
static int bt_nus_auto_start(void) |
|
{ |
|
int err; |
|
|
|
err = bt_enable(NULL); |
|
__ASSERT_NO_MSG(!err); |
|
|
|
err = bt_le_adv_start(BT_LE_ADV_CONN_FAST_1, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd)); |
|
__ASSERT_NO_MSG(!err); |
|
|
|
return 0; |
|
} |
|
|
|
SYS_INIT(bt_nus_auto_start, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);
|
|
|