File tree 1 file changed +4
-54
lines changed 1 file changed +4
-54
lines changed Original file line number Diff line number Diff line change @@ -27,62 +27,12 @@ Here is a list of platforms that are supported:
27
27
- [ Arduino Yùn] ( https://www.arduino.cc/en/Main/ArduinoBoardYun )
28
28
- [ ESP8266] ( https://github.com/esp8266/Arduino )
29
29
30
- ## Example
30
+ ## Examples
31
31
32
- - [ Example using the alternative YunMQTTClient ] ( https://github.com/256dpi/arduino-mqtt/blob/master/examples/YunMQTTClient/YunMQTTClient.ino ) .
32
+ The examples show how you can use the library with your hardware:
33
33
34
- ``` c++
35
- #include < Bridge.h>
36
- #include < YunClient.h>
37
- #include < MQTTClient.h>
38
-
39
- YunClient net;
40
- MQTTClient client;
41
-
42
- unsigned long lastMillis = 0 ;
43
-
44
- void setup () {
45
- Bridge.begin();
46
- Serial.begin(9600);
47
- client.begin("broker.shiftr.io", net);
48
-
49
- connect ();
50
- }
51
-
52
- void connect () {
53
- Serial.print("connecting...");
54
- while (!client.connect("arduino", "try", "try")) {
55
- Serial.print(".");
56
- }
57
-
58
- Serial.println("\nconnected!");
59
-
60
- client.subscribe("/example");
61
- // client.unsubscribe("/example");
62
- }
63
-
64
- void loop () {
65
- client.loop();
66
-
67
- if(!client.connected()) {
68
- connect();
69
- }
70
-
71
- // publish a message roughly every second.
72
- if(millis() - lastMillis > 1000) {
73
- lastMillis = millis();
74
- client.publish("/hello", "world");
75
- }
76
- }
77
-
78
- void messageReceived (String topic, String payload, char * bytes, unsigned int length) {
79
- Serial.print("incoming: ");
80
- Serial.print(topic);
81
- Serial.print(" - ");
82
- Serial.print(payload);
83
- Serial.println();
84
- }
85
- ```
34
+ - [ ArduinoYun_MQTTClient] ( https://github.com/256dpi/arduino-mqtt/blob/master/examples/ArduinoYun_MQTTClient/ArduinoYun_MQTTClient.ino )
35
+ - [ ArduinoYun_YunMQTTClient] ( https://github.com/256dpi/arduino-mqtt/blob/master/examples/ArduinoYun_YunMQTTClient/ArduinoYun_YunMQTTClient.ino )
86
36
87
37
## API
88
38
You can’t perform that action at this time.
0 commit comments