Align GATT transport interface
This commit is contained in:
@@ -5,7 +5,7 @@ QVector<Dri_Gatt_Struct_PortInfo> Dri_Gatt_Enum()
|
|||||||
return {};
|
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)
|
if (p_Port == nullptr)
|
||||||
{
|
{
|
||||||
@@ -15,22 +15,33 @@ void Dri_Gatt_Deinit(Dri_Gatt_Struct_Port* p_Port)
|
|||||||
*p_Port = Dri_Gatt_Struct_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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dri_Gatt_Deinit(p_Port);
|
Dri_Gatt_Close(p_Port);
|
||||||
|
p_Port->IsOpened = true;
|
||||||
|
p_Port->DeviceAddress = DeviceAddress.trimmed();
|
||||||
return false;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -38,7 +49,10 @@ bool Dri_Gatt_Read(Dri_Gatt_Struct_Port* p_Port, QByteArray& ByteArray)
|
|||||||
return false;
|
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)
|
if ((p_Port == nullptr) || !p_Port->IsOpened)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,15 +10,27 @@ struct Dri_Gatt_Struct_PortInfo
|
|||||||
QString DeviceAddress;
|
QString DeviceAddress;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Dri_Gatt_Struct_OpenConfig
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
struct Dri_Gatt_Struct_Port
|
struct Dri_Gatt_Struct_Port
|
||||||
{
|
{
|
||||||
bool IsOpened = false;
|
bool IsOpened = false;
|
||||||
QString DeviceAddress;
|
QString DeviceAddress;
|
||||||
QByteArray ReadBuffer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QVector<Dri_Gatt_Struct_PortInfo> Dri_Gatt_Enum();
|
QVector<Dri_Gatt_Struct_PortInfo> Dri_Gatt_Enum();
|
||||||
void Dri_Gatt_Deinit(Dri_Gatt_Struct_Port* p_Port);
|
void Dri_Gatt_Close(Dri_Gatt_Struct_Port* p_Port);
|
||||||
bool Dri_Gatt_Init(Dri_Gatt_Struct_Port* p_Port);
|
bool Dri_Gatt_Open(
|
||||||
bool Dri_Gatt_Read(Dri_Gatt_Struct_Port* p_Port, QByteArray& ByteArray);
|
Dri_Gatt_Struct_Port* p_Port,
|
||||||
bool Dri_Gatt_Write(Dri_Gatt_Struct_Port* p_Port, const QByteArray& ByteArray);
|
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);
|
||||||
|
|||||||
@@ -32,6 +32,17 @@ Design notes:
|
|||||||
- keeps the implementation small for now
|
- keeps the implementation small for now
|
||||||
- avoids mixing GATT transport with logic concerns
|
- avoids mixing GATT transport with logic concerns
|
||||||
|
|
||||||
|
Implemented behavior:
|
||||||
|
|
||||||
|
- keep the same surface shape as CDC:
|
||||||
|
- `Enum`
|
||||||
|
- `Open`
|
||||||
|
- `Close`
|
||||||
|
- `ReadBytes`
|
||||||
|
- `WriteBytes`
|
||||||
|
- stay transport-only
|
||||||
|
- keep real BLE implementation for a later node
|
||||||
|
|
||||||
### Node 2: CDC transport cleanup
|
### Node 2: CDC transport cleanup
|
||||||
|
|
||||||
Files updated in this step:
|
Files updated in this step:
|
||||||
|
|||||||
Reference in New Issue
Block a user