From 62dbcbfc953a36202d96466563a8e71b8bd4ff65 Mon Sep 17 00:00:00 2001 From: "James A. Jerkins" Date: Sat, 30 Oct 2021 13:02:39 -0500 Subject: Connect and bond with a passkey This commit adds the following: Passkey pairing - passkey is displayed on watch Swipe down to clear passkey screen Connection encryption Connection bonding Automatic reconnects to a bonded peripheral Trusted device on Android Note that persisting the bond between reboots is NOT included in this commit. Therefore, rebooting the watch will cause reconnect failures. You must delete the bond from the phone to reconnect/pair. --- src/displayapp/screens/PassKey.cpp | 17 +++++++++++++++++ src/displayapp/screens/PassKey.h | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/displayapp/screens/PassKey.cpp create mode 100644 src/displayapp/screens/PassKey.h (limited to 'src/displayapp/screens') diff --git a/src/displayapp/screens/PassKey.cpp b/src/displayapp/screens/PassKey.cpp new file mode 100644 index 00000000..66bf0c24 --- /dev/null +++ b/src/displayapp/screens/PassKey.cpp @@ -0,0 +1,17 @@ +#include "PassKey.h" +#include "displayapp/DisplayApp.h" + +using namespace Pinetime::Applications::Screens; + +PassKey::PassKey(Pinetime::Applications::DisplayApp* app, uint32_t key) : Screen(app) { + lpasskey = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(lpasskey, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFF00)); + lv_obj_set_style_local_text_font(lpasskey, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_label_set_text_fmt(lpasskey, "%06u", key); + lv_obj_align(lpasskey, nullptr, LV_ALIGN_CENTER, 0, -20); +} + +PassKey::~PassKey() { + lv_obj_clean(lv_scr_act()); +} + diff --git a/src/displayapp/screens/PassKey.h b/src/displayapp/screens/PassKey.h new file mode 100644 index 00000000..34e0d593 --- /dev/null +++ b/src/displayapp/screens/PassKey.h @@ -0,0 +1,20 @@ +#pragma once + +#include "Screen.h" +#include + +namespace Pinetime { + namespace Applications { + namespace Screens { + + class PassKey : public Screen { + public: + PassKey(DisplayApp* app, uint32_t key); + ~PassKey() override; + + private: + lv_obj_t* lpasskey; + }; + } + } +} -- cgit v1.2.3 From 1e4130a9cfe6e1385d83d93e544d1e1cd79f11f8 Mon Sep 17 00:00:00 2001 From: "James A. Jerkins" Date: Mon, 1 Nov 2021 15:12:25 -0500 Subject: Fix for passkey screen scramble When a passkey is displayed, screen on or off, and another passkey is displayed the screen may become scrambled. Fix the issue by insuring the whole screen is drawn every time. --- src/displayapp/DisplayApp.cpp | 6 +++--- src/displayapp/screens/PassKey.cpp | 17 ++++++++++++----- src/displayapp/screens/PassKey.h | 3 ++- 3 files changed, 17 insertions(+), 9 deletions(-) (limited to 'src/displayapp/screens') diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 08a76467..0a675c8f 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -215,6 +215,9 @@ void DisplayApp::Refresh() { } else { LoadApp(Apps::Alarm, DisplayApp::FullRefreshDirections::None); } + case Messages::ShowPairingKey: + LoadApp(Apps::PassKey, DisplayApp::FullRefreshDirections::Up); + break; case Messages::TouchEvent: { if (state != States::Running) { break; @@ -289,9 +292,6 @@ void DisplayApp::Refresh() { // Added to remove warning // What should happen here? break; - case Messages::ShowPairingKey: - LoadApp(Apps::PassKey, DisplayApp::FullRefreshDirections::Up); - break; } } diff --git a/src/displayapp/screens/PassKey.cpp b/src/displayapp/screens/PassKey.cpp index 66bf0c24..9e43a541 100644 --- a/src/displayapp/screens/PassKey.cpp +++ b/src/displayapp/screens/PassKey.cpp @@ -4,11 +4,18 @@ using namespace Pinetime::Applications::Screens; PassKey::PassKey(Pinetime::Applications::DisplayApp* app, uint32_t key) : Screen(app) { - lpasskey = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(lpasskey, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFF00)); - lv_obj_set_style_local_text_font(lpasskey, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); - lv_label_set_text_fmt(lpasskey, "%06u", key); - lv_obj_align(lpasskey, nullptr, LV_ALIGN_CENTER, 0, -20); + passkeyLabel = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(passkeyLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFF00)); + lv_obj_set_style_local_text_font(passkeyLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_label_set_text_fmt(passkeyLabel, "%06u", key); + lv_obj_align(passkeyLabel, nullptr, LV_ALIGN_CENTER, 0, -20); + + backgroundLabel = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_click(backgroundLabel, true); + lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); + lv_obj_set_size(backgroundLabel, 240, 240); + lv_obj_set_pos(backgroundLabel, 0, 0); + lv_label_set_text(backgroundLabel, ""); } PassKey::~PassKey() { diff --git a/src/displayapp/screens/PassKey.h b/src/displayapp/screens/PassKey.h index 34e0d593..16e72a3c 100644 --- a/src/displayapp/screens/PassKey.h +++ b/src/displayapp/screens/PassKey.h @@ -13,7 +13,8 @@ namespace Pinetime { ~PassKey() override; private: - lv_obj_t* lpasskey; + lv_obj_t* passkeyLabel; + lv_obj_t* backgroundLabel; }; } } -- cgit v1.2.3