Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set/Reset on CHIPoBLEConState #4095

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/platform/ESP32/BLEManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,25 @@ class BLEManagerImpl final : public BLEManager,
uint16_t Allocated : 1;
uint16_t Subscribed : 1;
uint16_t Unused : 4;

void Set(uint16_t conId)
{
PendingIndBuf = nullptr;
ConId = conId;
MTU = 0;
Allocated = 1;
Subscribed = 0;
Unused = 0;
}
void Reset()
{
PendingIndBuf = nullptr;
ConId = BLE_CONNECTION_UNINITIALIZED;
MTU = 0;
Allocated = 0;
Subscribed = 0;
Unused = 0;
}
};

CHIPoBLEConState mCons[kMaxConnections];
Expand Down
10 changes: 2 additions & 8 deletions src/platform/ESP32/bluedroid/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,12 +1146,7 @@ BLEManagerImpl::CHIPoBLEConState * BLEManagerImpl::GetConnectionState(uint16_t c
{
if (freeIndex < kMaxConnections)
{
mCons[freeIndex].PendingIndBuf = nullptr;
mCons[freeIndex].ConId = conId;
mCons[freeIndex].MTU = 0;
mCons[freeIndex].Allocated = 1;
mCons[freeIndex].Subscribed = 0;
mCons[freeIndex].Unused = 0;
mCons[freeIndex].Set(conId);
return &mCons[freeIndex];
}

Expand All @@ -1167,8 +1162,7 @@ bool BLEManagerImpl::ReleaseConnectionState(uint16_t conId)
{
if (mCons[i].Allocated && mCons[i].ConId == conId)
{
mCons[i].PendingIndBuf = nullptr;
mCons[i].Allocated = 0;
mCons[i].Reset();
return true;
}
}
Expand Down