Skip to content

Commit 0c109b5

Browse files
committed
Bridge: Renamed YunClient/YunServer to BridgeClient/BridgeServer
This makes the library more consistent and not tied to a specific board.
1 parent 954f59d commit 0c109b5

File tree

7 files changed

+55
-53
lines changed

7 files changed

+55
-53
lines changed

libraries/Bridge/examples/Bridge/Bridge.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
*/
2424

2525
#include <Bridge.h>
26-
#include <YunServer.h>
27-
#include <YunClient.h>
26+
#include <BridgeServer.h>
27+
#include <BridgeClient.h>
2828

2929
// Listen to the default port 5555, the Yún webserver
3030
// will forward there all the HTTP requests you send
31-
YunServer server;
31+
BridgeServer server;
3232

3333
void setup() {
3434
// Bridge startup
@@ -45,7 +45,7 @@ void setup() {
4545

4646
void loop() {
4747
// Get clients coming from server
48-
YunClient client = server.accept();
48+
BridgeClient client = server.accept();
4949

5050
// There is a new client?
5151
if (client) {
@@ -59,7 +59,7 @@ void loop() {
5959
delay(50); // Poll every 50ms
6060
}
6161

62-
void process(YunClient client) {
62+
void process(BridgeClient client) {
6363
// read the command
6464
String command = client.readStringUntil('/');
6565

@@ -79,7 +79,7 @@ void process(YunClient client) {
7979
}
8080
}
8181

82-
void digitalCommand(YunClient client) {
82+
void digitalCommand(BridgeClient client) {
8383
int pin, value;
8484

8585
// Read pin number
@@ -107,7 +107,7 @@ void digitalCommand(YunClient client) {
107107
Bridge.put(key, String(value));
108108
}
109109

110-
void analogCommand(YunClient client) {
110+
void analogCommand(BridgeClient client) {
111111
int pin, value;
112112

113113
// Read pin number
@@ -148,7 +148,7 @@ void analogCommand(YunClient client) {
148148
}
149149
}
150150

151-
void modeCommand(YunClient client) {
151+
void modeCommand(BridgeClient client) {
152152
int pin;
153153

154154
// Read pin number

libraries/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
*/
3737

3838
#include <Bridge.h>
39-
#include <YunServer.h>
40-
#include <YunClient.h>
39+
#include <BridgeServer.h>
40+
#include <BridgeClient.h>
4141

4242
// Listen on default port 5555, the webserver on the Yún
4343
// will forward there all the HTTP requests for us.
44-
YunServer server;
44+
BridgeServer server;
4545
String startString;
4646
long hits = 0;
4747

@@ -76,7 +76,7 @@ void setup() {
7676

7777
void loop() {
7878
// Get clients coming from server
79-
YunClient client = server.accept();
79+
BridgeClient client = server.accept();
8080

8181
// There is a new client?
8282
if (client) {

libraries/Bridge/keywords.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Mailbox KEYWORD1 YunMailboxConstructor
1515
HttpClient KEYWORD1 YunHttpClientConstructor
1616
YunServer KEYWORD1 YunServerConstructor
1717
YunClient KEYWORD1 YunClientConstructor
18+
BridgeServer KEYWORD1 YunServerConstructor
19+
BridgeClient KEYWORD1 YunClientConstructor
1820

1921
#######################################
2022
# Methods and Functions (KEYWORD2)
@@ -72,7 +74,7 @@ getAsynchronously KEYWORD2
7274
ready KEYWORD2
7375
getResult KEYWORD2
7476

75-
# YunServer Class
77+
# BridgeServer Class
7678
accept KEYWORD2
7779
stop KEYWORD2
7880
connect KEYWORD2

libraries/Bridge/src/YunClient.cpp renamed to libraries/Bridge/src/BridgeClient.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,26 @@
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

19-
#include <YunClient.h>
19+
#include <BridgeClient.h>
2020

21-
YunClient::YunClient(int _h, BridgeClass &_b) :
21+
BridgeClient::BridgeClient(int _h, BridgeClass &_b) :
2222
bridge(_b), handle(_h), opened(true), buffered(0) {
2323
}
2424

25-
YunClient::YunClient(BridgeClass &_b) :
25+
BridgeClient::BridgeClient(BridgeClass &_b) :
2626
bridge(_b), handle(0), opened(false), buffered(0) {
2727
}
2828

29-
YunClient::~YunClient() {
29+
BridgeClient::~BridgeClient() {
3030
}
3131

32-
YunClient& YunClient::operator=(const YunClient &_x) {
32+
BridgeClient& BridgeClient::operator=(const BridgeClient &_x) {
3333
opened = _x.opened;
3434
handle = _x.handle;
3535
return *this;
3636
}
3737

38-
void YunClient::stop() {
38+
void BridgeClient::stop() {
3939
if (opened) {
4040
uint8_t cmd[] = {'j', handle};
4141
bridge.transfer(cmd, 2);
@@ -45,7 +45,7 @@ void YunClient::stop() {
4545
readPos = 0;
4646
}
4747

48-
void YunClient::doBuffer() {
48+
void BridgeClient::doBuffer() {
4949
// If there are already char in buffer exit
5050
if (buffered > 0)
5151
return;
@@ -56,13 +56,13 @@ void YunClient::doBuffer() {
5656
buffered = bridge.transfer(cmd, 3, buffer, sizeof(buffer));
5757
}
5858

59-
int YunClient::available() {
59+
int BridgeClient::available() {
6060
// Look if there is new data available
6161
doBuffer();
6262
return buffered;
6363
}
6464

65-
int YunClient::read() {
65+
int BridgeClient::read() {
6666
doBuffer();
6767
if (buffered == 0)
6868
return -1; // no chars available
@@ -72,7 +72,7 @@ int YunClient::read() {
7272
}
7373
}
7474

75-
int YunClient::read(uint8_t *buff, size_t size) {
75+
int BridgeClient::read(uint8_t *buff, size_t size) {
7676
int readed = 0;
7777
do {
7878
if (buffered == 0) {
@@ -86,34 +86,34 @@ int YunClient::read(uint8_t *buff, size_t size) {
8686
return readed;
8787
}
8888

89-
int YunClient::peek() {
89+
int BridgeClient::peek() {
9090
doBuffer();
9191
if (buffered == 0)
9292
return -1; // no chars available
9393
else
9494
return buffer[readPos];
9595
}
9696

97-
size_t YunClient::write(uint8_t c) {
97+
size_t BridgeClient::write(uint8_t c) {
9898
if (!opened)
9999
return 0;
100100
uint8_t cmd[] = {'l', handle, c};
101101
bridge.transfer(cmd, 3);
102102
return 1;
103103
}
104104

105-
size_t YunClient::write(const uint8_t *buf, size_t size) {
105+
size_t BridgeClient::write(const uint8_t *buf, size_t size) {
106106
if (!opened)
107107
return 0;
108108
uint8_t cmd[] = {'l', handle};
109109
bridge.transfer(cmd, 2, buf, size, NULL, 0);
110110
return size;
111111
}
112112

113-
void YunClient::flush() {
113+
void BridgeClient::flush() {
114114
}
115115

116-
uint8_t YunClient::connected() {
116+
uint8_t BridgeClient::connected() {
117117
if (!opened)
118118
return false;
119119
// Client is "connected" if it has unread bytes
@@ -126,7 +126,7 @@ uint8_t YunClient::connected() {
126126
return (res[0] == 1);
127127
}
128128

129-
int YunClient::connect(IPAddress ip, uint16_t port) {
129+
int BridgeClient::connect(IPAddress ip, uint16_t port) {
130130
String address;
131131
address.reserve(18);
132132
address += ip[0];
@@ -139,7 +139,7 @@ int YunClient::connect(IPAddress ip, uint16_t port) {
139139
return connect(address.c_str(), port);
140140
}
141141

142-
int YunClient::connect(const char *host, uint16_t port) {
142+
int BridgeClient::connect(const char *host, uint16_t port) {
143143
uint8_t tmp[] = {
144144
'C',
145145
(port >> 8) & 0xFF,

libraries/Bridge/src/YunClient.h renamed to libraries/Bridge/src/BridgeClient.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

19-
#ifndef _YUN_CLIENT_H_
20-
#define _YUN_CLIENT_H_
19+
#ifndef _BRIDGE_CLIENT_H_
20+
#define _BRIDGE_CLIENT_H_
2121

2222
#include <Bridge.h>
2323
#include <Client.h>
2424

25-
class YunClient : public Client {
25+
class BridgeClient : public Client {
2626
public:
2727
// Constructor with a user provided BridgeClass instance
28-
YunClient(int _h, BridgeClass &_b = Bridge);
29-
YunClient(BridgeClass &_b = Bridge);
30-
~YunClient();
28+
BridgeClient(int _h, BridgeClass &_b = Bridge);
29+
BridgeClient(BridgeClass &_b = Bridge);
30+
~BridgeClient();
3131

3232
// Stream methods
3333
// (read message)
@@ -45,7 +45,7 @@ class YunClient : public Client {
4545
return opened;
4646
}
4747

48-
YunClient& operator=(const YunClient &_x);
48+
BridgeClient& operator=(const BridgeClient &_x);
4949

5050
virtual void stop();
5151
virtual uint8_t connected();
@@ -67,4 +67,4 @@ class YunClient : public Client {
6767

6868
};
6969

70-
#endif // _YUN_CLIENT_H_
70+
#endif // _BRIDGE_CLIENT_H_

libraries/Bridge/src/YunServer.cpp renamed to libraries/Bridge/src/BridgeServer.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

19-
#include <YunServer.h>
20-
#include <YunClient.h>
19+
#include <BridgeServer.h>
20+
#include <BridgeClient.h>
2121

22-
YunServer::YunServer(uint16_t _p, BridgeClass &_b) :
22+
BridgeServer::BridgeServer(uint16_t _p, BridgeClass &_b) :
2323
bridge(_b), port(_p), listening(false), useLocalhost(false) {
2424
}
2525

26-
void YunServer::begin() {
26+
void BridgeServer::begin() {
2727
uint8_t tmp[] = {
2828
'N',
2929
(port >> 8) & 0xFF,
@@ -37,16 +37,16 @@ void YunServer::begin() {
3737
listening = (res[0] == 1);
3838
}
3939

40-
YunClient YunServer::accept() {
40+
BridgeClient BridgeServer::accept() {
4141
uint8_t cmd[] = {'k'};
4242
uint8_t res[1];
4343
unsigned int l = bridge.transfer(cmd, 1, res, 1);
4444
if (l == 0)
45-
return YunClient();
46-
return YunClient(res[0]);
45+
return BridgeClient();
46+
return BridgeClient(res[0]);
4747
}
4848

49-
size_t YunServer::write(uint8_t c) {
49+
size_t BridgeServer::write(uint8_t c) {
5050
uint8_t cmd[] = { 'b', c };
5151
bridge.transfer(cmd, 2);
5252
return 1;

libraries/Bridge/src/YunServer.h renamed to libraries/Bridge/src/BridgeServer.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

19-
#ifndef _YUN_SERVER_H_
20-
#define _YUN_SERVER_H_
19+
#ifndef _BRIDGE_SERVER_H_
20+
#define _BRIDGE_SERVER_H_
2121

2222
#include <Bridge.h>
2323
#include <Server.h>
2424

25-
class YunClient;
25+
class BridgeClient;
2626

27-
class YunServer : public Server {
27+
class BridgeServer : public Server {
2828
public:
2929
// Constructor with a user provided BridgeClass instance
30-
YunServer(uint16_t port = 5555, BridgeClass &_b = Bridge);
30+
BridgeServer(uint16_t port = 5555, BridgeClass &_b = Bridge);
3131

3232
void begin();
33-
YunClient accept();
33+
BridgeClient accept();
3434

3535
virtual size_t write(uint8_t c);
3636

@@ -48,4 +48,4 @@ class YunServer : public Server {
4848
BridgeClass &bridge;
4949
};
5050

51-
#endif // _YUN_SERVER_H_
51+
#endif // _BRIDGE_SERVER_H_

0 commit comments

Comments
 (0)