@@ -611,6 +611,7 @@ uint16_t NimBLEDevice::getMTU() {
611611 * @brief Gets the number of bonded peers stored
612612 */
613613int NimBLEDevice::getNumBonds () {
614+ # if MYNEWT_VAL(BLE_STORE_MAX_BONDS)
614615 ble_addr_t peer_id_addrs[MYNEWT_VAL (BLE_STORE_MAX_BONDS)];
615616 int num_peers, rc;
616617 rc = ble_store_util_bonded_peers (&peer_id_addrs[0 ], &num_peers, MYNEWT_VAL (BLE_STORE_MAX_BONDS));
@@ -619,6 +620,9 @@ int NimBLEDevice::getNumBonds() {
619620 }
620621
621622 return num_peers;
623+ # else
624+ return 0 ;
625+ # endif
622626}
623627
624628/* *
@@ -652,6 +656,7 @@ bool NimBLEDevice::deleteBond(const NimBLEAddress& address) {
652656 * @returns True if bonded.
653657 */
654658bool NimBLEDevice::isBonded (const NimBLEAddress& address) {
659+ # if MYNEWT_VAL(BLE_STORE_MAX_BONDS)
655660 ble_addr_t peer_id_addrs[MYNEWT_VAL (BLE_STORE_MAX_BONDS)];
656661 int num_peers, rc;
657662
@@ -666,7 +671,8 @@ bool NimBLEDevice::isBonded(const NimBLEAddress& address) {
666671 return true ;
667672 }
668673 }
669-
674+ # endif
675+ (void )address; // unused
670676 return false ;
671677}
672678
@@ -676,6 +682,7 @@ bool NimBLEDevice::isBonded(const NimBLEAddress& address) {
676682 * @returns NimBLEAddress of the found bonded peer or null address if not found.
677683 */
678684NimBLEAddress NimBLEDevice::getBondedAddress (int index) {
685+ # if MYNEWT_VAL(BLE_STORE_MAX_BONDS)
679686 ble_addr_t peer_id_addrs[MYNEWT_VAL (BLE_STORE_MAX_BONDS)];
680687 int num_peers, rc;
681688 rc = ble_store_util_bonded_peers (&peer_id_addrs[0 ], &num_peers, MYNEWT_VAL (BLE_STORE_MAX_BONDS));
@@ -684,6 +691,10 @@ NimBLEAddress NimBLEDevice::getBondedAddress(int index) {
684691 }
685692
686693 return NimBLEAddress (peer_id_addrs[index]);
694+ # else
695+ (void )index; // unused
696+ return NimBLEAddress{};
697+ # endif
687698}
688699# endif
689700
@@ -1264,10 +1275,17 @@ bool NimBLEDevice::startSecurity(uint16_t connHandle, int* rcPtr) {
12641275 * @return true if the passkey was injected successfully.
12651276 */
12661277bool NimBLEDevice::injectPassKey (const NimBLEConnInfo& peerInfo, uint32_t passkey) {
1278+ #if MYNEWT_VAL(BLE_SM_LEGACY)
12671279 ble_sm_io pkey{.action = BLE_SM_IOACT_INPUT, .passkey = passkey};
12681280 int rc = ble_sm_inject_io (peerInfo.getConnHandle (), &pkey);
12691281 NIMBLE_LOGD (LOG_TAG, " BLE_SM_IOACT_INPUT; ble_sm_inject_io result: %d" , rc);
12701282 return rc == 0 ;
1283+ #else
1284+ (void )peerInfo;
1285+ (void )passkey;
1286+ NIMBLE_LOGE (LOG_TAG, " Passkey entry not supported with current security settings" );
1287+ return false ;
1288+ #endif
12711289}
12721290
12731291/* *
@@ -1276,10 +1294,17 @@ bool NimBLEDevice::injectPassKey(const NimBLEConnInfo& peerInfo, uint32_t passke
12761294 * @param [in] accept Whether the user confirmed or declined the comparison.
12771295 */
12781296bool NimBLEDevice::injectConfirmPasskey (const NimBLEConnInfo& peerInfo, bool accept) {
1297+ #if MYNEWT_VAL(BLE_SM_SC)
12791298 ble_sm_io pkey{.action = BLE_SM_IOACT_NUMCMP, .numcmp_accept = accept};
12801299 int rc = ble_sm_inject_io (peerInfo.getConnHandle (), &pkey);
12811300 NIMBLE_LOGD (LOG_TAG, " BLE_SM_IOACT_NUMCMP; ble_sm_inject_io result: %d" , rc);
12821301 return rc == 0 ;
1302+ #else
1303+ (void )peerInfo;
1304+ (void )accept;
1305+ NIMBLE_LOGE (LOG_TAG, " Numeric comparison not supported with current security settings" );
1306+ return false ;
1307+ #endif
12831308}
12841309# endif // MYNEWT_VAL(BLE_ROLE_CENTRAL) || MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
12851310
0 commit comments