Skip to content

Commit b17b43c

Browse files
committed
add test files
1 parent bb2e0c9 commit b17b43c

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
.vscode
2-
paho_mqtt_test.py
3-
wake_on_lan_test.py

examples/tests/paho_mqtt_test.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import paho.mqtt.client as mqtt
2+
3+
# The callback for when the client receives a CONNACK response from the server.
4+
def on_connect(client, userdata, flags, rc):
5+
print("Connected with result code "+str(rc))
6+
# Subscribing in on_connect() means that if we lose the connection and
7+
# reconnect then subscriptions will be renewed.
8+
client.subscribe("$SYS/#")
9+
10+
# The callback for when a PUBLISH message is received from the server.
11+
def on_message(client, userdata, msg):
12+
print(msg.topic+" "+str(msg.payload))
13+
14+
client = mqtt.Client()
15+
client.on_connect = on_connect
16+
client.on_message = on_message
17+
18+
client.connect("192.168.1.8", 1883, 60)
19+
20+
# Blocking call that processes network traffic, dispatches callbacks and
21+
# handles reconnecting.
22+
# Other loop*() functions are available that give a threaded interface and a
23+
# manual interface.
24+
client.loop_forever()

examples/tests/wake_on_lan_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from wakeonlan import send_magic_packet
2+
3+
mac = "94:de:80:21:2f:11" # actual
4+
mac = "94:de:80:21:2f:10" # not correct
5+
6+
send_magic_packet(mac,ip_address="192.168.20.255")

0 commit comments

Comments
 (0)