5#ifndef LIBGULLIBLE_CONTROLLER_HPP
6#define LIBGULLIBLE_CONTROLLER_HPP
13 using namespace std::chrono_literals;
28 [[nodiscard]]
retcode do_read(mlab::bin_data &
data, std::uint16_t, std::uint16_t)
override;
30 [[nodiscard]]
retcode do_write(mlab::bin_data
const &
data, std::uint16_t, std::uint16_t)
override;
37 std::unique_ptr<T[]>
v =
nullptr;
41 v = std::unique_ptr<T[]>(
new T[new_size]);
68 explicit controller(std::vector<service>
const &svcs);
111 [[nodiscard]] inline std::vector<
service::snapshot> const &
services() const;
117 connect = BLE_GAP_EVENT_CONNECT,
123 disc = BLE_GAP_EVENT_DISC,
131 mtu = BLE_GAP_EVENT_MTU,
mlab::bin_data & data
Definition: characteristic.cpp:49
Definition: characteristic.hpp:52
Definition: controller.hpp:33
void advertise_stop()
Definition: controller.cpp:256
std::vector< service::snapshot > const & services() const
Definition: controller.hpp:147
std::uint16_t get_device_appearance() const
Definition: controller.cpp:164
void set_auto_advertise(bool aa)
Definition: controller.hpp:159
static void _nimble_main_task(void *)
Definition: controller.cpp:268
std::string get_device_name() const
Definition: controller.cpp:160
std::unique_ptr< ble_gatt_svc_def[]> _nimble_svc_defs
Definition: controller.hpp:47
bool auto_advertise() const
Definition: controller.hpp:155
static void _nimble_sync_cbk()
Definition: controller.cpp:332
dyn_c_vec< ble_uuid128_t > _nimble_svc_uuid128
Definition: controller.hpp:50
void set_device_appearance(std::uint16_t new_appearance)
Definition: controller.cpp:168
static void _nimble_reset_cbk(int reason)
Definition: controller.cpp:281
std::vector< service::snapshot > _svc_snapshots
Definition: controller.hpp:46
void ensure_own_address()
Definition: controller.cpp:318
void start()
Definition: controller.cpp:345
dyn_c_vec< ble_uuid32_t > _nimble_svc_uuid32
Definition: controller.hpp:49
controller(std::vector< service > const &svcs)
Definition: controller.cpp:50
controller(controller &&) noexcept=delete
void set_device_name(std::string const &new_name)
Definition: controller.cpp:153
void advertise_start(std::chrono::milliseconds duration=0ms)
Definition: controller.cpp:175
std::uint8_t _own_address
Definition: controller.hpp:51
void stop()
Definition: controller.cpp:359
bool _auto_advertise
Definition: controller.hpp:52
void configure_services(bool start_gatts_manually=false)
Definition: controller.cpp:134
dyn_c_vec< ble_uuid16_t > _nimble_svc_uuid16
Definition: controller.hpp:48
static int _nimble_on_gap_event_cbk(ble_gap_event *event, void *tracker)
Definition: controller.cpp:285
bool is_advertising() const
Definition: controller.cpp:264
bool is_running() const
Definition: controller.cpp:355
Definition: service.hpp:17
Definition: characteristic.hpp:14
device_appearance
Definition: controller.hpp:19
retcode
Definition: characteristic.hpp:16
gap_event
Definition: controller.hpp:116
const char * to_string(gap_event evt)
Definition: controller.cpp:365
Definition: controller.hpp:36
void resize(std::size_t new_size)
Definition: controller.hpp:40
std::size_t size
Definition: controller.hpp:38
std::unique_ptr< T[]> v
Definition: controller.hpp:37
Definition: controller.hpp:24
retcode do_write(mlab::bin_data const &data, std::uint16_t, std::uint16_t) override
Definition: controller.cpp:44
retcode do_read(mlab::bin_data &data, std::uint16_t, std::uint16_t) override
Definition: controller.cpp:37
device_name_characteristic(uuid u)
Definition: controller.cpp:35