Hi,
I am trying to store a buffer which i collect from ble connection. I have tried sd_flash functions first. I could not found any examples so page number or addresses might be wrong.
So i tried to test it with very easy code. These lines are in main function after all service and other Initializations.
Fullscreen
1
2
3
4
5
6
7
uint32_t test_buffer = 1;
uint32_t test_buffer2 = 0;
sd_flash_page_erase(0);
sd_flash_write((uint32_t *)0, &test_buffer, 1);
memcpy(&test_buffer2, (uint32_t *)0x3e000, 4);
Neither erase or write is working.
// where can i found the document about pages to erase and write ?
So i tried flash_fstorage example
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
static void nus_data_handler(ble_nus_evt_t * p_evt)
{
uint8_t temp_buffer[50] = {0};
uint32_t test_buffer;
uint32_t ab = 2;
ret_code_t rc;
if (p_evt->type == BLE_NUS_EVT_RX_DATA)
{
memcpy(temp_buffer, p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);
temp_buffer[p_evt->params.rx_data.length] = '\0';
NRF_LOG_INFO("%s", temp_buffer);
if(memcmp(temp_buffer, "123", 3) == 0)
{
// passkey_len = p_evt->params.rx_data.length - 3;
NRF_LOG_INFO("Writing \"%x\" to flash.", ab);
rc = nrf_fstorage_write(&fstorage, 0x3e100, &ab, sizeof(ab), NULL);
APP_ERROR_CHECK(rc);
wait_for_flash_ready(&fstorage);
But device can not even any log. I did everything according to the example. If i commenct out rc = nrf_fstorage_write(&fstorage, 0x3e100, &ab, sizeof(ab), NULL); i get all logs.