Skip to content

Commit 707ff3a

Browse files
adding a function to get the dafault initialization values for NetworkSetting
1 parent 5c0c6da commit 707ff3a

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

src/settings/settings.h

+2
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,5 @@ namespace models {
122122
};
123123
};
124124
}
125+
126+
#include "settings_default.h"

src/settings/settings_default.h

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#pragma once
2+
#include "settings.h"
3+
4+
namespace models {
5+
6+
/*
7+
* if the cpp version is older than cpp14 then a constexpr function cannot include
8+
* other than a simple return statement, thsu we can define it only as inline
9+
*/
10+
#if __cplusplus > 201103L
11+
constexpr NetworkSetting settingsDefault(NetworkAdapter type) {
12+
#else
13+
inline NetworkSetting settingsDefault(NetworkAdapter type) {
14+
#endif
15+
16+
NetworkSetting res = {};
17+
18+
switch(type) {
19+
#if defined(BOARD_HAS_WIFI)
20+
case NetworkAdapter::WIFI: // nothing todo, default optional values are fine with 0
21+
break;
22+
#endif //defined(BOARD_HAS_WIFI)
23+
24+
#if defined(BOARD_HAS_NB)
25+
case NetworkAdapter::NB: // nothing todo, default optional values are fine with 0
26+
break;
27+
#endif //defined(BOARD_HAS_NB)
28+
29+
#if defined(BOARD_HAS_GSM)
30+
case NetworkAdapter::GSM: // nothing todo, default optional values are fine with 0
31+
break;
32+
#endif //defined(BOARD_HAS_GSM)
33+
34+
#if defined(BOARD_HAS_CELLULAR)
35+
case NetworkAdapter::CELL: // nothing todo, default optional values are fine with 0
36+
break;
37+
#endif //defined(BOARD_HAS_CELLULAR)
38+
39+
#if defined(BOARD_HAS_ETHERNET)
40+
case NetworkAdapter::ETHERNET:
41+
res.eth.timeout = 15000;
42+
res.eth.response_timeout = 4000;
43+
break;
44+
#endif //defined(BOARD_HAS_ETHERNET)
45+
46+
#if defined(BOARD_HAS_CATM1_NBIOT)
47+
case NetworkAdapter::CATM1:
48+
res.catm1.rat = 7; // CATM1
49+
res.catm1.band = 0x04 | 0x80000 | 0x40000; // BAND_3 | BAND_20 | BAND_19
50+
break;
51+
#endif //defined(BOARD_HAS_CATM1_NBIOT)
52+
53+
#if defined(BOARD_HAS_LORA)
54+
case LORA:
55+
res.lora.band = 5; // _lora_band::EU868
56+
res.lora.channelMask[0] = '\0';
57+
res.lora.deviceClass = 'A'; // _lora_class::CLASS_A
58+
break;
59+
#endif //defined(BOARD_HAS_LORA)
60+
}
61+
62+
return res;
63+
}
64+
}

0 commit comments

Comments
 (0)