Skip to content

Commit 91e9b9b

Browse files
committed
update
1 parent 6e2481d commit 91e9b9b

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/YunMQTTClient.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ boolean YunMQTTClient::connect(const char * clientId, const char * username, con
3434

3535
// wait for answer
3636
String ret = this->process.readStringUntil('\n');
37-
return ret.equals("ca");
37+
this->alive = ret.equals("ca");
38+
39+
return this->connected();
3840
}
3941

4042
void YunMQTTClient::publish(String topic) {
@@ -98,8 +100,7 @@ void YunMQTTClient::loop() {
98100
}
99101

100102
boolean YunMQTTClient::connected() {
101-
//TODO: fix!
102-
return true;
103+
return this->alive;
103104
}
104105

105106
void YunMQTTClient::disconnect() {

src/YunMQTTClient.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class YunMQTTClient {
1111
Process process;
1212
const char * hostname;
1313
int port;
14+
boolean alive = false;
1415
public:
1516
YunMQTTClient(const char * hostname, int port);
1617
boolean connect(const char * clientId);

yun/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,5 @@ def do_disconnect(client):
6767

6868
while True:
6969
parse_command(c, sys.stdin.readline()[0:-1])
70+
71+
# TODO: better error handling

0 commit comments

Comments
 (0)