Skip to content

Commit d4bb9d8

Browse files
facchinmmanchoz
authored andcommitted
Network: apply clang-format on libraries
1 parent 974f4c2 commit d4bb9d8

21 files changed

+852
-847
lines changed

libraries/Ethernet/src/Ethernet.cpp

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,85 +3,85 @@
33
#define SSID_MAX_LENGTH 32
44

55
int arduino::EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) {
6-
if (eth_if == nullptr) {
7-
//Q: What is the callback for?
8-
_initializerCallback();
9-
if(eth_if == nullptr) return 0;
10-
}
6+
if (eth_if == nullptr) {
7+
//Q: What is the callback for?
8+
_initializerCallback();
9+
if (eth_if == nullptr) return 0;
10+
}
1111

12-
unsigned long start = millis();
13-
eth_if->set_blocking(false);
14-
eth_if->connect();
12+
unsigned long start = millis();
13+
eth_if->set_blocking(false);
14+
eth_if->connect();
1515

16-
while ((millis() - start < timeout) && (linkStatus() != LinkON)) {
17-
delay(10);
18-
}
16+
while ((millis() - start < timeout) && (linkStatus() != LinkON)) {
17+
delay(10);
18+
}
1919

20-
return (linkStatus() == LinkON ? 1 : 0);
20+
return (linkStatus() == LinkON ? 1 : 0);
2121
}
2222

2323
int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip) {
24-
IPAddress dns = ip;
25-
dns[3] = 1;
24+
IPAddress dns = ip;
25+
dns[3] = 1;
2626

27-
auto ret = begin(mac, ip, dns);
28-
return ret;
27+
auto ret = begin(mac, ip, dns);
28+
return ret;
2929
}
3030

3131
int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns) {
32-
IPAddress gateway = ip;
33-
gateway[3] = 1;
34-
35-
auto ret = begin(mac, ip, dns, gateway);
36-
return ret;
32+
IPAddress gateway = ip;
33+
gateway[3] = 1;
34+
35+
auto ret = begin(mac, ip, dns, gateway);
36+
return ret;
3737
}
3838

3939
int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway) {
40-
IPAddress subnet(255, 255, 255, 0);
41-
auto ret = begin(mac, ip, dns, gateway, subnet);
42-
return ret;
40+
IPAddress subnet(255, 255, 255, 0);
41+
auto ret = begin(mac, ip, dns, gateway, subnet);
42+
return ret;
4343
}
4444

4545
int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet) {
46-
config(ip, dns, gateway, subnet);
46+
config(ip, dns, gateway, subnet);
4747

48-
eth_if->set_dhcp(false);
49-
eth_if->set_network(_ip, _netmask, _gateway);
50-
eth_if->add_dns_server(_dnsServer1, nullptr);
48+
eth_if->set_dhcp(false);
49+
eth_if->set_network(_ip, _netmask, _gateway);
50+
eth_if->add_dns_server(_dnsServer1, nullptr);
5151

52-
auto ret = begin(mac);
53-
return ret;
52+
auto ret = begin(mac);
53+
return ret;
5454
}
5555

5656
void arduino::EthernetClass::end() {
57-
disconnect();
57+
disconnect();
5858
}
5959

6060
EthernetLinkStatus arduino::EthernetClass::linkStatus() {
61-
return (eth_if->get_connection_status() == NSAPI_STATUS_GLOBAL_UP ? LinkON : LinkOFF);
61+
return (eth_if->get_connection_status() == NSAPI_STATUS_GLOBAL_UP ? LinkON : LinkOFF);
6262
}
6363

6464
EthernetHardwareStatus arduino::EthernetClass::hardwareStatus() {
65-
return EthernetMbed;
65+
return EthernetMbed;
6666
}
6767

6868

6969
int arduino::EthernetClass::disconnect() {
70-
eth_if->disconnect();
71-
return 1;
70+
eth_if->disconnect();
71+
return 1;
7272
}
7373

7474

75-
uint8_t arduino::EthernetClass::status() {
76-
return _currentNetworkStatus;
75+
uint8_t arduino::EthernetClass::status() {
76+
return _currentNetworkStatus;
7777
}
7878

7979
NetworkInterface *arduino::EthernetClass::getNetwork() {
80-
return eth_if;
80+
return eth_if;
8181
}
8282

8383
unsigned long arduino::EthernetClass::getTime() {
84-
return 0;
84+
return 0;
8585
}
8686

8787
arduino::EthernetClass Ethernet;

libraries/Ethernet/src/Ethernet.h

Lines changed: 76 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -30,86 +30,97 @@
3030
#include "EthernetInterface.h"
3131

3232
enum EthernetLinkStatus {
33-
Unknown,
34-
LinkON,
35-
LinkOFF
33+
Unknown,
34+
LinkON,
35+
LinkOFF
3636
};
3737

3838
enum EthernetHardwareStatus {
39-
EthernetNoHardware,
40-
EthernetMbed = 6
39+
EthernetNoHardware,
40+
EthernetMbed = 6
4141
};
4242

4343
namespace arduino {
4444

45-
typedef void* (*voidPrtFuncPtr)(void);
45+
typedef void *(*voidPrtFuncPtr)(void);
4646

4747
class EthernetClass : public MbedSocketClass {
4848

4949
public:
50-
// Initialise the Ethernet shield to use the provided MAC address and
51-
// gain the rest of the configuration through DHCP.
52-
// Returns 0 if the DHCP configuration failed, and 1 if it succeeded
53-
EthernetClass(EthernetInterface* _if) : eth_if(_if) {};
54-
EthernetClass() {};
55-
56-
EthernetClass(voidPrtFuncPtr _cb) : _initializerCallback(_cb) {};
57-
58-
int begin(uint8_t *mac = nullptr, unsigned long timeout = 60000, unsigned long responseTimeout = 4000);
59-
EthernetLinkStatus linkStatus();
60-
EthernetHardwareStatus hardwareStatus();
61-
62-
// Manual configuration
63-
int begin(uint8_t *mac, IPAddress ip);
64-
int begin(uint8_t *mac, IPAddress ip, IPAddress dns);
65-
int begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway);
66-
int begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet);
67-
68-
int begin(IPAddress ip) { return begin(nullptr, ip); }
69-
int begin(IPAddress ip, IPAddress dns) { return begin(nullptr, ip, dns); }
70-
int begin(IPAddress ip, IPAddress dns, IPAddress gateway) { return begin(nullptr, ip, dns, gateway); }
71-
int begin(IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet) {return begin(nullptr, ip, dns, gateway, subnet); }
72-
void init(uint8_t sspin = 10);
73-
74-
void MACAddress(uint8_t *mac_address);
75-
76-
void setHostname(const char* name);
77-
78-
int disconnect(void);
79-
void end(void);
80-
81-
uint8_t status();
82-
unsigned long getTime();
83-
84-
void setMACAddress(const uint8_t *mac_address);
85-
void setLocalIP(const IPAddress local_ip);
86-
void setSubnetMask(const IPAddress subnet);
87-
void setGatewayIP(const IPAddress gateway);
88-
void setDnsServerIP(const IPAddress dns_server) { _dnsServer1 = socketAddressFromIpAddress(dns_server, 0); }
89-
void setRetransmissionTimeout(uint16_t milliseconds);
90-
void setRetransmissionCount(uint8_t num);
91-
92-
friend class EthernetClient;
93-
friend class EthernetServer;
94-
friend class EthernetUDP;
95-
96-
NetworkInterface *getNetwork();
50+
// Initialise the Ethernet shield to use the provided MAC address and
51+
// gain the rest of the configuration through DHCP.
52+
// Returns 0 if the DHCP configuration failed, and 1 if it succeeded
53+
EthernetClass(EthernetInterface *_if)
54+
: eth_if(_if){};
55+
EthernetClass(){};
56+
57+
EthernetClass(voidPrtFuncPtr _cb)
58+
: _initializerCallback(_cb){};
59+
60+
int begin(uint8_t *mac = nullptr, unsigned long timeout = 60000, unsigned long responseTimeout = 4000);
61+
EthernetLinkStatus linkStatus();
62+
EthernetHardwareStatus hardwareStatus();
63+
64+
// Manual configuration
65+
int begin(uint8_t *mac, IPAddress ip);
66+
int begin(uint8_t *mac, IPAddress ip, IPAddress dns);
67+
int begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway);
68+
int begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet);
69+
70+
int begin(IPAddress ip) {
71+
return begin(nullptr, ip);
72+
}
73+
int begin(IPAddress ip, IPAddress dns) {
74+
return begin(nullptr, ip, dns);
75+
}
76+
int begin(IPAddress ip, IPAddress dns, IPAddress gateway) {
77+
return begin(nullptr, ip, dns, gateway);
78+
}
79+
int begin(IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet) {
80+
return begin(nullptr, ip, dns, gateway, subnet);
81+
}
82+
void init(uint8_t sspin = 10);
83+
84+
void MACAddress(uint8_t *mac_address);
85+
86+
void setHostname(const char *name);
87+
88+
int disconnect(void);
89+
void end(void);
90+
91+
uint8_t status();
92+
unsigned long getTime();
93+
94+
void setMACAddress(const uint8_t *mac_address);
95+
void setLocalIP(const IPAddress local_ip);
96+
void setSubnetMask(const IPAddress subnet);
97+
void setGatewayIP(const IPAddress gateway);
98+
void setDnsServerIP(const IPAddress dns_server) {
99+
_dnsServer1 = socketAddressFromIpAddress(dns_server, 0);
100+
}
101+
void setRetransmissionTimeout(uint16_t milliseconds);
102+
void setRetransmissionCount(uint8_t num);
103+
104+
friend class EthernetClient;
105+
friend class EthernetServer;
106+
friend class EthernetUDP;
107+
108+
NetworkInterface *getNetwork();
97109

98110
protected:
99-
SocketAddress _ip = nullptr;
100-
SocketAddress _gateway = nullptr;
101-
SocketAddress _netmask = nullptr;
102-
SocketAddress _dnsServer1 = nullptr;
103-
SocketAddress _dnsServer2 = nullptr;
111+
SocketAddress _ip = nullptr;
112+
SocketAddress _gateway = nullptr;
113+
SocketAddress _netmask = nullptr;
114+
SocketAddress _dnsServer1 = nullptr;
115+
SocketAddress _dnsServer2 = nullptr;
104116

105117
private:
106-
107-
volatile EthernetLinkStatus _currentNetworkStatus = Unknown;
108-
EthernetInterface net;
109-
EthernetInterface* eth_if = &net;
110-
voidPrtFuncPtr _initializerCallback;
111-
arduino::IPAddress ipAddressFromSocketAddress(SocketAddress socketAddress);
112-
SocketAddress socketAddressFromIpAddress(arduino::IPAddress ip, uint16_t port);
118+
volatile EthernetLinkStatus _currentNetworkStatus = Unknown;
119+
EthernetInterface net;
120+
EthernetInterface *eth_if = &net;
121+
voidPrtFuncPtr _initializerCallback;
122+
arduino::IPAddress ipAddressFromSocketAddress(SocketAddress socketAddress);
123+
SocketAddress socketAddressFromIpAddress(arduino::IPAddress ip, uint16_t port);
113124
};
114125

115126
}

libraries/Ethernet/src/EthernetClient.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
namespace arduino {
2727

2828
class EthernetClient : public MbedClient {
29-
NetworkInterface *getNetwork() {
30-
return Ethernet.getNetwork();
31-
}
29+
NetworkInterface *getNetwork() {
30+
return Ethernet.getNetwork();
31+
}
3232
};
3333

3434
}

libraries/Ethernet/src/EthernetServer.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ namespace arduino {
2626
class EthernetClient;
2727

2828
class EthernetServer : public MbedServer {
29-
NetworkInterface *getNetwork() {
30-
return Ethernet.getNetwork();
31-
}
29+
NetworkInterface* getNetwork() {
30+
return Ethernet.getNetwork();
31+
}
32+
3233
public:
33-
EthernetServer(uint16_t port) : MbedServer(port) {}
34-
EthernetClient available(uint8_t* status = nullptr);
34+
EthernetServer(uint16_t port)
35+
: MbedServer(port) {}
36+
EthernetClient available(uint8_t* status = nullptr);
3537
};
3638

3739
}

libraries/Ethernet/src/EthernetUdp.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
namespace arduino {
2727

2828
class EthernetUDP : public MbedUDP {
29-
NetworkInterface *getNetwork() {
30-
return Ethernet.getNetwork();
31-
}
29+
NetworkInterface *getNetwork() {
30+
return Ethernet.getNetwork();
31+
}
3232
};
3333

3434
}

0 commit comments

Comments
 (0)