Add logic session skeleton
This commit is contained in:
57
KeyBorad/KeyBorad/LOGIC/Lgc_Session.cpp
Normal file
57
KeyBorad/KeyBorad/LOGIC/Lgc_Session.cpp
Normal 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;
|
||||||
|
}
|
||||||
18
KeyBorad/KeyBorad/LOGIC/Lgc_Session.h
Normal file
18
KeyBorad/KeyBorad/LOGIC/Lgc_Session.h
Normal 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);
|
||||||
Reference in New Issue
Block a user