This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to delete binding when using whitelist?

I'm using whitelist when bonded, but I want delete bonded then connect to anther device,.

But when scan again, whitelist_load is error. Try delete whitelist at the same time, The error still exists.

I use nRF5 SDK v16.0.0 with S132 SoftDevice v7.0.1.

// System soft reset: AT+BONDDEL\r
else if((length == 11) && (strncmp((char*)pBuffer, "AT+BONDDEL\r", 11) == 0))
{
	err_code = pm_whitelist_set(NULL, 0);
	APP_ERROR_CHECK(err_code);
	err_code = pm_peers_delete();
	APP_ERROR_CHECK(err_code);
	printf("AT:BONDDEL\r\n");
}

I found no entry PM_EVT_PEERS_DELETE_SUCCEEDED of pm_evt_handler. So I change below code replace, another error is appear.
"<warning> peer_manager_gcm: CAR char value couldn't be stored (error: NRF_ERROR_INVALID_PARAM). Reattempt will happen on the next connection."


// System soft reset: AT+BONDDEL\r\n
else if((length == 11) && (strncmp((char*)pBuffer, "AT+BONDDEL\r\n", 11) == 0))
{
//	err_code = pm_whitelist_set(NULL, 0);
//	APP_ERROR_CHECK(err_code);
//	err_code = pm_peers_delete();
//	APP_ERROR_CHECK(err_code);
	erase_bonds = true;
	scanning_start(&erase_bonds);
	erase_bonds = false;
	printf("AT:BONDDEL\r\n");
}

static void pm_evt_handler(pm_evt_t const * p_evt)
{
    pm_handler_on_pm_evt(p_evt);
    pm_handler_flash_clean(p_evt);

    switch (p_evt->evt_id)
    {
        case PM_EVT_PEERS_DELETE_SUCCEEDED:
            // Bonds are deleted. Start scanning.
		    printf("Bonds are deleted. Start scanning.");
            scan_start();
            break;
		case PM_EVT_CONN_SEC_CONFIG_REQ://重新连接
			{
				// Reject pairing request from an already bonded peer.
				pm_conn_sec_config_t conn_sec_config = {.allow_repairing = true};  
				//允许再次配对
				pm_conn_sec_config_reply(m_conn_handle, &conn_sec_config);
			}
			break;

        default:
            break;
    }
}


Best Regards!
John
Related