Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Donald Chen
pc-ble-driver-sd_api_v6
Commits
692e835b
Commit
692e835b
authored
Oct 04, 2017
by
Chun Fan
Browse files
Fixed merge conflict in app_ble_gap_sec_keys.cpp in v5
parent
2b4194f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sd_api_v5/sdk/custom/app_ble_gap_sec_keys.cpp
View file @
692e835b
...
...
@@ -51,20 +51,10 @@
#include "nrf_error.h"
#include <stddef.h>
// C++ code
#include "adapter.h"
#include <map>
#include <vector>
#include <thread>
#include <mutex>
#include <boost/thread/tss.hpp>
typedef
std
::
map
<
uint16_t
,
ser_ble_gap_app_keyset_t
*>
connhandle_keyset_t
;
ser_ble_gap_app_keyset_t
m_app_keys_table
[
SER_MAX_CONNECTIONS
];
// Map with context, each with a set of conn_handle and each conn_handle a ser_ble_gap_app_keyset_t*
std
::
map
<
void
*
,
connhandle_keyset_t
*>
m_app_keys_table
;
void
*
current_context
=
nullptr
;
std
::
mutex
current_context_mutex
;
...
...
@@ -82,66 +72,56 @@ void app_ble_gap_sec_context_root_release()
uint32_t
app_ble_gap_sec_context_create
(
uint16_t
conn_handle
,
uint32_t
*
p_index
)
{
if
(
current_context
==
nullptr
)
return
NRF_ERROR_INVALID_DATA
;
auto
tempRootContext
=
m_app_keys_table
.
find
(
current_context
);
auto
keyset
=
new
ser_ble_gap_app_keyset_t
();
// If current context is not found we have to add it
if
(
tempRootContext
==
m_app_keys_table
.
end
())
{
auto
connectionAndKeyset
=
new
std
::
map
<
uint16_t
,
ser_ble_gap_app_keyset_t
*>
{
{
conn_handle
,
keyset
}
};
uint32_t
err_code
=
NRF_ERROR_NO_MEM
;
uint32_t
i
;
m_app_keys_table
.
insert
(
std
::
make_pair
(
current_context
,
connectionAndKeyset
));
}
else
for
(
i
=
0
;
i
<
SER_MAX_CONNECTIONS
;
i
++
)
{
auto
connHandleMap
=
tempRootContext
->
second
;
auto
connHandle
=
connHandleMap
->
find
(
conn_handle
);
// If connection handle does not exist from before
// we create a new ser_ble_gap_app_keyset_t for the connnection handle
if
(
connHandle
!=
connHandleMap
->
end
())
if
(
!
m_app_keys_table
[
i
].
conn_active
)
{
delete
connHandle
->
second
;
connHandleMap
->
erase
(
conn_handle
);
m_app_keys_table
[
i
].
conn_active
=
1
;
m_app_keys_table
[
i
].
conn_handle
=
conn_handle
;
*
p_index
=
i
;
err_code
=
NRF_SUCCESS
;
break
;
}
connHandleMap
->
insert
(
std
::
make_pair
(
conn_handle
,
keyset
));
}
//TODO: insert real index
*
p_index
=
0
;
return
NRF_SUCCESS
;
return
err_code
;
}
uint32_t
app_ble_gap_sec_context_destroy
(
uint16_t
conn_handle
)
{
auto
tempAdapter
=
m_app_keys_table
.
find
(
current_context
)
;
if
(
tempAdapter
==
m_app_keys_table
.
end
())
return
NRF_ERROR_NOT_FOUND
;
uint32_t
err_code
=
NRF_ERROR_NOT_FOUND
;
uint32_t
i
;
auto
connHandleMap
=
tempAdapter
->
second
;
auto
connHandle
=
connHandleMap
->
find
(
conn_handle
);
if
(
connHandle
==
connHandleMap
->
end
())
return
NRF_ERROR_NOT_FOUND
;
delete
connHandle
->
second
;
// Delete the ser_ble_gap_app_keyset_t
connHandleMap
->
erase
(
conn_handle
);
for
(
i
=
0
;
i
<
SER_MAX_CONNECTIONS
;
i
++
)
{
if
(
m_app_keys_table
[
i
].
conn_handle
==
conn_handle
)
{
m_app_keys_table
[
i
].
conn_active
=
0
;
err_code
=
NRF_SUCCESS
;
break
;
}
}
return
NRF_SUCCESS
;
return
err_code
;
}
uint32_t
app_ble_gap_sec_context_find
(
uint16_t
conn_handle
,
uint32_t
*
p_index
)
{
auto
tempAdapter
=
m_app_keys_table
.
find
(
current_context
)
;
if
(
tempAdapter
==
m_app_keys_table
.
end
())
return
NRF_ERROR_NOT_FOUND
;
uint32_t
err_code
=
NRF_ERROR_NOT_FOUND
;
uint32_t
i
;
auto
connHandleMap
=
tempAdapter
->
second
;
auto
connHandle
=
connHandleMap
->
find
(
conn_handle
);
for
(
i
=
0
;
i
<
SER_MAX_CONNECTIONS
;
i
++
)
{
if
(
(
m_app_keys_table
[
i
].
conn_handle
==
conn_handle
)
&&
(
m_app_keys_table
[
i
].
conn_active
==
1
)
)
{
*
p_index
=
i
;
err_code
=
NRF_SUCCESS
;
break
;
}
}
if
(
connHandle
==
connHandleMap
->
end
())
return
NRF_ERROR_NOT_FOUND
;
//TODO: insert real index
*
p_index
=
0
;
return
NRF_SUCCESS
;
return
err_code
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment