From ed75b23ab712a4af752b50575930635cd3dbd6fc Mon Sep 17 00:00:00 2001 From: stli Date: Sat, 11 Apr 2026 08:36:45 +0800 Subject: [PATCH] Add logic session skeleton --- KeyBorad/KeyBorad/LOGIC/Lgc_Session.cpp | 57 +++++++++++++++++++++++++ KeyBorad/KeyBorad/LOGIC/Lgc_Session.h | 18 ++++++++ 2 files changed, 75 insertions(+) create mode 100644 KeyBorad/KeyBorad/LOGIC/Lgc_Session.cpp create mode 100644 KeyBorad/KeyBorad/LOGIC/Lgc_Session.h diff --git a/KeyBorad/KeyBorad/LOGIC/Lgc_Session.cpp b/KeyBorad/KeyBorad/LOGIC/Lgc_Session.cpp new file mode 100644 index 0000000..d7509fd --- /dev/null +++ b/KeyBorad/KeyBorad/LOGIC/Lgc_Session.cpp @@ -0,0 +1,57 @@ +#include "LOGIC/Lgc_Session.h" + +void Lgc_Session_Init(Lgc_Session* p_Session) +{ + if (p_Session == nullptr) + { + return; + } + + *p_Session = Lgc_Session(); +} + +void Lgc_Session_Close(Lgc_Session* p_Session) +{ + if (p_Session == nullptr) + { + return; + } + + Dri_Cdc_Deinit(&p_Session->CdcPort); + Dri_Gatt_Deinit(&p_Session->GattPort); + p_Session->IsStarted = false; +} + +bool Lgc_Session_TryStartCdc( + Lgc_Session* p_Session, + const Dri_Cdc_Struct_InitConfig& Config) +{ + if (p_Session == nullptr) + { + return false; + } + + if (Dri_Cdc_Init(&p_Session->CdcPort, Config)) + { + p_Session->IsStarted = true; + return true; + } + + return false; +} + +bool Lgc_Session_TryStartGatt(Lgc_Session* p_Session) +{ + if (p_Session == nullptr) + { + return false; + } + + if (Dri_Gatt_Init(&p_Session->GattPort)) + { + p_Session->IsStarted = true; + return true; + } + + return false; +} diff --git a/KeyBorad/KeyBorad/LOGIC/Lgc_Session.h b/KeyBorad/KeyBorad/LOGIC/Lgc_Session.h new file mode 100644 index 0000000..95b1eee --- /dev/null +++ b/KeyBorad/KeyBorad/LOGIC/Lgc_Session.h @@ -0,0 +1,18 @@ +#pragma once + +#include "DRI/Dri_Cdc.h" +#include "DRI/GATT/Dri_Gatt.h" + +struct Lgc_Session +{ + Dri_Cdc_Struct_Port CdcPort; + Dri_Gatt_Struct_Port GattPort; + bool IsStarted = false; +}; + +void Lgc_Session_Init(Lgc_Session* p_Session); +void Lgc_Session_Close(Lgc_Session* p_Session); +bool Lgc_Session_TryStartCdc( + Lgc_Session* p_Session, + const Dri_Cdc_Struct_InitConfig& Config); +bool Lgc_Session_TryStartGatt(Lgc_Session* p_Session);