@@ -198,7 +198,7 @@ ble_error_t nRF5xGap::startAdvertising(const GapAdvertisingParams ¶ms)
198
198
199
199
adv_para.p_whitelist = &whitelist;
200
200
#else
201
- err = updateWhiteAndIdentityListInStack (nRF5xGap::avdvertising_purpose );
201
+ err = updateWhiteAndIdentityListInStack (nRF5xGap::purpose_avdvertising );
202
202
203
203
if (err != BLE_ERROR_NONE) {
204
204
return (ble_error_t )err;
@@ -254,7 +254,7 @@ ble_error_t nRF5xGap::startRadioScan(const GapScanningParams &scanningParams)
254
254
scanParams.selective = scanningPolicyMode; /* *< If 1, ignore unknown devices (non whitelisted). */
255
255
scanParams.p_whitelist = &whitelist; /* *< Pointer to whitelist, NULL if none is given. */
256
256
#else
257
- uint32_t err = updateWhiteAndIdentityListInStack (nRF5xGap::scan_connect_purpose );
257
+ uint32_t err = updateWhiteAndIdentityListInStack (nRF5xGap::purpose_scan_connect );
258
258
259
259
if (err != BLE_ERROR_NONE) {
260
260
return (ble_error_t )err;
@@ -358,19 +358,20 @@ ble_error_t nRF5xGap::connect(const Address_t peerAddr,
358
358
scanParams.selective = scanningPolicyMode; /* *< If 1, ignore unknown devices (non whitelisted). */
359
359
scanParams.p_whitelist = &whitelist; /* *< Pointer to whitelist, NULL if none is given. */
360
360
#else
361
- uint32_t err = updateWhiteAndIdentityListInStack (nRF5xGap::scan_connect_purpose );
361
+ uint32_t err = updateWhiteAndIdentityListInStack (nRF5xGap::purpose_scan_connect );
362
362
363
363
if (err != BLE_ERROR_NONE) {
364
364
return (ble_error_t )err;
365
365
}
366
366
367
367
scanParams.use_whitelist = (whitelistAddressesSize) ? 1 : 0 ;
368
368
369
- if (addr.addr_type == ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE || addr.addr_type == ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE) {
369
+ if ((addr.addr_type == BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE)
370
+ || (addr.addr_type == BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE)) {
370
371
/* If a device is using Resolvable Private Addresses Section 1.3.2.2 (Core spec v4.2 volume 6 part B),
371
372
it shall also have an Identity Address that is either a Public or Random Static address type.”
372
- For connecting a static address must be provided by the application to the softdevice .
373
- The softdevice will resolve the address and connect to the right device if present . */
373
+ To establish a connection, a static address must be provided by the application to the SoftDevice .
374
+ The SoftDevice resolves the address and connects to the right device if it is available . */
374
375
addr.addr_id_peer = 1 ;
375
376
addr.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC;
376
377
} else {
@@ -1031,35 +1032,27 @@ ble_error_t nRF5xGap::generateStackWhitelist(ble_gap_whitelist_t &whitelist)
1031
1032
#if (NRF_SD_BLE_API_VERSION >= 3)
1032
1033
1033
1034
/* *
1034
- * Fuction for preparing setting of the whitelist- feature and identiti-reseolv- feature (privacy) for SoftDevice.
1035
+ * Function for preparing settings of the whitelist feature and the identity-resolving feature (privacy) for the SoftDevice.
1035
1036
*
1036
- * Gap::setWhitelist provide base for prepartion of this settings.
1037
- * This funtion matches resolvabele addreses (pased by Gap::setWhitelist) to IRK datas in boonds table.
1038
- * Therefore resovable addresses instead of being passed to the whitelist (intended to be passed to Softdevice)
1039
- * are passed to the identities list (intended to be passed to Softdevice).
1037
+ * Gap::setWhitelist provides the base for preparation of these settings.
1038
+ * This function matches resolvable addresses (passed by Gap::setWhitelist) to IRK data in bonds table.
1039
+ * Therefore resolvable addresses instead of being passed to the whitelist (intended to be passed to the Softdevice)
1040
+ * are passed to the identities list (intended to be passed to the Softdevice).
1040
1041
*
1041
1042
* @param[out] gapAdrHelper Reference to the struct for storing settings.
1042
1043
*/
1043
1044
1044
1045
ble_error_t nRF5xGap::getStackWhiteIdentityList (GapWhiteAndIdentityList_t &gapAdrHelper)
1045
1046
{
1046
- uint32_t peers_to_check = pm_peer_count ();
1047
1047
pm_peer_id_t peer_id;
1048
1048
1049
1049
ret_code_t ret;
1050
1050
1051
1051
pm_peer_data_bonding_t bond_data;
1052
- pm_peer_data_t peer_data;
1053
- uint32_t const buf_size = sizeof (bond_data);
1054
1052
1055
- memset (&peer_data, 0x00 , sizeof (peer_data));
1056
- peer_data.p_bonding_data = &bond_data;
1053
+ uint8_t irk_found[YOTTA_CFG_WHITELIST_MAX_SIZE];
1057
1054
1058
-
1059
-
1060
- uint8_t irk_fund[YOTTA_CFG_WHITELIST_MAX_SIZE];
1061
-
1062
- memset (irk_fund, 0x00 , sizeof (irk_fund));
1055
+ memset (irk_found, 0x00 , sizeof (irk_found));
1063
1056
1064
1057
1065
1058
gapAdrHelper.identities_cnt = 0 ;
@@ -1074,26 +1067,25 @@ ble_error_t nRF5xGap::getStackWhiteIdentityList(GapWhiteAndIdentityList_t &gapAd
1074
1067
* For every private resolvable address in the bond table check if
1075
1068
* there is maching address in th provided whitelist.
1076
1069
*/
1077
- while (( peer_id != PM_PEER_ID_INVALID) && (peers_to_check--) )
1070
+ while (peer_id != PM_PEER_ID_INVALID)
1078
1071
{
1079
1072
memset (&bond_data, 0x00 , sizeof (bond_data));
1080
1073
1081
1074
// Read peer data from flash.
1082
- ret = pds_peer_data_read (peer_id, PM_PEER_DATA_ID_BONDING,
1083
- &peer_data, &buf_size);
1075
+ ret = pm_peer_data_bonding_load (peer_id, &bond_data);
1084
1076
1085
1077
1086
1078
if ((ret == NRF_ERROR_NOT_FOUND) || (ret == NRF_ERROR_INVALID_PARAM))
1087
1079
{
1088
- // Peer data coulnd't be found in flash or peer ID is not valid.
1080
+ // Peer data could not be found in flash or peer ID is not valid.
1089
1081
return BLE_ERROR_UNSPECIFIED;
1090
1082
}
1091
1083
1092
1084
if ( bond_data.peer_ble_id .id_addr_info .addr_type == BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE)
1093
1085
{
1094
1086
for (uint8_t i = 0 ; i < whitelistAddressesSize; ++i)
1095
1087
{
1096
- if (!irk_fund [i])
1088
+ if (!irk_found [i])
1097
1089
{
1098
1090
if (whitelistAddresses[i].addr_type == BLEProtocol::AddressType::RANDOM_PRIVATE_RESOLVABLE)
1099
1091
{
@@ -1102,11 +1094,10 @@ ble_error_t nRF5xGap::getStackWhiteIdentityList(GapWhiteAndIdentityList_t &gapAd
1102
1094
if (securityManager.matchAddressAndIrk (&whitelistAddresses[i], &bond_data.peer_ble_id .id_info ))
1103
1095
{
1104
1096
// Copy data to the buffer.
1105
- memcpy (&gapAdrHelper.identity [i], &bond_data.peer_ble_id , sizeof (ble_gap_id_key_t ));
1106
- gapAdrHelper.pp_identities [i] = &gapAdrHelper.identity [i];
1097
+ memcpy (&gapAdrHelper.identities [i], &bond_data.peer_ble_id , sizeof (ble_gap_id_key_t ));
1107
1098
gapAdrHelper.identities_cnt ++;
1108
1099
1109
- irk_fund [i] = 1 ; // don't look at this address again
1100
+ irk_found [i] = 1 ; // don't look at this address again
1110
1101
}
1111
1102
}
1112
1103
}
@@ -1117,39 +1108,52 @@ ble_error_t nRF5xGap::getStackWhiteIdentityList(GapWhiteAndIdentityList_t &gapAd
1117
1108
peer_id = pm_next_peer_id_get (peer_id);
1118
1109
}
1119
1110
1120
- gapAdrHelper.addr_cnt = 0 ;
1111
+ gapAdrHelper.addrs_cnt = 0 ;
1121
1112
1122
1113
/* *
1123
- * Bulida whitelist from the rest of addresses (explicite addressess6 )
1114
+ * Build whitelist from the rest of addresses (explicit addresses )
1124
1115
*/
1125
1116
for (uint8_t i = 0 ; i < whitelistAddressesSize; ++i)
1126
1117
{
1127
- if (!irk_fund [i])
1118
+ if (!irk_found [i])
1128
1119
{
1129
- memcpy (&gapAdrHelper.addr [i], &bond_data.peer_ble_id .id_addr_info , sizeof (ble_gap_addr_t ));
1130
- gapAdrHelper.pp_addr [i] = &gapAdrHelper.addr [i];
1131
- gapAdrHelper.addr_cnt ++;
1120
+ memcpy (&gapAdrHelper.addrs [i], &whitelistAddresses[i], sizeof (ble_gap_addr_t ));
1121
+ gapAdrHelper.addrs_cnt ++;
1132
1122
}
1133
1123
}
1134
1124
1135
1125
return BLE_ERROR_NONE;
1136
1126
}
1137
1127
1138
- ble_error_t nRF5xGap::apllyWhiteIdentityList (GapWhiteAndIdentityList_t &gapAdrHelper)
1128
+ ble_error_t nRF5xGap::applyWhiteIdentityList (GapWhiteAndIdentityList_t &gapAdrHelper)
1139
1129
{
1140
1130
uint32_t retc;
1141
1131
1142
1132
if (gapAdrHelper.identities_cnt == 0 ) {
1143
1133
retc = sd_ble_gap_device_identities_set (NULL , NULL , 0 );
1144
1134
} else {
1145
- retc = sd_ble_gap_device_identities_set (gapAdrHelper.pp_identities , NULL /* Don't use local IRKs*/ ,gapAdrHelper.identities_cnt );
1135
+ ble_gap_id_key_t * pp_identities[YOTTA_CFG_IRK_TABLE_MAX_SIZE];
1136
+
1137
+ for (uint32_t i = 0 ; i < gapAdrHelper.identities_cnt ; ++i)
1138
+ {
1139
+ pp_identities[i] = &gapAdrHelper.identities [i];
1140
+ }
1141
+
1142
+ retc = sd_ble_gap_device_identities_set (pp_identities, NULL /* Don't use local IRKs*/ ,gapAdrHelper.identities_cnt );
1146
1143
}
1147
1144
1148
1145
if (retc == NRF_SUCCESS) {
1149
- if (gapAdrHelper.addr_cnt == 0 ) {
1146
+ if (gapAdrHelper.addrs_cnt == 0 ) {
1150
1147
retc = sd_ble_gap_whitelist_set (NULL , 0 );
1151
1148
} else {
1152
- retc = sd_ble_gap_whitelist_set (gapAdrHelper.pp_addr , gapAdrHelper.addr_cnt );
1149
+ ble_gap_addr_t * pp_addrs[YOTTA_CFG_IRK_TABLE_MAX_SIZE];
1150
+
1151
+ for (uint32_t i = 0 ; i < gapAdrHelper.addrs_cnt ; ++i)
1152
+ {
1153
+ pp_addrs[i] = &gapAdrHelper.addrs [i];
1154
+ }
1155
+
1156
+ retc = sd_ble_gap_whitelist_set (pp_addrs, gapAdrHelper.addrs_cnt );
1153
1157
}
1154
1158
}
1155
1159
@@ -1178,9 +1182,9 @@ ble_error_t nRF5xGap::updateWhiteAndIdentityListInStack(whiteAndIdentityListPurp
1178
1182
uint32_t err;
1179
1183
bool provide_settings;
1180
1184
1181
- if (purpose == nRF5xGap::avdvertising_purpose ) {
1185
+ if (purpose == nRF5xGap::purpose_avdvertising ) {
1182
1186
provide_settings = (advertisingPolicyMode != Gap::ADV_POLICY_IGNORE_WHITELIST) ? true : false ;
1183
- } else { // it must be nRF5xGap::scan_connect_purpose
1187
+ } else { // It must be nRF5xGap::purpose_scan_connect.
1184
1188
provide_settings = (scanningPolicyMode != Gap::SCAN_POLICY_IGNORE_WHITELIST) ? true : false ;
1185
1189
}
1186
1190
@@ -1193,11 +1197,11 @@ ble_error_t nRF5xGap::updateWhiteAndIdentityListInStack(whiteAndIdentityListPurp
1193
1197
return (ble_error_t )err;
1194
1198
}
1195
1199
} else {
1196
- whiteAndIdentityList.addr_cnt = 0 ;
1200
+ whiteAndIdentityList.addrs_cnt = 0 ;
1197
1201
whiteAndIdentityList.identities_cnt = 0 ;
1198
1202
}
1199
1203
1200
1204
1201
- return apllyWhiteIdentityList (whiteAndIdentityList);
1205
+ return applyWhiteIdentityList (whiteAndIdentityList);
1202
1206
}
1203
- #endif
1207
+ #endif
0 commit comments