Align GATT transport interface
This commit is contained in:
@@ -5,7 +5,7 @@ QVector<Dri_Gatt_Struct_PortInfo> Dri_Gatt_Enum()
|
||||
return {};
|
||||
}
|
||||
|
||||
void Dri_Gatt_Deinit(Dri_Gatt_Struct_Port* p_Port)
|
||||
void Dri_Gatt_Close(Dri_Gatt_Struct_Port* p_Port)
|
||||
{
|
||||
if (p_Port == nullptr)
|
||||
{
|
||||
@@ -15,22 +15,33 @@ void Dri_Gatt_Deinit(Dri_Gatt_Struct_Port* p_Port)
|
||||
*p_Port = Dri_Gatt_Struct_Port();
|
||||
}
|
||||
|
||||
bool Dri_Gatt_Init(Dri_Gatt_Struct_Port* p_Port)
|
||||
bool Dri_Gatt_Open(
|
||||
Dri_Gatt_Struct_Port* p_Port,
|
||||
const QString& DeviceAddress,
|
||||
const Dri_Gatt_Struct_OpenConfig&)
|
||||
{
|
||||
if (p_Port == nullptr)
|
||||
if ((p_Port == nullptr) || DeviceAddress.trimmed().isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Dri_Gatt_Deinit(p_Port);
|
||||
Dri_Gatt_Close(p_Port);
|
||||
p_Port->IsOpened = true;
|
||||
p_Port->DeviceAddress = DeviceAddress.trimmed();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Dri_Gatt_Read(Dri_Gatt_Struct_Port* p_Port, QByteArray& ByteArray)
|
||||
bool Dri_Gatt_ReadBytes(
|
||||
Dri_Gatt_Struct_Port* p_Port,
|
||||
QByteArray* p_ByteArray,
|
||||
int)
|
||||
{
|
||||
ByteArray.clear();
|
||||
if (p_ByteArray != nullptr)
|
||||
{
|
||||
p_ByteArray->clear();
|
||||
}
|
||||
|
||||
if ((p_Port == nullptr) || !p_Port->IsOpened)
|
||||
if ((p_Port == nullptr) || (p_ByteArray == nullptr) || !p_Port->IsOpened)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -38,7 +49,10 @@ bool Dri_Gatt_Read(Dri_Gatt_Struct_Port* p_Port, QByteArray& ByteArray)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Dri_Gatt_Write(Dri_Gatt_Struct_Port* p_Port, const QByteArray& ByteArray)
|
||||
bool Dri_Gatt_WriteBytes(
|
||||
Dri_Gatt_Struct_Port* p_Port,
|
||||
const QByteArray& ByteArray,
|
||||
int)
|
||||
{
|
||||
if ((p_Port == nullptr) || !p_Port->IsOpened)
|
||||
{
|
||||
|
||||
@@ -10,15 +10,27 @@ struct Dri_Gatt_Struct_PortInfo
|
||||
QString DeviceAddress;
|
||||
};
|
||||
|
||||
struct Dri_Gatt_Struct_OpenConfig
|
||||
{
|
||||
};
|
||||
|
||||
struct Dri_Gatt_Struct_Port
|
||||
{
|
||||
bool IsOpened = false;
|
||||
QString DeviceAddress;
|
||||
QByteArray ReadBuffer;
|
||||
};
|
||||
|
||||
QVector<Dri_Gatt_Struct_PortInfo> Dri_Gatt_Enum();
|
||||
void Dri_Gatt_Deinit(Dri_Gatt_Struct_Port* p_Port);
|
||||
bool Dri_Gatt_Init(Dri_Gatt_Struct_Port* p_Port);
|
||||
bool Dri_Gatt_Read(Dri_Gatt_Struct_Port* p_Port, QByteArray& ByteArray);
|
||||
bool Dri_Gatt_Write(Dri_Gatt_Struct_Port* p_Port, const QByteArray& ByteArray);
|
||||
void Dri_Gatt_Close(Dri_Gatt_Struct_Port* p_Port);
|
||||
bool Dri_Gatt_Open(
|
||||
Dri_Gatt_Struct_Port* p_Port,
|
||||
const QString& DeviceAddress,
|
||||
const Dri_Gatt_Struct_OpenConfig& Config);
|
||||
bool Dri_Gatt_ReadBytes(
|
||||
Dri_Gatt_Struct_Port* p_Port,
|
||||
QByteArray* p_ByteArray,
|
||||
int TimeoutMs);
|
||||
bool Dri_Gatt_WriteBytes(
|
||||
Dri_Gatt_Struct_Port* p_Port,
|
||||
const QByteArray& ByteArray,
|
||||
int TimeoutMs);
|
||||
|
||||
Reference in New Issue
Block a user