Skip to content

Commit 8bb9578

Browse files
committed
Fix backward compatability issue with remote charactertistic sorting
1 parent 28d49a0 commit 8bb9578

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/NimBLERemoteService.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,17 @@ int NimBLERemoteService::characteristicDiscCB(uint16_t conn_handle,
152152

153153
if (error->status == 0) {
154154
// insert in handle order
155+
auto pNewChar = new NimBLERemoteCharacteristic(pSvc, chr);
155156
for (auto it = pSvc->m_vChars.begin(); it != pSvc->m_vChars.end(); ++it) {
156157
if ((*it)->getHandle() > chr->def_handle) {
157-
pTaskData->m_pBuf = (*pSvc->m_vChars.insert(it, new NimBLERemoteCharacteristic(pSvc, chr)));
158+
pSvc->m_vChars.insert(it, pNewChar);
159+
pTaskData->m_pBuf = pNewChar;
158160
return 0;
159161
}
160162
}
161-
pTaskData->m_pBuf = pSvc->m_vChars.emplace_back(new NimBLERemoteCharacteristic(pSvc, chr));
163+
164+
pSvc->m_vChars.push_back(pNewChar);
165+
pTaskData->m_pBuf = pNewChar;
162166
return 0;
163167
}
164168

0 commit comments

Comments
 (0)