uint32_t ble_central_bondmngr_init(ble_central_bondmngr_t * p_bm, ble_central_bondmngr_init_t * p_bm_init) { uint32_t err_code; p_bm->p_sec_params = p_bm_init->p_sec_params; bond_info.keyset.keys_periph.p_enc_key = &bond_info.enc_key; if (p_bm_init->delete_bonds) { err_code = ble_flash_page_erase(BLE_CENTRAL_BONDMNGR_PAGE_NUM); if (err_code != NRF_SUCCESS) return err_code; } else { uint8_t size_to_read = sizeof(bond_info)/sizeof(uint32_t); err_code = ble_flash_page_read(BLE_CENTRAL_BONDMNGR_PAGE_NUM, (uint32_t *) &bond_info, &size_to_read); if (err_code != NRF_ERROR_NOT_FOUND && err_code != NRF_SUCCESS) return err_code; printf("Restoring data from %d, %d...\r\n", BLE_CENTRAL_BONDMNGR_PAGE_NUM, BLE_CENTRAL_BONDMNGR_PAGE_NUM*NRF_FICR->CODEPAGESIZE); } print_address(&bond_info.addr); return NRF_SUCCESS; }
uint32_t ble_error_log_read(ble_error_log_data_t * error_log) { uint8_t error_log_size = CEIL_DIV(sizeof(ble_error_log_data_t), sizeof(uint32_t)); uint32_t err_code = NRF_SUCCESS; err_code = ble_flash_page_read(FLASH_PAGE_ERROR_LOG, (uint32_t *) error_log, &error_log_size); // If nothing is in flash; then return NRF_SUCCESS. if (err_code == NRF_ERROR_NOT_FOUND) { return NRF_SUCCESS; } if (err_code != NRF_SUCCESS) { return err_code; } if (!error_log->failure) { return NRF_SUCCESS; } nrf_gpio_pin_set(LOG_LED_PIN_NO); // Notify that a message exists in the log. while (error_log->failure && !m_ble_log_clear_flag) { // Put breakpoint, and read data, then log->failure=false; to continue in debug mode. // In application, define how to clear the error log, // e.g. read button 6, if pressed, then clear log and continue. } nrf_gpio_pin_clear(LOG_LED_PIN_NO); err_code = ble_flash_page_erase(FLASH_PAGE_ERROR_LOG); return err_code; }