sandeepmistry / arduino-nRF5

Arduino Core for Nordic Semiconductor nRF5 based boards
Other
873 stars 278 forks source link

[Question] Saving value to storage #453

Closed jLynx closed 2 years ago

jLynx commented 3 years ago

Hi, I have a nRF51822 and I have a 10 byte value that I am wanting to save so it is persistent after the device has been turned off and on again. Is there a way to implement this?

TheLukaDragar commented 2 years ago

` / Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.

/** @file

include

include

include "nrf.h"

include "bsp.h"

include "app_uart.h"

include "app_error.h"

include "nordic_common.h"

define UART_TX_BUF_SIZE 256 /*< UART TX buffer size. /

define UART_RX_BUF_SIZE 1 /*< UART RX buffer size. /

void uart_error_handle(app_uart_evt_t * p_event) { if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR) { APP_ERROR_HANDLER(p_event->data.error_communication); } else if (p_event->evt_type == APP_UART_FIFO_ERROR) { APP_ERROR_HANDLER(p_event->data.error_code); } }

/* @brief Function for erasing a page in flash.

/* @brief Function for filling a page in flash with a value.

/**

/* @} / `

TheLukaDragar commented 2 years ago

found Nordic Fstorage option it worked i think tis is code ftom fstorage example

jLynx commented 2 years ago

Awesome, thanks for that

JAndrassy commented 2 years ago

why not use the Arduino library https://github.com/d00616/arduino-NVM ?

TheLukaDragar commented 2 years ago

Fstorage is new. If you look into that repos issues they are talking about implementning it.