Firmware  0.4.1
Loading...
Searching...
No Matches
NVS

Non-volatile storage (NVS) is designed to store key-value pairs in flash. The firmware uses this memory type to store accessories, locomotives, and settings.

Initialization

init() is responsible for initializing the NVS memory during the boot phase. If the NVS partition is truncated for any reason, the entire memory is erased and then reinitialized. The default settings will be restored in this case.

Base

Base is a convenience wrapper over the NVS C-API and forms the basis of all NVS classes. The RAII idiom ensures that the desired namespace is opened in the constructor and that any write operations are committed in the destructor and the namespace is closed again.

A nested iterator type (Base::Iterator) ensures that the keys of the namespace can be iterated over.

Locos

Locos allows to store locomotives (i.e. mobile decoders) in a JSON format in the NVS namespace "locos". The decoder address is used as key, the JSON string represents the value. The conversion to and from JSON is handled internally by the ArduinoJson library. Getters and setters are overloaded and available in dcc::Address::value_type or std::string variants.

The two utility functions address2key() and key2address() can be used to convert a dcc::Address::value_type into a std::string (or vice versa).

Turnouts

Todo
not yet implemented

Accessories

Todo
not yet implemented

Settings

Settings stores various firmware preferences in the NVS namespace "settings". Most settings are either directly strings or integer types, all others (e.g. drv::out::track::CurrentLimit) are converted accordingly within the class. Each setting has a getter and a setter, the latter of which may perform various checks (e.g. value range).

The following table contains an overview of all currently available settings, their NVS key, value range and default.

Setting NVS Key Type Min Max Default
mDNS hostname under which the device appears (e.g. my-remise.local) sta_mdns Binary - - "remise"
Name of the network to connect to sta_ssid Binary - - ""
Password of the network to connect to sta_pass Binary - - ""
Name of the alternative network to connect to sta_alt_ssid Binary - - ""
Password of the alternative network to connect to sta_alt_pass Binary - - ""
IP address sta_ip Binary - - ""
IP address of the access point to connect to sta_netmask Binary - - ""
Range of IP addresses in the network sta_gateway Binary - - ""
Timeout for receiving HTTP requests (also used for USB) http_rx_timeout u8 5 60 5
Timeout for transmitting HTTP response http_tx_timeout u8 5 60 5
Display a query when leaving the page http_exit_msg u8 0 1 1
Current limit in DCC operation mode cur_lim u8 0 3 3
Current limit in DCC service mode cur_lim_serv u8 0 3 1
Time after which an overcurrent is considered a short circuit cur_sc_time u8 20 240 100
Duty cycle of the bug LED led_dc_bug u8 0 100 5
Duty cycle of the WiFi LED led_dc_wifi u8 0 100 50
Number of DCC preamble bits dcc_preamble u8 17 30 17
Duration of a DCC 1 bit dcc_bit1_dur u8 56 60 58
Duration of a DCC 0 bit dcc_bit0_dur u8 97 114 100
Duration of a BiDi bit during cutout (0=BiDi off) dcc_bidibit_dur u8 57 61 60
How a service mode verify is performed (bitwise, bytewise, or both) dcc_prog_type u8 0 3 3
Number of DCC reset packets at the start of the service mode programming sequence dcc_strtp_rs_pc u8 25 255 25
Number of DCC reset packets when continuing the service mode programming sequence dcc_cntn_rs_pc u8 3 64 6
Number of DCC programming packets in the service mode programming sequence dcc_prog_pc u8 2 64 7
Comparing bits to either 0 or 1 during a service mode verify dcc_verify_bit1 u8 0 1 1
DCC acknowledge pulse current (60mA according to S-9.2.3) dcc_ack_cur u8 10 250 50
DCC locos flags dcc_loco_flags - - 226
DCC accessory flags dcc_accy_flags - - 4
Previous Next
Memory HW Reference