summaryrefslogtreecommitdiffstats
path: root/examples/clients/coap-client.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/clients/coap-client.py')
-rw-r--r--examples/clients/coap-client.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/clients/coap-client.py b/examples/clients/coap-client.py
new file mode 100644
index 0000000..eba80e9
--- /dev/null
+++ b/examples/clients/coap-client.py
@@ -0,0 +1,15 @@
1from webiopi.protocols.coap import *
2from time import sleep
3
4client = COAPClient()
5client.sendRequest(COAPPost("coap://224.0.1.123/GPIO/25/function/out"))
6state = True
7
8while True:
9 response = client.sendRequest(COAPPost("coap://224.0.1.123/GPIO/25/value/%d" % state))
10 if response:
11 print("Received response:\n%s" % response)
12 state = not state
13 else:
14 print("No response received")
15 sleep(0.5)