From 73e134d0b62c6ad7f9d60a4187bbab112d582bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Mon, 9 Apr 2018 22:23:29 +0200 Subject: [PATCH] cleaned up nordic config --- framework/system_settings.c | 13 ++++++------- platform/cfg_utils.c | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/framework/system_settings.c b/framework/system_settings.c index 936bc3d..affead3 100644 --- a/framework/system_settings.c +++ b/framework/system_settings.c @@ -200,19 +200,18 @@ void systemsettings_build_ini(IniWriter *iw) iw_comment(iw, "nRF24L01+ radio"); iw_entry_s(iw, "com-nrf", str_yn(SystemSettings.use_comm_nordic)); - iw_comment(iw, "nRF channel"); + iw_comment(iw, "Radio channel (0-125)"); iw_entry_d(iw, "nrf-channel", SystemSettings.nrf_channel); - iw_comment(iw, "nRF network ID (hex, 4 bytes, little-endian)"); - iw_entry(iw, "nrf-network", "%02X-%02X-%02X-%02X", + iw_comment(iw, "Network prefix (hex, 4 bytes)"); + iw_entry(iw, "nrf-network", "%02X:%02X:%02X:%02X", SystemSettings.nrf_network[0], SystemSettings.nrf_network[1], SystemSettings.nrf_network[2], SystemSettings.nrf_network[3]); - iw_comment(iw, "nRF node address (hex, 1 byte, > 0)"); - iw_entry(iw, "nrf-address", "0x%02X", - SystemSettings.nrf_address); + iw_comment(iw, "Node address (1-255)"); + iw_entry(iw, "nrf-address", "%d", (int)SystemSettings.nrf_address); // those aren't implement yet, don't tease the user // TODO show pin-out, extra settings if applicable @@ -285,7 +284,7 @@ bool systemsettings_load_ini(const char *restrict key, const char *restrict valu } if (streq(key, "nrf-address")) { - cfg_hex_parse(&SystemSettings.nrf_address, 1, value, &suc); + SystemSettings.nrf_address = cfg_u8_parse(value, &suc); } if (streq(key, "nrf-network")) { diff --git a/platform/cfg_utils.c b/platform/cfg_utils.c index e580e61..83dce48 100644 --- a/platform/cfg_utils.c +++ b/platform/cfg_utils.c @@ -311,7 +311,7 @@ void cfg_hex_parse(uint8_t *dest, uint32_t count, const char *value, bool *suc) if (v != 0) value++; uint8_t nibble = 0; - if (v == ' ' || v == '.' || v == '-' || v == ':') { + if (v == ' ' || v == '.' || v == ',' || v == '-' || v == ':') { continue; // junk } else if (v >= '0' && v <= '9') {