Skip to content

Commit 73aa094

Browse files
defining interface settings in a struct
1 parent c72dfdb commit 73aa094

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

src/settings/settings.h

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
* This file is part of ArduinoIoTCloud.
3+
*
4+
* Copyright 2019 ARDUINO SA (http://www.arduino.cc/)
5+
*
6+
* This software is released under the GNU General Public License version 3,
7+
* which covers the main part of arduino-cli.
8+
* The terms of this license can be found at:
9+
* https://www.gnu.org/licenses/gpl-3.0.en.html
10+
*
11+
* You can be released from the requirements of the above licenses by purchasing
12+
* a commercial license. Buying such a license is mandatory if you want to modify or
13+
* otherwise use the software for commercial activities involving the Arduino
14+
* software without disclosing the source code of your own applications. To purchase
15+
* a commercial license, send an email to license@arduino.cc.
16+
*/
17+
18+
#pragma once
19+
20+
#include "ConnectionHandlerDefinitions.h"
21+
#include <stdint.h>
22+
#include <IPAddress.h>
23+
24+
namespace models {
25+
#if defined(BOARD_HAS_WIFI)
26+
struct WiFiSetting {
27+
char ssid[33]; // Max length of ssid is 32 + \0
28+
char pwd[64]; // Max length of password is 63 + \0
29+
};
30+
#endif //defined(BOARD_HAS_WIFI)
31+
32+
#if defined(BOARD_HAS_ETHERNET)
33+
// this struct represents an ip address in its simplest form.
34+
// TODO should this stay here?
35+
// TODO it may be better to check for IPV6 compatibility to reduce size
36+
struct ip_addr {
37+
IPType type;
38+
union {
39+
uint8_t bytes[16];
40+
uint32_t dword[4];
41+
};
42+
};
43+
44+
struct EthernetSetting {
45+
ip_addr ip;
46+
ip_addr dns;
47+
ip_addr gateway;
48+
ip_addr netmask;
49+
unsigned long timeout;
50+
unsigned long response_timeout;
51+
};
52+
#endif // BOARD_HAS_ETHERNET
53+
54+
#if defined(BOARD_HAS_NB) || defined(BOARD_HAS_GSM) ||defined(BOARD_HAS_CELLULAR)
55+
struct CellularSetting {
56+
char pin[9];
57+
char apn[101]; // Max length of apn is 100 + \0
58+
char login[65];
59+
char pass[65];
60+
};
61+
#endif // defined(BOARD_HAS_NB) || defined(BOARD_HAS_GSM) || defined(BOARD_HAS_CATM1_NBIOT) || defined(BOARD_HAS_CELLULAR)
62+
63+
#if defined(BOARD_HAS_GSM)
64+
typedef CellularSetting GSMSetting;
65+
#endif //defined(BOARD_HAS_GSM)
66+
67+
#if defined(BOARD_HAS_NB)
68+
typedef CellularSetting NBSetting;
69+
#endif //defined(BOARD_HAS_NB)
70+
71+
#if defined(BOARD_HAS_CATM1_NBIOT)
72+
struct CATM1Setting {
73+
char pin[9];
74+
char apn[101]; // Max length of apn is 100 + \0
75+
char login[65];
76+
char pass[65];
77+
uint32_t band;
78+
uint8_t rat;
79+
};
80+
#endif //defined(BOARD_HAS_CATM1_NBIOT)
81+
82+
#if defined(BOARD_HAS_LORA)
83+
struct LoraSetting {
84+
char appeui[17]; // appeui is 8 octets * 2 (hex format) + \0
85+
char appkey[33]; // appeui is 16 octets * 2 (hex format) + \0
86+
uint8_t band;
87+
char channelMask[13];
88+
uint8_t deviceClass;
89+
};
90+
#endif
91+
92+
struct NetworkSetting {
93+
NetworkAdapter type;
94+
union {
95+
#if defined(BOARD_HAS_WIFI)
96+
WiFiSetting wifi;
97+
#endif
98+
99+
#if defined(BOARD_HAS_ETHERNET)
100+
EthernetSetting eth;
101+
#endif
102+
103+
#if defined(BOARD_HAS_NB)
104+
NBSetting nb;
105+
#endif
106+
107+
#if defined(BOARD_HAS_GSM)
108+
GSMSetting gsm;
109+
#endif
110+
111+
#if defined(BOARD_HAS_CATM1_NBIOT)
112+
CATM1Setting catm1;
113+
#endif
114+
115+
#if defined(BOARD_HAS_CELLULAR)
116+
CellularSetting cell;
117+
#endif
118+
119+
#if defined(BOARD_HAS_LORA)
120+
LoraSetting lora;
121+
#endif
122+
};
123+
};
124+
}

0 commit comments

Comments
 (0)