Firmware  0.0.0
Loading...
Searching...
No Matches
Memory

This module takes care of all used memory in the firmware. Currently, this only includes the initialization and maintenance of the NVS storage.

Initialization

init() initializes all memory types used. Currently this is only NVS.

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

nvs::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

nvs::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 (nvs::Base::Iterator) ensures that the keys of the namespace can be iterated over.

Accessories

Todo
not yet implemented

Locos

nvs::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 nvs::Locos::address2key() and nvs::Locos::key2address() are also part of this class. They can be used to convert a dcc::Address::value_type into a std::string (or vice versa).

Settings

nvs::Settings stores various firmware preferences in the NVS namespace "settings". Most settings are either directly strings or integer types, all others (e.g. 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 - - ""
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
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
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
Number of MDU preamble bits mdu_preamble u8 14 30 14
Number of MDU ackreq bits mdu_ackreq u8 10 30 10
Previous Next
MDU OTA