diff options
Diffstat (limited to 'examples/clients/coap-client.py')
| -rw-r--r-- | examples/clients/coap-client.py | 15 |
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 @@ | |||
| 1 | from webiopi.protocols.coap import * | ||
| 2 | from time import sleep | ||
| 3 | |||
| 4 | client = COAPClient() | ||
| 5 | client.sendRequest(COAPPost("coap://224.0.1.123/GPIO/25/function/out")) | ||
| 6 | state = True | ||
| 7 | |||
| 8 | while 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) | ||
