summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/badge/ble.h54
1 files changed, 46 insertions, 8 deletions
diff --git a/include/badge/ble.h b/include/badge/ble.h
index 27b4749..1373d30 100644
--- a/include/badge/ble.h
+++ b/include/badge/ble.h
@@ -1,7 +1,8 @@
#pragma once
#include "indicator.h"
-#include <stdint.h>
+#include <cstdint>
+#include <string>
namespace de::uvok::badge
{
@@ -9,21 +10,58 @@ namespace de::uvok::badge
{
None,
Template,
- Indicator
+ Indicator,
+ TextAsQrCode
};
- typedef struct
+ struct BlePollResult
{
BleActionType action_type;
union {
uint8_t new_template;
DisplayIndicator new_indicator;
};
- } ble_poll_result_t;
+ std::string new_text;
- void ble_init(void);
- void ble_advertise(void);
- bool ble_is_active(void);
- ble_poll_result_t ble_poll(void);
+ static BlePollResult MakeTemplate(uint8_t val)
+ {
+ BlePollResult p{};
+ p.action_type = BleActionType::Template;
+ p.new_template = val;
+ return p;
+ }
+
+ static BlePollResult MakeText(const std::string &val)
+ {
+ BlePollResult p{};
+ p.action_type = BleActionType::TextAsQrCode;
+ p.new_text = val;
+ return p;
+ }
+
+ static BlePollResult MakeEmpty()
+ {
+ BlePollResult p{};
+ return p;
+ }
+
+ static BlePollResult MakeIndicator(DisplayIndicator ind)
+ {
+ BlePollResult p{};
+ p.action_type = BleActionType::Indicator;
+ p.new_indicator = ind;
+ return p;
+ }
+
+ private:
+ BlePollResult() : action_type(BleActionType::None), new_indicator(DisplayIndicator::None)
+ {
+ }
+ };
+
+ void ble_init();
+ void ble_advertise();
+ bool ble_is_active();
+ BlePollResult ble_poll();
void ble_set_image(uint8_t image);
} // namespace de::uvok::badge