Skip to content

Commit a4d4834

Browse files
committed
ran clang-format on all relevant sources
including all example sources
1 parent 2c22d90 commit a4d4834

File tree

32 files changed

+2193
-2197
lines changed

32 files changed

+2193
-2197
lines changed

RF24Client.cpp

+32-31
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ RF24Client::RF24Client() : data(NULL) {}
2626

2727
/*************************************************************/
2828

29-
RF24Client::RF24Client(uip_userdata_t *conn_data) : data(conn_data) {}
29+
RF24Client::RF24Client(uip_userdata_t* conn_data) : data(conn_data) {}
3030

3131
/*************************************************************/
3232

@@ -47,7 +47,7 @@ int RF24Client::connect(IPAddress ip, uint16_t port)
4747
uip_ipaddr_t ipaddr;
4848
uip_ip_addr(ipaddr, ip);
4949

50-
struct uip_conn *conn = uip_connect(&ipaddr, htons(port));
50+
struct uip_conn* conn = uip_connect(&ipaddr, htons(port));
5151

5252
if (conn)
5353
{
@@ -61,7 +61,7 @@ int RF24Client::connect(IPAddress ip, uint16_t port)
6161

6262
if ((conn->tcpstateflags & UIP_TS_MASK) == UIP_ESTABLISHED)
6363
{
64-
data = (uip_userdata_t *)conn->appstate;
64+
data = (uip_userdata_t*)conn->appstate;
6565
IF_RF24ETHERNET_DEBUG_CLIENT(Serial.print(millis()); Serial.print(F(" connected, state: ")); Serial.print(data->state); Serial.print(F(", first packet in: ")); Serial.println(data->packets_in););
6666
return 1;
6767
}
@@ -73,7 +73,6 @@ int RF24Client::connect(IPAddress ip, uint16_t port)
7373
break;
7474
}
7575
#endif
76-
7776
}
7877
}
7978
//delay(25);
@@ -86,7 +85,7 @@ int RF24Client::connect(IPAddress ip, uint16_t port)
8685

8786
/*************************************************************/
8887

89-
int RF24Client::connect(const char *host, uint16_t port)
88+
int RF24Client::connect(const char* host, uint16_t port)
9089
{
9190
// Look up the host first
9291
int ret = 0;
@@ -105,10 +104,12 @@ int RF24Client::connect(const char *host, uint16_t port)
105104
#endif
106105
return connect(remote_addr, port);
107106
}
108-
#else // ! UIP_UDP
109-
//Do something with the input paramaters to prevent compile time warnings
110-
if (host) {};
111-
if (port) {};
107+
#else // ! UIP_UDP
108+
//Do something with the input parameters to prevent compile time warnings
109+
if (host) {
110+
};
111+
if (port) {
112+
};
112113
#endif // ! UIP_UDP
113114

114115
#if defined(ETH_DEBUG_L1) || defined(RF24ETHERNET_DEBUG_DNS)
@@ -154,7 +155,7 @@ void RF24Client::stop()
154155

155156
// the next function allows us to use the client returned by
156157
// EthernetServer::available() as the condition in an if-statement.
157-
bool RF24Client::operator==(const RF24Client &rhs)
158+
bool RF24Client::operator==(const RF24Client& rhs)
158159
{
159160
return data && rhs.data && (data == rhs.data);
160161
}
@@ -176,14 +177,14 @@ size_t RF24Client::write(uint8_t c)
176177

177178
/*************************************************************/
178179

179-
size_t RF24Client::write(const uint8_t *buf, size_t size)
180+
size_t RF24Client::write(const uint8_t* buf, size_t size)
180181
{
181182
return _write(data, buf, size);
182183
}
183184

184185
/*************************************************************/
185186

186-
size_t RF24Client::_write(uip_userdata_t *u, const uint8_t *buf, size_t size)
187+
size_t RF24Client::_write(uip_userdata_t* u, const uint8_t* buf, size_t size)
187188
{
188189

189190
size_t total_written = 0;
@@ -200,7 +201,7 @@ size_t RF24Client::_write(uip_userdata_t *u, const uint8_t *buf, size_t size)
200201
goto test2;
201202
}
202203

203-
IF_RF24ETHERNET_DEBUG_CLIENT(Serial.println(); Serial.print(millis()); Serial.print(F(" UIPClient.write: writePacket(")); Serial.print(u->packets_out); Serial.print(F(") pos: ")); Serial.print(u->out_pos); Serial.print(F(", buf[")); Serial.print(size - total_written); Serial.print(F("]: '")); Serial.write((uint8_t *)buf + total_written, payloadSize); Serial.println(F("'")););
204+
IF_RF24ETHERNET_DEBUG_CLIENT(Serial.println(); Serial.print(millis()); Serial.print(F(" UIPClient.write: writePacket(")); Serial.print(u->packets_out); Serial.print(F(") pos: ")); Serial.print(u->out_pos); Serial.print(F(", buf[")); Serial.print(size - total_written); Serial.print(F("]: '")); Serial.write((uint8_t*)buf + total_written, payloadSize); Serial.println(F("'")););
204205

205206
memcpy(u->myData + u->out_pos, buf + total_written, payloadSize);
206207
u->packets_out = 1;
@@ -224,7 +225,7 @@ size_t RF24Client::_write(uip_userdata_t *u, const uint8_t *buf, size_t size)
224225

225226
/*************************************************************/
226227

227-
void uip_log(char *msg)
228+
void uip_log(char* msg)
228229
{
229230
//Serial.println();
230231
//Serial.println("** UIP LOG **");
@@ -238,21 +239,21 @@ void uip_log(char *msg)
238239

239240
void serialip_appcall(void)
240241
{
241-
uip_userdata_t *u = (uip_userdata_t *)uip_conn->appstate;
242+
uip_userdata_t* u = (uip_userdata_t*)uip_conn->appstate;
242243

243-
if(u && u->connectTimeout > 0){
244-
if(millis() - u->connectTimer > u->connectTimeout && u->initialData == false){
245-
uip_close();
246-
IF_RF24ETHERNET_DEBUG_CLIENT(Serial.println(); Serial.print(millis()); Serial.println("UIP Client close(timeout)"););
247-
}
244+
if (u && u->connectTimeout > 0) {
245+
if (millis() - u->connectTimer > u->connectTimeout && u->initialData == false) {
246+
uip_close();
247+
IF_RF24ETHERNET_DEBUG_CLIENT(Serial.println(); Serial.print(millis()); Serial.println("UIP Client close(timeout)"););
248+
}
248249
}
249-
250+
250251
/*******Connected**********/
251252
if (!u && uip_connected())
252253
{
253254
IF_RF24ETHERNET_DEBUG_CLIENT(Serial.println(); Serial.print(millis()); Serial.println(F(" UIPClient uip_connected")););
254255

255-
u = (uip_userdata_t *)EthernetClient::_allocateData();
256+
u = (uip_userdata_t*)EthernetClient::_allocateData();
256257

257258
if (u)
258259
{
@@ -273,7 +274,7 @@ void serialip_appcall(void)
273274
IF_RF24ETHERNET_DEBUG_CLIENT(Serial.println(); Serial.print(millis()); Serial.print(F(" UIPClient uip_newdata, uip_len:")); Serial.println(uip_len););
274275

275276
u->initialData = true;
276-
277+
277278
if (u->sent)
278279
{
279280
u->hold = (u->out_pos = (u->windowOpened = (u->packets_out = false)));
@@ -302,7 +303,7 @@ void serialip_appcall(void)
302303

303304
if (u->packets_in)
304305
{
305-
((uip_userdata_closed_t *)u)->lport = uip_conn->lport;
306+
((uip_userdata_closed_t*)u)->lport = uip_conn->lport;
306307
u->state |= UIP_CLIENT_REMOTECLOSED;
307308
IF_RF24ETHERNET_DEBUG_CLIENT(Serial.println(F("UIPClient close 1")););
308309
}
@@ -401,18 +402,18 @@ void serialip_appcall(void)
401402
IF_RF24ETHERNET_DEBUG_CLIENT(Serial.println(F("blocks outstanding transfer -> uip_stop()")););
402403
}
403404
}
404-
finish:;
405+
finish:;
405406

406407
if (u->state & UIP_CLIENT_RESTART && !u->windowOpened)
407408
{
408409
if (!(u->state & (UIP_CLIENT_CLOSE | UIP_CLIENT_REMOTECLOSED)))
409410
{
410411
uip_restart();
411-
#if defined ETH_DEBUG_L1
412+
#if defined ETH_DEBUG_L1
412413
Serial.println();
413414
Serial.print(millis());
414415
Serial.println(F(" UIPClient Re-Open TCP Window"));
415-
#endif
416+
#endif
416417
u->windowOpened = true;
417418
u->restartInterval = UIP_WINDOW_REOPEN_DELAY; //.75 seconds
418419
u->restartTime = u->connAbortTime = millis();
@@ -423,11 +424,11 @@ void serialip_appcall(void)
423424

424425
/*******************************************************/
425426

426-
uip_userdata_t *RF24Client::_allocateData()
427+
uip_userdata_t* RF24Client::_allocateData()
427428
{
428429
for (uint8_t sock = 0; sock < UIP_CONNS; sock++)
429430
{
430-
uip_userdata_t *data = &RF24Client::all_data[sock];
431+
uip_userdata_t* data = &RF24Client::all_data[sock];
431432
if (!data->state)
432433
{
433434
data->state = sock | UIP_CLIENT_CONNECTED;
@@ -473,7 +474,7 @@ int RF24Client::available()
473474

474475
/*************************************************************/
475476

476-
int RF24Client::_available(uip_userdata_t *u)
477+
int RF24Client::_available(uip_userdata_t* u)
477478
{
478479
if (u->packets_in)
479480
{
@@ -482,7 +483,7 @@ int RF24Client::_available(uip_userdata_t *u)
482483
return 0;
483484
}
484485

485-
int RF24Client::read(uint8_t *buf, size_t size)
486+
int RF24Client::read(uint8_t* buf, size_t size)
486487
{
487488
if (*this)
488489
{

RF24Client.h

+23-22
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,30 @@
2828
//#define UIP_SOCKET_NUMPACKETS 5
2929
//#endif
3030

31-
#define UIP_CLIENT_CONNECTED 0x10
32-
#define UIP_CLIENT_CLOSE 0x20
31+
#define UIP_CLIENT_CONNECTED 0x10
32+
#define UIP_CLIENT_CLOSE 0x20
3333
#define UIP_CLIENT_REMOTECLOSED 0x40
34-
#define UIP_CLIENT_RESTART 0x80
35-
#define UIP_CLIENT_STATEFLAGS (UIP_CLIENT_CONNECTED | UIP_CLIENT_CLOSE | UIP_CLIENT_REMOTECLOSED | UIP_CLIENT_RESTART)
36-
#define UIP_CLIENT_SOCKETS ~UIP_CLIENT_STATEFLAGS
34+
#define UIP_CLIENT_RESTART 0x80
35+
#define UIP_CLIENT_STATEFLAGS (UIP_CLIENT_CONNECTED | UIP_CLIENT_CLOSE | UIP_CLIENT_REMOTECLOSED | UIP_CLIENT_RESTART)
36+
#define UIP_CLIENT_SOCKETS ~UIP_CLIENT_STATEFLAGS
3737

3838
/**
3939
* @warning <b> This is used internally and should not be accessed directly by users </b>
4040
*/
41-
typedef struct {
41+
typedef struct
42+
{
4243
uint8_t state;
4344
uint8_t packets_in[UIP_SOCKET_NUMPACKETS];
4445
/** The local TCP port, in network byte order. */
4546
uint16_t lport;
4647
} uip_userdata_closed_t;
4748

48-
4949
/**
5050
* Data structure for holding per connection data
5151
* @warning <b> This is used internally and should not be accessed directly by users </b>
5252
*/
53-
typedef struct {
53+
typedef struct
54+
{
5455
bool hold;
5556
bool sent;
5657
bool packets_in;
@@ -61,7 +62,7 @@ typedef struct {
6162
uint16_t dataPos;
6263
uint16_t dataCnt;
6364
#if UIP_CLIENT_TIMER >= 0
64-
uint32_t timer;
65+
uint32_t timer;
6566
#endif
6667
uint32_t restartTime;
6768
uint32_t restartInterval;
@@ -72,11 +73,10 @@ typedef struct {
7273
bool initialData;
7374
} uip_userdata_t;
7475

75-
76-
class RF24Client : public Client {
76+
class RF24Client : public Client
77+
{
7778

7879
public:
79-
8080
/** Basic constructor */
8181
RF24Client();
8282

@@ -91,7 +91,7 @@ class RF24Client : public Client {
9191
* Lookups will generally return responses with a single A record if using hostnames like
9292
* "www.google.com" instead of "google.com" which works well with the default buffer size
9393
*/
94-
int connect(const char *host, uint16_t port);
94+
int connect(const char* host, uint16_t port);
9595

9696
/**
9797
* Read available data into a buffer
@@ -100,7 +100,7 @@ class RF24Client : public Client {
100100
* client.read(buf,size);
101101
* @endcode
102102
*/
103-
int read(uint8_t *buf, size_t size);
103+
int read(uint8_t* buf, size_t size);
104104

105105
/**
106106
* Read data one byte at a time
@@ -123,7 +123,7 @@ class RF24Client : public Client {
123123
size_t write(uint8_t);
124124

125125
/** Write a buffer of data, to be sent in a single TCP packet */
126-
size_t write(const uint8_t *buf, size_t size);
126+
size_t write(const uint8_t* buf, size_t size);
127127

128128
/**
129129
* Indicates whether data is available to be read by the client.
@@ -143,7 +143,7 @@ class RF24Client : public Client {
143143
* @note Calling client or server available() keeps the IP stack and RF24Network layer running, so needs to be called regularly,
144144
* even when disconnected or delaying for extended periods.
145145
*/
146-
int waitAvailable(uint32_t timeout=750);
146+
int waitAvailable(uint32_t timeout = 750);
147147

148148
/** Read a byte from the incoming buffer without advancing the point of reading */
149149
int peek();
@@ -155,21 +155,23 @@ class RF24Client : public Client {
155155

156156
operator bool();
157157
virtual bool operator==(const EthernetClient&);
158-
virtual bool operator!=(const EthernetClient& rhs) { return !this->operator==(rhs); };
158+
virtual bool operator!=(const EthernetClient& rhs)
159+
{
160+
return !this->operator==(rhs);
161+
};
159162

160163
static uip_userdata_t all_data[UIP_CONNS];
161164

162165
private:
163-
164-
RF24Client(struct uip_conn *_conn);
166+
RF24Client(struct uip_conn* _conn);
165167
RF24Client(uip_userdata_t* conn_data);
166168

167169
uip_userdata_t* data;
168170

169-
static int _available(uip_userdata_t *);
171+
static int _available(uip_userdata_t*);
170172

171173
static uip_userdata_t* _allocateData();
172-
static size_t _write(uip_userdata_t *,const uint8_t *buf, size_t size);
174+
static size_t _write(uip_userdata_t*, const uint8_t* buf, size_t size);
173175

174176
friend class RF24EthernetClass;
175177
friend class RF24Server;
@@ -178,5 +180,4 @@ class RF24Client : public Client {
178180
friend void uip_log(char* msg);
179181
};
180182

181-
182183
#endif // RF24CLIENT_H

0 commit comments

Comments
 (0)