5 #ifndef HERALD_ZEPHYR_CONTEXT_H
6 #define HERALD_ZEPHYR_CONTEXT_H
9 #include "ble/bluetooth_state_manager.h"
12 #ifndef CONFIG_HERALD_LOG_LEVEL
13 #define CONFIG_HERALD_LOG_LEVEL 0
16 #include "data/zephyr/zephyr_logging_sink.h"
17 #include "data/sensor_logger.h"
25 #include <bluetooth/bluetooth.h>
26 #include <bluetooth/gatt.h>
27 #include <bluetooth/gatt_dm.h>
31 using namespace herald::ble;
32 using namespace herald::data;
35 namespace zephyrinternal {
40 void stopAdvertising() noexcept;
41 void startAdvertising() noexcept;
42 void registerStopCallback(std::function<
void()> cb);
43 void registerStartCallback(std::function<
void()> cb);
45 std::optional<std::function<void()>> startCallback;
46 std::optional<std::function<void()>> stopCallback;
67 BluetoothState state()
override;
70 int enableBluetooth() noexcept;
74 int startBluetooth() noexcept;
75 int stopBluetooth() noexcept;
77 void periodicActions() noexcept;
79 Date getNow() noexcept;
86 std::vector<std::reference_wrapper<BluetoothStateManagerDelegate>> stateDelegates;
88 bool bluetoothEnabled;
93 namespace zephyrinternal {
102 virtual void scan_cb(
const bt_addr_le_t *addr, int8_t rssi, uint8_t adv_type,
103 struct net_buf_simple *buf) = 0;
106 virtual void discovery_completed_cb(
struct bt_gatt_dm *dm,
void *context) = 0;
107 virtual void discovery_service_not_found_cb(
struct bt_conn *conn,
void *context) = 0;
108 virtual void discovery_error_found_cb(
struct bt_conn *conn,
int err,
void *context) = 0;
109 virtual uint8_t gatt_read_cb(
struct bt_conn *conn, uint8_t err,
110 struct bt_gatt_read_params *params,
111 const void *data, uint16_t length) = 0;
114 virtual void le_param_updated(
struct bt_conn *conn, uint16_t interval,
115 uint16_t latency, uint16_t timeout) = 0;
116 virtual void connected(
struct bt_conn *conn, uint8_t err) = 0;
117 virtual void disconnected(
struct bt_conn *conn, uint8_t reason) = 0;
Holds generic state across our application for any Zephyr RTOS device.
Definition: zephyr_context.h:57
Definition: bluetooth_state_manager_delegate.h:16
Definition: bluetooth_state_manager.h:19
Definition: zephyr_logging_sink.h:19
Definition: zephyr_context.h:36
INTERNAL utility class to allow Zephyr C API to call callbacks in the Zephyr internal Context Impl cl...
Definition: zephyr_context.h:96
Acts as a non-global memory arena for arbitrary classes.
Definition: aggregates.h:15