Add logic session skeleton

This commit is contained in:
2026-04-11 08:36:45 +08:00
parent 61d826363b
commit ed75b23ab7
2 changed files with 75 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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);