14#include <goodisplay/gdey029T94.h>
17static const char*
TAG =
"BLE_PAIR_UI";
23 connHandle_ = connHandle;
25 timeoutMs_ = timeoutMs;
37 if (responded_)
return;
38 if (enteredAtMs_ == 0) {
42 if (nowMs - enteredAtMs_ >= timeoutMs_) {
43 LOG_W(
TAG,
"Pairing prompt timed out, rejecting");
62void BlePairingPromptView::respond(
bool accept) {
66 ble->respondToNumericComparison(connHandle_, accept);
68 LOG_I(
TAG,
"Pairing %s by user", accept ?
"accepted" :
"rejected");
77 auto* gfx =
static_cast<Gdey029T94*
>(
display->getNativeHandle());
80 constexpr int BOX_W = 240;
81 constexpr int BOX_H = 96;
82 const int boxX = (
display->getWidth() - BOX_W) / 2;
83 const int boxY = (
display->getHeight() - BOX_H) / 2;
87 gfx->setTextColor(EPD_BLACK);
90 gfx->setCursor(boxX + 14, boxY + 14);
91 gfx->print(
"BLE Pairing Request");
94 snprintf(codeBuf,
sizeof(codeBuf),
"%03lu %03lu",
95 (
unsigned long)(passkey_ / 1000), (
unsigned long)(passkey_ % 1000));
98 gfx->setCursor(boxX + 48, boxY + 36);
102 gfx->setCursor(boxX + 14, boxY + BOX_H - 16);
103 gfx->print(
"[Y] Accept [N] Reject");
CDC Log: logging over TinyUSB CDC and UART.
#define LOG_W(tag, fmt,...)
#define LOG_I(tag, fmt,...)
void onTick(uint32_t nowMs) override
void render(bool partial) override
void onEnter(void *context) override
void prepare(uint16_t connHandle, uint32_t passkey, uint32_t timeoutMs=30000)
InputResult onKey(char key) override
void clearDirty() override
static ViewStack & instance()
Returns singleton view-stack instance.
IDisplay * getDisplayInstance()
Returns lazily created singleton display instance.
IBluetoothController * getBluetoothControllerInstance()
Returns singleton Bluetooth stub when NimBLE is unavailable.
void drawDialogFrame(Gdey029T94 *gfx, int x, int y, int w, int h)
Draws a framed dialog box with double border.
Centralized key-code constants for cdc_views.
static constexpr char KEY_NO
Cancel / Back / Backspace.
static constexpr char KEY_YES
Confirm / OK / Save.